Commit 9003aae1 authored by hush's avatar hush Committed by Commit bot

Set content-length header for httpResponses.

The client might wait forever if the server fails to close
the connection.

BUG=

Review URL: https://codereview.chromium.org/501603002

Cr-Commit-Position: refs/heads/master@{#291711}
parent d009777f
......@@ -422,7 +422,9 @@ public class TestWebServer {
if (response.mResponseAction != null) response.mResponseAction.run();
httpResponse = createResponse(HttpStatus.SC_OK);
httpResponse.setEntity(createEntity(response.mResponseData));
ByteArrayEntity entity = createEntity(response.mResponseData);
httpResponse.setEntity(entity);
httpResponse.setHeader("Content-Length", "" + entity.getContentLength());
for (Pair<String, String> header : response.mResponseHeaders) {
httpResponse.addHeader(header.first, header.second);
}
......@@ -465,7 +467,9 @@ public class TestWebServer {
buf.append("</title></head><body>");
buf.append(reason);
buf.append("</body></html>");
response.setEntity(createEntity(buf.toString().getBytes()));
ByteArrayEntity entity = createEntity(buf.toString().getBytes());
response.setEntity(entity);
response.setHeader("Content-Length", "" + entity.getContentLength());
}
return response;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment