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 "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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 return out; | 166 return out; |
167 | 167 |
168 const HttpResponseInfo* response = trans->GetResponseInfo(); | 168 const HttpResponseInfo* response = trans->GetResponseInfo(); |
169 EXPECT_TRUE(response != NULL); | 169 EXPECT_TRUE(response != NULL); |
170 | 170 |
171 EXPECT_TRUE(response->headers != NULL); | 171 EXPECT_TRUE(response->headers != NULL); |
172 out.status_line = response->headers->GetStatusLine(); | 172 out.status_line = response->headers->GetStatusLine(); |
173 | 173 |
174 rv = ReadTransaction(trans.get(), &out.response_data); | 174 rv = ReadTransaction(trans.get(), &out.response_data); |
175 EXPECT_EQ(OK, rv); | 175 EXPECT_EQ(OK, rv); |
| 176 |
| 177 net::CapturingNetLog::EntryList entries; |
| 178 log.GetEntries(&entries); |
176 size_t pos = ExpectLogContainsSomewhere( | 179 size_t pos = ExpectLogContainsSomewhere( |
177 log.entries(), 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, | 180 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, |
178 NetLog::PHASE_NONE); | 181 NetLog::PHASE_NONE); |
179 ExpectLogContainsSomewhere( | 182 ExpectLogContainsSomewhere( |
180 log.entries(), pos, | 183 entries, pos, |
181 NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS, | 184 NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS, |
182 NetLog::PHASE_NONE); | 185 NetLog::PHASE_NONE); |
183 | 186 |
184 CapturingNetLog::Entry entry = log.entries()[pos]; | 187 CapturingNetLog::Entry entry = entries[pos]; |
185 NetLogHttpRequestParameter* request_params = | 188 NetLogHttpRequestParameter* request_params = |
186 static_cast<NetLogHttpRequestParameter*>(entry.extra_parameters.get()); | 189 static_cast<NetLogHttpRequestParameter*>(entry.extra_parameters.get()); |
187 EXPECT_EQ("GET / HTTP/1.1\r\n", request_params->GetLine()); | 190 EXPECT_EQ("GET / HTTP/1.1\r\n", request_params->GetLine()); |
188 EXPECT_EQ("Host: www.google.com\r\n" | 191 EXPECT_EQ("Host: www.google.com\r\n" |
189 "Connection: keep-alive\r\n\r\n", | 192 "Connection: keep-alive\r\n\r\n", |
190 request_params->GetHeaders().ToString()); | 193 request_params->GetHeaders().ToString()); |
191 | 194 |
192 return out; | 195 return out; |
193 } | 196 } |
194 | 197 |
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 | 1520 |
1518 TestCompletionCallback callback1; | 1521 TestCompletionCallback callback1; |
1519 | 1522 |
1520 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1523 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
1521 | 1524 |
1522 int rv = trans->Start(&request, &callback1, log.bound()); | 1525 int rv = trans->Start(&request, &callback1, log.bound()); |
1523 EXPECT_EQ(ERR_IO_PENDING, rv); | 1526 EXPECT_EQ(ERR_IO_PENDING, rv); |
1524 | 1527 |
1525 rv = callback1.WaitForResult(); | 1528 rv = callback1.WaitForResult(); |
1526 EXPECT_EQ(OK, rv); | 1529 EXPECT_EQ(OK, rv); |
| 1530 net::CapturingNetLog::EntryList entries; |
| 1531 log.GetEntries(&entries); |
1527 size_t pos = ExpectLogContainsSomewhere( | 1532 size_t pos = ExpectLogContainsSomewhere( |
1528 log.entries(), 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 1533 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
1529 NetLog::PHASE_NONE); | 1534 NetLog::PHASE_NONE); |
1530 ExpectLogContainsSomewhere( | 1535 ExpectLogContainsSomewhere( |
1531 log.entries(), pos, | 1536 entries, pos, |
1532 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 1537 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
1533 NetLog::PHASE_NONE); | 1538 NetLog::PHASE_NONE); |
1534 | 1539 |
1535 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1540 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1536 ASSERT_FALSE(response == NULL); | 1541 ASSERT_FALSE(response == NULL); |
1537 | 1542 |
1538 EXPECT_EQ(407, response->headers->response_code()); | 1543 EXPECT_EQ(407, response->headers->response_code()); |
1539 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 1544 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
1540 | 1545 |
1541 // The password prompt info should have been set in response->auth_challenge. | 1546 // The password prompt info should have been set in response->auth_challenge. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 data_writes1, arraysize(data_writes1)); | 1626 data_writes1, arraysize(data_writes1)); |
1622 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1627 session_deps.socket_factory.AddSocketDataProvider(&data1); |
1623 | 1628 |
1624 TestCompletionCallback callback1; | 1629 TestCompletionCallback callback1; |
1625 | 1630 |
1626 int rv = trans->Start(&request, &callback1, log.bound()); | 1631 int rv = trans->Start(&request, &callback1, log.bound()); |
1627 EXPECT_EQ(ERR_IO_PENDING, rv); | 1632 EXPECT_EQ(ERR_IO_PENDING, rv); |
1628 | 1633 |
1629 rv = callback1.WaitForResult(); | 1634 rv = callback1.WaitForResult(); |
1630 EXPECT_EQ(OK, rv); | 1635 EXPECT_EQ(OK, rv); |
| 1636 net::CapturingNetLog::EntryList entries; |
| 1637 log.GetEntries(&entries); |
1631 size_t pos = ExpectLogContainsSomewhere( | 1638 size_t pos = ExpectLogContainsSomewhere( |
1632 log.entries(), 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 1639 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
1633 NetLog::PHASE_NONE); | 1640 NetLog::PHASE_NONE); |
1634 ExpectLogContainsSomewhere( | 1641 ExpectLogContainsSomewhere( |
1635 log.entries(), pos, | 1642 entries, pos, |
1636 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 1643 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
1637 NetLog::PHASE_NONE); | 1644 NetLog::PHASE_NONE); |
1638 | 1645 |
1639 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1646 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1640 EXPECT_FALSE(response == NULL); | 1647 EXPECT_FALSE(response == NULL); |
1641 | 1648 |
1642 EXPECT_TRUE(response->headers->IsKeepAlive()); | 1649 EXPECT_TRUE(response->headers->IsKeepAlive()); |
1643 EXPECT_EQ(407, response->headers->response_code()); | 1650 EXPECT_EQ(407, response->headers->response_code()); |
1644 EXPECT_EQ(10, response->headers->GetContentLength()); | 1651 EXPECT_EQ(10, response->headers->GetContentLength()); |
1645 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 1652 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1823 | 1830 |
1824 TestCompletionCallback callback1; | 1831 TestCompletionCallback callback1; |
1825 | 1832 |
1826 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1833 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
1827 | 1834 |
1828 int rv = trans->Start(&request, &callback1, log.bound()); | 1835 int rv = trans->Start(&request, &callback1, log.bound()); |
1829 EXPECT_EQ(ERR_IO_PENDING, rv); | 1836 EXPECT_EQ(ERR_IO_PENDING, rv); |
1830 | 1837 |
1831 rv = callback1.WaitForResult(); | 1838 rv = callback1.WaitForResult(); |
1832 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); | 1839 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); |
| 1840 net::CapturingNetLog::EntryList entries; |
| 1841 log.GetEntries(&entries); |
1833 size_t pos = ExpectLogContainsSomewhere( | 1842 size_t pos = ExpectLogContainsSomewhere( |
1834 log.entries(), 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 1843 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
1835 NetLog::PHASE_NONE); | 1844 NetLog::PHASE_NONE); |
1836 ExpectLogContainsSomewhere( | 1845 ExpectLogContainsSomewhere( |
1837 log.entries(), pos, | 1846 entries, pos, |
1838 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 1847 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
1839 NetLog::PHASE_NONE); | 1848 NetLog::PHASE_NONE); |
1840 } | 1849 } |
1841 | 1850 |
1842 // Test a simple get through an HTTPS Proxy. | 1851 // Test a simple get through an HTTPS Proxy. |
1843 TEST_F(HttpNetworkTransactionTest, HttpsProxyGet) { | 1852 TEST_F(HttpNetworkTransactionTest, HttpsProxyGet) { |
1844 // Configure against https proxy server "proxy:70". | 1853 // Configure against https proxy server "proxy:70". |
1845 SessionDependencies session_deps(ProxyService::CreateFixed("https://proxy:70")
); | 1854 SessionDependencies session_deps(ProxyService::CreateFixed("https://proxy:70")
); |
1846 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 1855 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
1847 session_deps.net_log = log.bound().net_log(); | 1856 session_deps.net_log = log.bound().net_log(); |
(...skipping 5868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7716 | 7725 |
7717 TestCompletionCallback callback1; | 7726 TestCompletionCallback callback1; |
7718 | 7727 |
7719 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 7728 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
7720 | 7729 |
7721 int rv = trans->Start(&request, &callback1, log.bound()); | 7730 int rv = trans->Start(&request, &callback1, log.bound()); |
7722 EXPECT_EQ(ERR_IO_PENDING, rv); | 7731 EXPECT_EQ(ERR_IO_PENDING, rv); |
7723 | 7732 |
7724 rv = callback1.WaitForResult(); | 7733 rv = callback1.WaitForResult(); |
7725 EXPECT_EQ(OK, rv); | 7734 EXPECT_EQ(OK, rv); |
| 7735 net::CapturingNetLog::EntryList entries; |
| 7736 log.GetEntries(&entries); |
7726 size_t pos = ExpectLogContainsSomewhere( | 7737 size_t pos = ExpectLogContainsSomewhere( |
7727 log.entries(), 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 7738 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
7728 NetLog::PHASE_NONE); | 7739 NetLog::PHASE_NONE); |
7729 ExpectLogContainsSomewhere( | 7740 ExpectLogContainsSomewhere( |
7730 log.entries(), pos, | 7741 entries, pos, |
7731 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 7742 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
7732 NetLog::PHASE_NONE); | 7743 NetLog::PHASE_NONE); |
7733 | 7744 |
7734 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7745 const HttpResponseInfo* response = trans->GetResponseInfo(); |
7735 ASSERT_FALSE(response == NULL); | 7746 ASSERT_FALSE(response == NULL); |
7736 | 7747 |
7737 EXPECT_TRUE(response->headers->IsKeepAlive()); | 7748 EXPECT_TRUE(response->headers->IsKeepAlive()); |
7738 EXPECT_EQ(200, response->headers->response_code()); | 7749 EXPECT_EQ(200, response->headers->response_code()); |
7739 EXPECT_EQ(100, response->headers->GetContentLength()); | 7750 EXPECT_EQ(100, response->headers->GetContentLength()); |
7740 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 7751 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7778 | 7789 |
7779 TestCompletionCallback callback1; | 7790 TestCompletionCallback callback1; |
7780 | 7791 |
7781 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 7792 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
7782 | 7793 |
7783 int rv = trans->Start(&request, &callback1, log.bound()); | 7794 int rv = trans->Start(&request, &callback1, log.bound()); |
7784 EXPECT_EQ(ERR_IO_PENDING, rv); | 7795 EXPECT_EQ(ERR_IO_PENDING, rv); |
7785 | 7796 |
7786 rv = callback1.WaitForResult(); | 7797 rv = callback1.WaitForResult(); |
7787 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); | 7798 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); |
| 7799 net::CapturingNetLog::EntryList entries; |
| 7800 log.GetEntries(&entries); |
7788 size_t pos = ExpectLogContainsSomewhere( | 7801 size_t pos = ExpectLogContainsSomewhere( |
7789 log.entries(), 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 7802 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
7790 NetLog::PHASE_NONE); | 7803 NetLog::PHASE_NONE); |
7791 ExpectLogContainsSomewhere( | 7804 ExpectLogContainsSomewhere( |
7792 log.entries(), pos, | 7805 entries, pos, |
7793 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 7806 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
7794 NetLog::PHASE_NONE); | 7807 NetLog::PHASE_NONE); |
7795 } | 7808 } |
7796 | 7809 |
7797 // Test for crbug.com/55424. | 7810 // Test for crbug.com/55424. |
7798 TEST_F(HttpNetworkTransactionTest, PreconnectWithExistingSpdySession) { | 7811 TEST_F(HttpNetworkTransactionTest, PreconnectWithExistingSpdySession) { |
7799 SessionDependencies session_deps; | 7812 SessionDependencies session_deps; |
7800 | 7813 |
7801 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet( | 7814 scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet( |
7802 "https://www.google.com", false, 1, LOWEST)); | 7815 "https://www.google.com", false, 1, LOWEST)); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7944 rv = callback.WaitForResult(); | 7957 rv = callback.WaitForResult(); |
7945 ASSERT_EQ(OK, rv); | 7958 ASSERT_EQ(OK, rv); |
7946 | 7959 |
7947 std::string contents; | 7960 std::string contents; |
7948 rv = ReadTransaction(trans.get(), &contents); | 7961 rv = ReadTransaction(trans.get(), &contents); |
7949 EXPECT_EQ(net::OK, rv); | 7962 EXPECT_EQ(net::OK, rv); |
7950 EXPECT_EQ("hello world", contents); | 7963 EXPECT_EQ("hello world", contents); |
7951 } | 7964 } |
7952 | 7965 |
7953 } // namespace net | 7966 } // namespace net |
OLD | NEW |