Add HTTP Status Code to mock response for Route (#1441)
Summary: Mock requests can currently only return an HTTP Status Code of 200. This is not sufficient to take full advantage of the mocking feature. It would be more useful to specify a status code for the response. Then not only can the original request be tested, but failure of the call could be tested as well. This is described in Issue https://github.com/facebook/flipper/issues/1423 [https://github.com/facebook/flipper/issues/1423] Changelog: Allow user to change response code for a mock request Pull Request resolved: https://github.com/facebook/flipper/pull/1441 Test Plan: Here is a video demonstrating the change [Uploading response-status-code.mp4.zip…] Here is a screenshot showing where the new HTTP status code is entered for the mock request:  This screenshot shows a mock response with an alternate return code:  Reviewed By: jknoxville Differential Revision: D22977811 Pulled By: passy fbshipit-source-id: c1662dd02abeb4546c80a416ed87f8e0dadbf96a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5f8ba09534
commit
6989fa608d
@@ -228,10 +228,12 @@ public class FlipperOkhttpInterceptor
|
||||
if (TextUtils.isEmpty(requestUrl) || TextUtils.isEmpty(method)) {
|
||||
return null;
|
||||
}
|
||||
final int statusCode = route.getInt("status");
|
||||
|
||||
final ResponseInfo mockResponse = new ResponseInfo();
|
||||
mockResponse.body = data.getBytes();
|
||||
mockResponse.statusCode = HttpURLConnection.HTTP_OK;
|
||||
mockResponse.statusCode = statusCode;
|
||||
mockResponse.statusReason = "OK";
|
||||
if (headersArray != null) {
|
||||
final List<NetworkReporter.Header> headers = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user