Commit 92354ccd authored by samuong's avatar samuong Committed by Commit bot

[chromedriver] Remove extra call to HttpServer::Close() and increase TestHttpServer buffer limit

BUG=
TBR=stgao@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#295871}
parent edbfba94
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include "net/socket/tcp_server_socket.h" #include "net/socket/tcp_server_socket.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
const int kBufferSize = 100 * 1024 * 1024; // 100 MB
TestHttpServer::TestHttpServer() TestHttpServer::TestHttpServer()
: thread_("ServerThread"), : thread_("ServerThread"),
all_closed_event_(false, true), all_closed_event_(false, true),
...@@ -73,9 +75,19 @@ GURL TestHttpServer::web_socket_url() const { ...@@ -73,9 +75,19 @@ GURL TestHttpServer::web_socket_url() const {
return web_socket_url_; return web_socket_url_;
} }
void TestHttpServer::OnHttpRequest(
int connection_id,
const net::HttpServerRequestInfo& info) {
server_->SetSendBufferSize(connection_id, kBufferSize);
server_->SetReceiveBufferSize(connection_id, kBufferSize);
}
void TestHttpServer::OnWebSocketRequest( void TestHttpServer::OnWebSocketRequest(
int connection_id, int connection_id,
const net::HttpServerRequestInfo& info) { const net::HttpServerRequestInfo& info) {
server_->SetSendBufferSize(connection_id, kBufferSize);
server_->SetReceiveBufferSize(connection_id, kBufferSize);
WebSocketRequestAction action; WebSocketRequestAction action;
{ {
base::AutoLock lock(action_lock_); base::AutoLock lock(action_lock_);
...@@ -99,6 +111,8 @@ void TestHttpServer::OnWebSocketRequest( ...@@ -99,6 +111,8 @@ void TestHttpServer::OnWebSocketRequest(
void TestHttpServer::OnWebSocketMessage(int connection_id, void TestHttpServer::OnWebSocketMessage(int connection_id,
const std::string& data) { const std::string& data) {
server_->SetSendBufferSize(connection_id, kBufferSize);
server_->SetReceiveBufferSize(connection_id, kBufferSize);
WebSocketMessageAction action; WebSocketMessageAction action;
{ {
base::AutoLock lock(action_lock_); base::AutoLock lock(action_lock_);
......
...@@ -62,7 +62,7 @@ class TestHttpServer : public net::HttpServer::Delegate { ...@@ -62,7 +62,7 @@ class TestHttpServer : public net::HttpServer::Delegate {
// Overridden from net::HttpServer::Delegate: // Overridden from net::HttpServer::Delegate:
virtual void OnHttpRequest(int connection_id, virtual void OnHttpRequest(int connection_id,
const net::HttpServerRequestInfo& info) OVERRIDE {} const net::HttpServerRequestInfo& info) OVERRIDE;
virtual void OnWebSocketRequest( virtual void OnWebSocketRequest(
int connection_id, int connection_id,
const net::HttpServerRequestInfo& info) OVERRIDE; const net::HttpServerRequestInfo& info) OVERRIDE;
......
...@@ -87,7 +87,8 @@ class HttpServer : public net::HttpServer::Delegate { ...@@ -87,7 +87,8 @@ class HttpServer : public net::HttpServer::Delegate {
// the connection to close (e.g., python 2.7 urllib). // the connection to close (e.g., python 2.7 urllib).
response->AddHeader("Connection", "close"); response->AddHeader("Connection", "close");
server_->SendResponse(connection_id, *response); server_->SendResponse(connection_id, *response);
server_->Close(connection_id); // Don't need to call server_->Close(), since SendResponse() will handle
// this for us.
} }
HttpRequestHandlerFunc handle_request_func_; HttpRequestHandlerFunc handle_request_func_;
......
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