Set stricter limit for body payloads

Summary:
Base64 encoding can easily cause OOMs for large payloads.

In the long-term, it would be great to have a way of streaming these
responses so we don't allocate 50MB chunks of memory at once.

Reviewed By: jknoxville

Differential Revision: D17951353

fbshipit-source-id: a5d7b8242892518590ac95c1d9751f24d20dc40e
This commit is contained in:
Pascal Hartig
2019-10-16 09:28:33 -07:00
committed by Facebook Github Bot
parent 9e96f0c7c2
commit 182b4e1b1f

View File

@@ -16,6 +16,7 @@ import java.util.List;
public class NetworkFlipperPlugin extends BufferingFlipperPlugin implements NetworkReporter { public class NetworkFlipperPlugin extends BufferingFlipperPlugin implements NetworkReporter {
public static final String ID = "Network"; public static final String ID = "Network";
private static final int MAX_BODY_SIZE_IN_BYTES = 1024 * 1024;
private final List<NetworkResponseFormatter> mFormatters; private final List<NetworkResponseFormatter> mFormatters;
@@ -114,6 +115,10 @@ public class NetworkFlipperPlugin extends BufferingFlipperPlugin implements Netw
return false; return false;
} }
if (responseInfo.body != null && responseInfo.body.length > MAX_BODY_SIZE_IN_BYTES) {
return true;
}
return contentType.value.contains("image/") return contentType.value.contains("image/")
|| contentType.value.contains("video/") || contentType.value.contains("video/")
|| contentType.value.contains("application/zip"); || contentType.value.contains("application/zip");