Commit 736efbc1 authored by John Chen's avatar John Chen Committed by Commit Bot

[ChromeDriver] Support persistent client connection

Modify ChromeDriver so it doesn't force closing client HTTP connection
if request header has connection:keep-alive.

Bug: chromedriver:2183
Change-Id: I965fe3e25c7d9cee8050ed90933acbfb0e70a5d7
Reviewed-on: https://chromium-review.googlesource.com/844355Reviewed-by: default avatarJonathon Kereliuk <kereliuk@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#527006}
parent cb99c7d5
...@@ -106,7 +106,8 @@ class HttpServer : public net::HttpServer::Delegate { ...@@ -106,7 +106,8 @@ class HttpServer : public net::HttpServer::Delegate {
info, info,
base::Bind(&HttpServer::OnResponse, base::Bind(&HttpServer::OnResponse,
weak_factory_.GetWeakPtr(), weak_factory_.GetWeakPtr(),
connection_id)); connection_id,
info.HasHeaderValue("connection", "keep-alive")));
} }
void OnWebSocketRequest(int connection_id, void OnWebSocketRequest(int connection_id,
const net::HttpServerRequestInfo& info) override {} const net::HttpServerRequestInfo& info) override {}
...@@ -116,11 +117,10 @@ class HttpServer : public net::HttpServer::Delegate { ...@@ -116,11 +117,10 @@ class HttpServer : public net::HttpServer::Delegate {
private: private:
void OnResponse(int connection_id, void OnResponse(int connection_id,
bool keep_alive,
std::unique_ptr<net::HttpServerResponseInfo> response) { std::unique_ptr<net::HttpServerResponseInfo> response) {
// Don't support keep-alive, since there's no way to detect if the if (!keep_alive)
// client is HTTP/1.0. In such cases, the client may hang waiting for response->AddHeader("Connection", "close");
// the connection to close (e.g., python 2.7 urllib).
response->AddHeader("Connection", "close");
server_->SendResponse(connection_id, *response); server_->SendResponse(connection_id, *response);
// Don't need to call server_->Close(), since SendResponse() will handle // Don't need to call server_->Close(), since SendResponse() will handle
// this for us. // this for us.
......
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