OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <algorithm> | 5 #include <algorithm> |
6 #include <utility> | 6 #include <utility> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 HttpServerTest() : quit_after_request_count_(0) {} | 182 HttpServerTest() : quit_after_request_count_(0) {} |
183 | 183 |
184 virtual void SetUp() OVERRIDE { | 184 virtual void SetUp() OVERRIDE { |
185 scoped_ptr<ServerSocket> server_socket( | 185 scoped_ptr<ServerSocket> server_socket( |
186 new TCPServerSocket(NULL, net::NetLog::Source())); | 186 new TCPServerSocket(NULL, net::NetLog::Source())); |
187 server_socket->ListenWithAddressAndPort("127.0.0.1", 0, 1); | 187 server_socket->ListenWithAddressAndPort("127.0.0.1", 0, 1); |
188 server_.reset(new HttpServer(server_socket.Pass(), this)); | 188 server_.reset(new HttpServer(server_socket.Pass(), this)); |
189 ASSERT_EQ(OK, server_->GetLocalAddress(&server_address_)); | 189 ASSERT_EQ(OK, server_->GetLocalAddress(&server_address_)); |
190 } | 190 } |
191 | 191 |
| 192 virtual void OnConnect(int connection_id) OVERRIDE {} |
| 193 |
192 virtual void OnHttpRequest(int connection_id, | 194 virtual void OnHttpRequest(int connection_id, |
193 const HttpServerRequestInfo& info) OVERRIDE { | 195 const HttpServerRequestInfo& info) OVERRIDE { |
194 requests_.push_back(std::make_pair(info, connection_id)); | 196 requests_.push_back(std::make_pair(info, connection_id)); |
195 if (requests_.size() == quit_after_request_count_) | 197 if (requests_.size() == quit_after_request_count_) |
196 run_loop_quit_func_.Run(); | 198 run_loop_quit_func_.Run(); |
197 } | 199 } |
198 | 200 |
199 virtual void OnWebSocketRequest(int connection_id, | 201 virtual void OnWebSocketRequest(int connection_id, |
200 const HttpServerRequestInfo& info) OVERRIDE { | 202 const HttpServerRequestInfo& info) OVERRIDE { |
201 NOTREACHED(); | 203 NOTREACHED(); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 | 615 |
614 ASSERT_EQ(client_connection_id, GetConnectionId(2)); | 616 ASSERT_EQ(client_connection_id, GetConnectionId(2)); |
615 server_->Send200(client_connection_id, "Content for /test3", "text/plain"); | 617 server_->Send200(client_connection_id, "Content for /test3", "text/plain"); |
616 std::string response3; | 618 std::string response3; |
617 ASSERT_TRUE(client.ReadResponse(&response3)); | 619 ASSERT_TRUE(client.ReadResponse(&response3)); |
618 ASSERT_TRUE(StartsWithASCII(response3, "HTTP/1.1 200 OK", true)); | 620 ASSERT_TRUE(StartsWithASCII(response3, "HTTP/1.1 200 OK", true)); |
619 ASSERT_TRUE(EndsWith(response3, "Content for /test3", true)); | 621 ASSERT_TRUE(EndsWith(response3, "Content for /test3", true)); |
620 } | 622 } |
621 | 623 |
622 } // namespace net | 624 } // namespace net |
OLD | NEW |