| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
| 8 #include <stdarg.h> | 8 #include <stdarg.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 new HttpNetworkTransaction(DEFAULT_PRIORITY, | 302 new HttpNetworkTransaction(DEFAULT_PRIORITY, |
| 303 CreateSession(&session_deps_))); | 303 CreateSession(&session_deps_))); |
| 304 | 304 |
| 305 for (size_t i = 0; i < data_count; ++i) { | 305 for (size_t i = 0; i < data_count; ++i) { |
| 306 session_deps_.socket_factory->AddSocketDataProvider(data[i]); | 306 session_deps_.socket_factory->AddSocketDataProvider(data[i]); |
| 307 } | 307 } |
| 308 | 308 |
| 309 TestCompletionCallback callback; | 309 TestCompletionCallback callback; |
| 310 | 310 |
| 311 EXPECT_TRUE(log.bound().IsLoggingAllEvents()); | 311 EXPECT_TRUE(log.bound().IsLoggingAllEvents()); |
| 312 int rv = trans->Start(&request, callback.callback(), log.bound()); | 312 out.rv = trans->Start(&request, callback.callback(), log.bound()); |
| 313 EXPECT_EQ(ERR_IO_PENDING, rv); | 313 EXPECT_EQ(ERR_IO_PENDING, out.rv); |
| 314 | 314 if (out.rv == net::ERR_IO_PENDING) |
| 315 out.rv = callback.WaitForResult(); | 315 out.rv = callback.WaitForResult(); |
| 316 | 316 |
| 317 // Even in the failure cases that use this function, connections are always | 317 // Even in the failure cases that use this function, connections are always |
| 318 // successfully established before the error. | 318 // successfully established before the error. |
| 319 EXPECT_TRUE(trans->GetLoadTimingInfo(&out.load_timing_info)); | 319 EXPECT_TRUE(trans->GetLoadTimingInfo(&out.load_timing_info)); |
| 320 TestLoadTimingNotReused(out.load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); | 320 TestLoadTimingNotReused(out.load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES); |
| 321 | 321 |
| 322 if (out.rv != OK) | 322 if (out.rv != OK) |
| 323 return out; | 323 return out; |
| 324 | 324 |
| 325 const HttpResponseInfo* response = trans->GetResponseInfo(); | 325 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 326 // Can't use ASSERT_* inside helper functions like this, so | 326 // Can't use ASSERT_* inside helper functions like this, so |
| 327 // return an error. | 327 // return an error. |
| 328 if (response == NULL || response->headers.get() == NULL) { | 328 if (response == NULL || response->headers.get() == NULL) { |
| 329 out.rv = ERR_UNEXPECTED; | 329 out.rv = ERR_UNEXPECTED; |
| 330 return out; | 330 return out; |
| 331 } | 331 } |
| 332 out.status_line = response->headers->GetStatusLine(); | 332 out.status_line = response->headers->GetStatusLine(); |
| 333 | 333 |
| 334 EXPECT_EQ("127.0.0.1", response->socket_address.host()); | 334 EXPECT_EQ("127.0.0.1", response->socket_address.host()); |
| 335 EXPECT_EQ(80, response->socket_address.port()); | 335 EXPECT_EQ(80, response->socket_address.port()); |
| 336 | 336 |
| 337 rv = ReadTransaction(trans.get(), &out.response_data); | 337 int rv = ReadTransaction(trans.get(), &out.response_data); |
| 338 EXPECT_EQ(OK, rv); | 338 EXPECT_EQ(OK, rv); |
| 339 | 339 |
| 340 net::CapturingNetLog::CapturedEntryList entries; | 340 net::CapturingNetLog::CapturedEntryList entries; |
| 341 log.GetEntries(&entries); | 341 log.GetEntries(&entries); |
| 342 size_t pos = ExpectLogContainsSomewhere( | 342 size_t pos = ExpectLogContainsSomewhere( |
| 343 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, | 343 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, |
| 344 NetLog::PHASE_NONE); | 344 NetLog::PHASE_NONE); |
| 345 ExpectLogContainsSomewhere( | 345 ExpectLogContainsSomewhere( |
| 346 entries, pos, | 346 entries, pos, |
| 347 NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS, | 347 NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS, |
| (...skipping 11044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11392 EXPECT_EQ("hello!", response_data); | 11392 EXPECT_EQ("hello!", response_data); |
| 11393 EXPECT_FALSE( | 11393 EXPECT_FALSE( |
| 11394 session->spdy_session_pool()->HasSession(spdy_session_key_a)); | 11394 session->spdy_session_pool()->HasSession(spdy_session_key_a)); |
| 11395 EXPECT_FALSE( | 11395 EXPECT_FALSE( |
| 11396 session->spdy_session_pool()->HasSession(spdy_session_key_b)); | 11396 session->spdy_session_pool()->HasSession(spdy_session_key_b)); |
| 11397 | 11397 |
| 11398 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); | 11398 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
| 11399 } | 11399 } |
| 11400 | 11400 |
| 11401 } // namespace net | 11401 } // namespace net |
| OLD | NEW |