| Index: net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java
|
| diff --git a/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java b/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java
|
| index 5ca9b52aa893d7ae57ae61d718e1664d2babfaa5..ab6f5cda413ee382dd0258492cc3b242f1b695d5 100644
|
| --- a/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java
|
| +++ b/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java
|
| @@ -84,14 +84,16 @@ public class TestWebServer {
|
| final boolean mIsNotFound;
|
| final boolean mIsNoContent;
|
| final boolean mForWebSocket;
|
| + final boolean mIsEmptyResponse;
|
|
|
| Response(byte[] responseData, List<Pair<String, String>> responseHeaders,
|
| boolean isRedirect, boolean isNotFound, boolean isNoContent, boolean forWebSocket,
|
| - Runnable responseAction) {
|
| + boolean isEmptyResponse, Runnable responseAction) {
|
| mIsRedirect = isRedirect;
|
| mIsNotFound = isNotFound;
|
| mIsNoContent = isNoContent;
|
| mForWebSocket = forWebSocket;
|
| + mIsEmptyResponse = isEmptyResponse;
|
| mResponseData = responseData;
|
| mResponseHeaders = responseHeaders == null
|
| ? new ArrayList<Pair<String, String>>() : responseHeaders;
|
| @@ -201,6 +203,7 @@ public class TestWebServer {
|
| private static final int RESPONSE_STATUS_NOT_FOUND = 2;
|
| private static final int RESPONSE_STATUS_NO_CONTENT = 3;
|
| private static final int RESPONSE_STATUS_FOR_WEBSOCKET = 4;
|
| + private static final int RESPONSE_STATUS_EMPTY_RESPONSE = 5;
|
|
|
| private String setResponseInternal(
|
| String requestPath, byte[] responseData,
|
| @@ -210,11 +213,12 @@ public class TestWebServer {
|
| final boolean isNotFound = (status == RESPONSE_STATUS_NOT_FOUND);
|
| final boolean isNoContent = (status == RESPONSE_STATUS_NO_CONTENT);
|
| final boolean forWebSocket = (status == RESPONSE_STATUS_FOR_WEBSOCKET);
|
| + final boolean isEmptyResponse = (status == RESPONSE_STATUS_EMPTY_RESPONSE);
|
|
|
| synchronized (mLock) {
|
| - mResponseMap.put(
|
| - requestPath, new Response(responseData, responseHeaders, isRedirect, isNotFound,
|
| - isNoContent, forWebSocket, responseAction));
|
| + mResponseMap.put(requestPath,
|
| + new Response(responseData, responseHeaders, isRedirect, isNotFound, isNoContent,
|
| + forWebSocket, isEmptyResponse, responseAction));
|
| mResponseCountMap.put(requestPath, Integer.valueOf(0));
|
| mLastRequestMap.put(requestPath, null);
|
| }
|
| @@ -273,6 +277,18 @@ public class TestWebServer {
|
| }
|
|
|
| /**
|
| + * Sets an empty response to be returned when a particular request path is passed in.
|
| + *
|
| + * @param requestPath The path to respond to.
|
| + * @return The full URL including the path that should be requested to get the expected
|
| + * response.
|
| + */
|
| + public String setEmptyResponse(String requestPath) {
|
| + return setResponseInternal(
|
| + requestPath, "".getBytes(), null, null, RESPONSE_STATUS_EMPTY_RESPONSE);
|
| + }
|
| +
|
| + /**
|
| * Sets a response to be returned when a particular request path is passed
|
| * in (with the option to specify additional headers).
|
| *
|
| @@ -504,6 +520,10 @@ public class TestWebServer {
|
| httpResponse = createResponse(HttpStatus.SC_NO_CONTENT);
|
| httpResponse.setHeader("Content-Length", "0");
|
| servedResponseFor(path, request);
|
| + } else if (response.mIsEmptyResponse) {
|
| + httpResponse = createResponse(HttpStatus.SC_FORBIDDEN); // arbitrary failure status
|
| + httpResponse.setHeader("Content-Length", "0");
|
| + servedResponseFor(path, request);
|
| } else if (response.mIsRedirect) {
|
| httpResponse = createResponse(HttpStatus.SC_MOVED_TEMPORARILY);
|
| for (Pair<String, String> header : response.mResponseHeaders) {
|
|
|