Index: net/server/http_server_unittest.cc |
diff --git a/net/server/http_server_unittest.cc b/net/server/http_server_unittest.cc |
index 42e56399a10afc4d3ed71d17ebe8573957fad1f8..03f13bdf3b3260512f5196343ef67f99a2a79127 100644 |
--- a/net/server/http_server_unittest.cc |
+++ b/net/server/http_server_unittest.cc |
@@ -189,6 +189,8 @@ class HttpServerTest : public testing::Test, |
ASSERT_EQ(OK, server_->GetLocalAddress(&server_address_)); |
} |
+ virtual void OnConnect(int connection_id) OVERRIDE {} |
+ |
virtual void OnHttpRequest(int connection_id, |
const HttpServerRequestInfo& info) OVERRIDE { |
requests_.push_back(std::make_pair(info, connection_id)); |
@@ -619,4 +621,28 @@ TEST_F(HttpServerTest, MultipleRequestsOnSameConnection) { |
ASSERT_TRUE(EndsWith(response3, "Content for /test3", true)); |
} |
+namespace { |
mmenke
2014/09/24 15:38:45
nit: Can you just stick this entire file in the a
samuong
2014/09/24 16:32:51
I've done this as much as possible, but HttpServer
|
+ |
+class CloseOnConnectHttpServerTest : public HttpServerTest { |
+ public: |
+ virtual void OnConnect(int connection_id) OVERRIDE { |
+ connection_ids_.push_back(connection_id); |
+ server_->Close(connection_id); |
+ } |
+ |
+ protected: |
+ std::vector<int> connection_ids_; |
+}; |
+ |
+} // namespace |
mmenke
2014/09/24 15:38:45
nit: 2 spaces between code and comment.
samuong
2014/09/24 16:32:51
Done.
|
+ |
+TEST_F(CloseOnConnectHttpServerTest, ServerImmediatelyClosesConnection) { |
+ TestHttpClient client; |
+ ASSERT_EQ(OK, client.ConnectAndWait(server_address_)); |
+ ASSERT_EQ(1ul, connection_ids_.size()); |
+ client.Send("GET / HTTP/1.1\r\n\r\n"); |
+ ASSERT_FALSE(RunUntilRequestsReceived(1)); |
+ ASSERT_EQ(0ul, requests_.size()); |
+} |
+ |
} // namespace net |