OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <math.h> // ceil | 5 #include <math.h> // ceil |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 CaptureGroupNameSocketPool() : TCPClientSocketPool(0, 0, NULL, NULL, NULL) {} | 187 CaptureGroupNameSocketPool() : TCPClientSocketPool(0, 0, NULL, NULL, NULL) {} |
188 const std::string last_group_name_received() const { | 188 const std::string last_group_name_received() const { |
189 return last_group_name_; | 189 return last_group_name_; |
190 } | 190 } |
191 | 191 |
192 virtual int RequestSocket(const std::string& group_name, | 192 virtual int RequestSocket(const std::string& group_name, |
193 const void* socket_params, | 193 const void* socket_params, |
194 RequestPriority priority, | 194 RequestPriority priority, |
195 ClientSocketHandle* handle, | 195 ClientSocketHandle* handle, |
196 CompletionCallback* callback, | 196 CompletionCallback* callback, |
197 LoadLog* load_log) { | 197 const BoundNetLog& net_log) { |
198 last_group_name_ = group_name; | 198 last_group_name_ = group_name; |
199 return ERR_IO_PENDING; | 199 return ERR_IO_PENDING; |
200 } | 200 } |
201 virtual void CancelRequest(const std::string& group_name, | 201 virtual void CancelRequest(const std::string& group_name, |
202 const ClientSocketHandle* handle) { } | 202 const ClientSocketHandle* handle) { } |
203 virtual void ReleaseSocket(const std::string& group_name, | 203 virtual void ReleaseSocket(const std::string& group_name, |
204 ClientSocket* socket) {} | 204 ClientSocket* socket) {} |
205 virtual void CloseIdleSockets() {} | 205 virtual void CloseIdleSockets() {} |
206 virtual HostResolver* GetHostResolver() const { | 206 virtual HostResolver* GetHostResolver() const { |
207 return NULL; | 207 return NULL; |
(...skipping 4065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4273 | 4273 |
4274 session_deps.socket_factory.AddSocketDataProvider(&data); | 4274 session_deps.socket_factory.AddSocketDataProvider(&data); |
4275 | 4275 |
4276 TestCompletionCallback callback; | 4276 TestCompletionCallback callback; |
4277 | 4277 |
4278 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 4278 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
4279 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 4279 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
4280 | 4280 |
4281 int rv = trans->Start(&request, &callback, NULL); | 4281 int rv = trans->Start(&request, &callback, NULL); |
4282 EXPECT_EQ(ERR_IO_PENDING, rv); | 4282 EXPECT_EQ(ERR_IO_PENDING, rv); |
4283 | 4283 |
4284 HostPortPair http_host_port_pair; | 4284 HostPortPair http_host_port_pair; |
4285 http_host_port_pair.host = "www.google.com"; | 4285 http_host_port_pair.host = "www.google.com"; |
4286 http_host_port_pair.port = 80; | 4286 http_host_port_pair.port = 80; |
4287 const HttpAlternateProtocols& alternate_protocols = | 4287 const HttpAlternateProtocols& alternate_protocols = |
4288 session->alternate_protocols(); | 4288 session->alternate_protocols(); |
4289 EXPECT_FALSE( | 4289 EXPECT_FALSE( |
4290 alternate_protocols.HasAlternateProtocolFor(http_host_port_pair)); | 4290 alternate_protocols.HasAlternateProtocolFor(http_host_port_pair)); |
4291 | 4291 |
4292 EXPECT_EQ(OK, callback.WaitForResult()); | 4292 EXPECT_EQ(OK, callback.WaitForResult()); |
4293 | 4293 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4373 EXPECT_EQ(HttpAlternateProtocols::BROKEN, alternate.protocol); | 4373 EXPECT_EQ(HttpAlternateProtocols::BROKEN, alternate.protocol); |
4374 } | 4374 } |
4375 | 4375 |
4376 // TODO(willchan): Redo this test to use TLS/NPN=>SPDY. Currently, the code | 4376 // TODO(willchan): Redo this test to use TLS/NPN=>SPDY. Currently, the code |
4377 // says that it does SPDY, but it just does the TLS handshake, but the NPN | 4377 // says that it does SPDY, but it just does the TLS handshake, but the NPN |
4378 // response does not indicate SPDY, so we just do standard HTTPS over the port. | 4378 // response does not indicate SPDY, so we just do standard HTTPS over the port. |
4379 // We should add code such that we don't fallback to HTTPS, but fallback to HTTP | 4379 // We should add code such that we don't fallback to HTTPS, but fallback to HTTP |
4380 // on the original port. | 4380 // on the original port. |
4381 // TEST_F(HttpNetworkTransactionTest, UseAlternateProtocol) { | 4381 // TEST_F(HttpNetworkTransactionTest, UseAlternateProtocol) { |
4382 // SessionDependencies session_deps; | 4382 // SessionDependencies session_deps; |
4383 // | 4383 // |
4384 // HttpRequestInfo request; | 4384 // HttpRequestInfo request; |
4385 // request.method = "GET"; | 4385 // request.method = "GET"; |
4386 // request.url = GURL("http://www.google.com/"); | 4386 // request.url = GURL("http://www.google.com/"); |
4387 // request.load_flags = 0; | 4387 // request.load_flags = 0; |
4388 // | 4388 // |
4389 // MockRead data_reads[] = { | 4389 // MockRead data_reads[] = { |
4390 // MockRead("HTTP/1.1 200 OK\r\n\r\n"), | 4390 // MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
4391 // MockRead("hello world"), | 4391 // MockRead("hello world"), |
4392 // MockRead(true, OK), | 4392 // MockRead(true, OK), |
4393 // }; | 4393 // }; |
4394 // StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 4394 // StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
4395 // session_deps.socket_factory.AddSocketDataProvider(&data); | 4395 // session_deps.socket_factory.AddSocketDataProvider(&data); |
4396 // | 4396 // |
4397 // SSLSocketDataProvider ssl(true, OK); | 4397 // SSLSocketDataProvider ssl(true, OK); |
4398 // session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 4398 // session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
4399 // | 4399 // |
4400 // TestCompletionCallback callback; | 4400 // TestCompletionCallback callback; |
4401 // | 4401 // |
4402 // scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 4402 // scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
4403 // | 4403 // |
4404 // HostPortPair http_host_port_pair; | 4404 // HostPortPair http_host_port_pair; |
4405 // http_host_port_pair.host = "www.google.com"; | 4405 // http_host_port_pair.host = "www.google.com"; |
4406 // http_host_port_pair.port = 80; | 4406 // http_host_port_pair.port = 80; |
4407 // HttpAlternateProtocols* alternate_protocols = | 4407 // HttpAlternateProtocols* alternate_protocols = |
4408 // session->mutable_alternate_protocols(); | 4408 // session->mutable_alternate_protocols(); |
4409 // alternate_protocols->SetAlternateProtocolFor( | 4409 // alternate_protocols->SetAlternateProtocolFor( |
4410 // http_host_port_pair, 1234 /* port is ignored */, | 4410 // http_host_port_pair, 1234 /* port is ignored */, |
4411 // HttpAlternateProtocols::NPN_SPDY); | 4411 // HttpAlternateProtocols::NPN_SPDY); |
4412 // | 4412 // |
4413 // scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 4413 // scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
4414 // | 4414 // |
4415 // int rv = trans->Start(&request, &callback, NULL); | 4415 // int rv = trans->Start(&request, &callback, NULL); |
4416 // EXPECT_EQ(ERR_IO_PENDING, rv); | 4416 // EXPECT_EQ(ERR_IO_PENDING, rv); |
4417 // EXPECT_EQ(OK, callback.WaitForResult()); | 4417 // EXPECT_EQ(OK, callback.WaitForResult()); |
4418 // | 4418 // |
4419 // const HttpResponseInfo* response = trans->GetResponseInfo(); | 4419 // const HttpResponseInfo* response = trans->GetResponseInfo(); |
4420 // ASSERT_TRUE(response != NULL); | 4420 // ASSERT_TRUE(response != NULL); |
4421 // ASSERT_TRUE(response->headers != NULL); | 4421 // ASSERT_TRUE(response->headers != NULL); |
4422 // EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4422 // EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4423 // | 4423 // |
4424 // std::string response_data; | 4424 // std::string response_data; |
4425 // ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 4425 // ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
4426 // EXPECT_EQ("hello world", response_data); | 4426 // EXPECT_EQ("hello world", response_data); |
4427 // } | 4427 // } |
4428 | 4428 |
4429 TEST_F(HttpNetworkTransactionTest, FailNpnSpdyAndFallback) { | 4429 TEST_F(HttpNetworkTransactionTest, FailNpnSpdyAndFallback) { |
4430 SessionDependencies session_deps; | 4430 SessionDependencies session_deps; |
4431 | 4431 |
4432 HttpRequestInfo request; | 4432 HttpRequestInfo request; |
4433 request.method = "GET"; | 4433 request.method = "GET"; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4472 ASSERT_TRUE(response != NULL); | 4472 ASSERT_TRUE(response != NULL); |
4473 ASSERT_TRUE(response->headers != NULL); | 4473 ASSERT_TRUE(response->headers != NULL); |
4474 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4474 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4475 | 4475 |
4476 std::string response_data; | 4476 std::string response_data; |
4477 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 4477 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
4478 EXPECT_EQ("hello world", response_data); | 4478 EXPECT_EQ("hello world", response_data); |
4479 } | 4479 } |
4480 | 4480 |
4481 } // namespace net | 4481 } // namespace net |
OLD | NEW |