| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base/cert_verifier.h" | 5 #include "net/base/cert_verifier.h" |
| 6 #include "net/base/mock_host_resolver.h" | 6 #include "net/base/mock_host_resolver.h" |
| 7 #include "net/base/net_log.h" | 7 #include "net/base/net_log.h" |
| 8 #include "net/base/ssl_config_service_defaults.h" | 8 #include "net/base/ssl_config_service_defaults.h" |
| 9 #include "net/http/http_network_layer.h" | 9 #include "net/http/http_network_layer.h" |
| 10 #include "net/http/http_network_session.h" | 10 #include "net/http/http_network_session.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 MockWrite data_writes[] = { | 82 MockWrite data_writes[] = { |
| 83 MockWrite("GET / HTTP/1.1\r\n" | 83 MockWrite("GET / HTTP/1.1\r\n" |
| 84 "Host: www.google.com\r\n" | 84 "Host: www.google.com\r\n" |
| 85 "Connection: keep-alive\r\n" | 85 "Connection: keep-alive\r\n" |
| 86 "User-Agent: Foo/1.0\r\n\r\n"), | 86 "User-Agent: Foo/1.0\r\n\r\n"), |
| 87 }; | 87 }; |
| 88 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 88 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 89 data_writes, arraysize(data_writes)); | 89 data_writes, arraysize(data_writes)); |
| 90 mock_socket_factory_.AddSocketDataProvider(&data); | 90 mock_socket_factory_.AddSocketDataProvider(&data); |
| 91 | 91 |
| 92 TestOldCompletionCallback callback; | 92 TestCompletionCallback callback; |
| 93 | 93 |
| 94 HttpRequestInfo request_info; | 94 HttpRequestInfo request_info; |
| 95 request_info.url = GURL("http://www.google.com/"); | 95 request_info.url = GURL("http://www.google.com/"); |
| 96 request_info.method = "GET"; | 96 request_info.method = "GET"; |
| 97 request_info.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, | 97 request_info.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, |
| 98 "Foo/1.0"); | 98 "Foo/1.0"); |
| 99 request_info.load_flags = LOAD_NORMAL; | 99 request_info.load_flags = LOAD_NORMAL; |
| 100 | 100 |
| 101 scoped_ptr<HttpTransaction> trans; | 101 scoped_ptr<HttpTransaction> trans; |
| 102 int rv = factory_->CreateTransaction(&trans); | 102 int rv = factory_->CreateTransaction(&trans); |
| 103 EXPECT_EQ(OK, rv); | 103 EXPECT_EQ(OK, rv); |
| 104 | 104 |
| 105 rv = trans->Start(&request_info, &callback, BoundNetLog()); | 105 rv = trans->Start(&request_info, callback.callback(), BoundNetLog()); |
| 106 if (rv == ERR_IO_PENDING) | 106 if (rv == ERR_IO_PENDING) |
| 107 rv = callback.WaitForResult(); | 107 rv = callback.WaitForResult(); |
| 108 ASSERT_EQ(OK, rv); | 108 ASSERT_EQ(OK, rv); |
| 109 | 109 |
| 110 std::string contents; | 110 std::string contents; |
| 111 rv = ReadTransaction(trans.get(), &contents); | 111 rv = ReadTransaction(trans.get(), &contents); |
| 112 EXPECT_EQ(OK, rv); | 112 EXPECT_EQ(OK, rv); |
| 113 EXPECT_EQ("hello world", contents); | 113 EXPECT_EQ("hello world", contents); |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace | 116 } // namespace |
| 117 | 117 |
| 118 } // namespace net | 118 } // namespace net |
| OLD | NEW |