Network plugin - fix issue with responses with empty body (#1776)
Summary: The Network Plugin does not properly handle network requests that return an empty body (because of the body actually being empty or because the network call returns something like a 404 status). Also, the creation of mocks using the "Copy Highlighted" command when the original response returns an empty body is not handled properly. ## Fix The Android plugin now returns a response when the body length is 0. The client plugin creates a body containing an empty string instead of null when the body is empty. ## Changelog Fix problem in Network Plugin when original call or mock has an empty body in the response. Pull Request resolved: https://github.com/facebook/flipper/pull/1776 Test Plan: The following screen output for the Network Plugin shows that the call is now being handled correctly. The fields for "status", "size" and "duration" are now populated. Also, the mock calls are properly defined and shown in yellow.  Reviewed By: mweststrate Differential Revision: D25804212 Pulled By: passy fbshipit-source-id: b31cc87619c604b4df76e05bca5c86554a1cabff
This commit is contained in:
committed by
Facebook GitHub Bot
parent
02da9baa4b
commit
f806ee41d7
@@ -69,7 +69,9 @@ public class NetworkFlipperPlugin extends BufferingFlipperPlugin implements Netw
|
|||||||
int numChunks =
|
int numChunks =
|
||||||
responseInfo.body == null
|
responseInfo.body == null
|
||||||
? 1
|
? 1
|
||||||
: (int) Math.ceil((double) responseInfo.body.length / MAX_BODY_SIZE_IN_BYTES);
|
: Math.max(
|
||||||
|
(int) Math.ceil((double) responseInfo.body.length / MAX_BODY_SIZE_IN_BYTES),
|
||||||
|
1);
|
||||||
|
|
||||||
for (int i = 0; i < numChunks; i++) {
|
for (int i = 0; i < numChunks; i++) {
|
||||||
byte[] chunk =
|
byte[] chunk =
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ export function plugin(client: PluginClient<Events, Methods>) {
|
|||||||
|
|
||||||
// convert data TODO: we only want this for non-binary data! See D23403095
|
// convert data TODO: we only want this for non-binary data! See D23403095
|
||||||
const responseData =
|
const responseData =
|
||||||
response && response.data ? decodeBody(response) : null;
|
response && response.data ? decodeBody(response) : '';
|
||||||
|
|
||||||
const newNextRouteId = nextRouteId.get();
|
const newNextRouteId = nextRouteId.get();
|
||||||
routes.update((draft) => {
|
routes.update((draft) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user