| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 SessionDependencies session_deps; | 228 SessionDependencies session_deps; |
| 229 scoped_ptr<HttpTransaction> trans( | 229 scoped_ptr<HttpTransaction> trans( |
| 230 new HttpNetworkTransaction(CreateSession(&session_deps))); | 230 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 231 | 231 |
| 232 for (size_t i = 0; i < data_count; ++i) { | 232 for (size_t i = 0; i < data_count; ++i) { |
| 233 session_deps.socket_factory.AddSocketDataProvider(data[i]); | 233 session_deps.socket_factory.AddSocketDataProvider(data[i]); |
| 234 } | 234 } |
| 235 | 235 |
| 236 TestCompletionCallback callback; | 236 TestCompletionCallback callback; |
| 237 | 237 |
| 238 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 238 CapturingBoundNetLog log; |
| 239 EXPECT_TRUE(log.bound().IsLoggingAllEvents()); | 239 EXPECT_TRUE(log.bound().IsLoggingAllEvents()); |
| 240 int rv = trans->Start(&request, callback.callback(), log.bound()); | 240 int rv = trans->Start(&request, callback.callback(), log.bound()); |
| 241 EXPECT_EQ(ERR_IO_PENDING, rv); | 241 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 242 | 242 |
| 243 out.rv = callback.WaitForResult(); | 243 out.rv = callback.WaitForResult(); |
| 244 if (out.rv != OK) | 244 if (out.rv != OK) |
| 245 return out; | 245 return out; |
| 246 | 246 |
| 247 const HttpResponseInfo* response = trans->GetResponseInfo(); | 247 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 248 // Can't use ASSERT_* inside helper functions like this, so | 248 // Can't use ASSERT_* inside helper functions like this, so |
| 249 // return an error. | 249 // return an error. |
| 250 if (response == NULL || response->headers == NULL) { | 250 if (response == NULL || response->headers == NULL) { |
| 251 out.rv = ERR_UNEXPECTED; | 251 out.rv = ERR_UNEXPECTED; |
| 252 return out; | 252 return out; |
| 253 } | 253 } |
| 254 out.status_line = response->headers->GetStatusLine(); | 254 out.status_line = response->headers->GetStatusLine(); |
| 255 | 255 |
| 256 EXPECT_EQ("192.0.2.33", response->socket_address.host()); | 256 EXPECT_EQ("192.0.2.33", response->socket_address.host()); |
| 257 EXPECT_EQ(0, response->socket_address.port()); | 257 EXPECT_EQ(0, response->socket_address.port()); |
| 258 | 258 |
| 259 rv = ReadTransaction(trans.get(), &out.response_data); | 259 rv = ReadTransaction(trans.get(), &out.response_data); |
| 260 EXPECT_EQ(OK, rv); | 260 EXPECT_EQ(OK, rv); |
| 261 | 261 |
| 262 net::CapturingNetLog::CapturedEntryList entries; | 262 CapturingNetLog::CapturedEntryList entries; |
| 263 log.GetEntries(&entries); | 263 log.GetEntries(&entries); |
| 264 size_t pos = ExpectLogContainsSomewhere( | 264 size_t pos = ExpectLogContainsSomewhere( |
| 265 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, | 265 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, |
| 266 NetLog::PHASE_NONE); | 266 NetLog::PHASE_NONE); |
| 267 ExpectLogContainsSomewhere( | 267 ExpectLogContainsSomewhere( |
| 268 entries, pos, | 268 entries, pos, |
| 269 NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS, | 269 NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS, |
| 270 NetLog::PHASE_NONE); | 270 NetLog::PHASE_NONE); |
| 271 | 271 |
| 272 std::string line; | 272 std::string line; |
| (...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1734 // that requires a restart when setting up an SSL tunnel. | 1734 // that requires a restart when setting up an SSL tunnel. |
| 1735 TEST_F(HttpNetworkTransactionSpdy3Test, BasicAuthProxyNoKeepAlive) { | 1735 TEST_F(HttpNetworkTransactionSpdy3Test, BasicAuthProxyNoKeepAlive) { |
| 1736 HttpRequestInfo request; | 1736 HttpRequestInfo request; |
| 1737 request.method = "GET"; | 1737 request.method = "GET"; |
| 1738 request.url = GURL("https://www.google.com/"); | 1738 request.url = GURL("https://www.google.com/"); |
| 1739 // when the no authentication data flag is set. | 1739 // when the no authentication data flag is set. |
| 1740 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 1740 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
| 1741 | 1741 |
| 1742 // Configure against proxy server "myproxy:70". | 1742 // Configure against proxy server "myproxy:70". |
| 1743 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 1743 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 1744 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 1744 CapturingBoundNetLog log; |
| 1745 session_deps.net_log = log.bound().net_log(); | 1745 session_deps.net_log = log.bound().net_log(); |
| 1746 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1746 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 1747 | 1747 |
| 1748 // Since we have proxy, should try to establish tunnel. | 1748 // Since we have proxy, should try to establish tunnel. |
| 1749 MockWrite data_writes1[] = { | 1749 MockWrite data_writes1[] = { |
| 1750 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 1750 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 1751 "Host: www.google.com\r\n" | 1751 "Host: www.google.com\r\n" |
| 1752 "Proxy-Connection: keep-alive\r\n\r\n"), | 1752 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 1753 | 1753 |
| 1754 // After calling trans->RestartWithAuth(), this is the request we should | 1754 // After calling trans->RestartWithAuth(), this is the request we should |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1787 | 1787 |
| 1788 TestCompletionCallback callback1; | 1788 TestCompletionCallback callback1; |
| 1789 | 1789 |
| 1790 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1790 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1791 | 1791 |
| 1792 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 1792 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 1793 EXPECT_EQ(ERR_IO_PENDING, rv); | 1793 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1794 | 1794 |
| 1795 rv = callback1.WaitForResult(); | 1795 rv = callback1.WaitForResult(); |
| 1796 EXPECT_EQ(OK, rv); | 1796 EXPECT_EQ(OK, rv); |
| 1797 net::CapturingNetLog::CapturedEntryList entries; | 1797 CapturingNetLog::CapturedEntryList entries; |
| 1798 log.GetEntries(&entries); | 1798 log.GetEntries(&entries); |
| 1799 size_t pos = ExpectLogContainsSomewhere( | 1799 size_t pos = ExpectLogContainsSomewhere( |
| 1800 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 1800 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 1801 NetLog::PHASE_NONE); | 1801 NetLog::PHASE_NONE); |
| 1802 ExpectLogContainsSomewhere( | 1802 ExpectLogContainsSomewhere( |
| 1803 entries, pos, | 1803 entries, pos, |
| 1804 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 1804 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 1805 NetLog::PHASE_NONE); | 1805 NetLog::PHASE_NONE); |
| 1806 | 1806 |
| 1807 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1807 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1840 TEST_F(HttpNetworkTransactionSpdy3Test, BasicAuthProxyKeepAlive) { | 1840 TEST_F(HttpNetworkTransactionSpdy3Test, BasicAuthProxyKeepAlive) { |
| 1841 HttpRequestInfo request; | 1841 HttpRequestInfo request; |
| 1842 request.method = "GET"; | 1842 request.method = "GET"; |
| 1843 request.url = GURL("https://www.google.com/"); | 1843 request.url = GURL("https://www.google.com/"); |
| 1844 // Ensure that proxy authentication is attempted even | 1844 // Ensure that proxy authentication is attempted even |
| 1845 // when the no authentication data flag is set. | 1845 // when the no authentication data flag is set. |
| 1846 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 1846 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
| 1847 | 1847 |
| 1848 // Configure against proxy server "myproxy:70". | 1848 // Configure against proxy server "myproxy:70". |
| 1849 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 1849 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 1850 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 1850 CapturingBoundNetLog log; |
| 1851 session_deps.net_log = log.bound().net_log(); | 1851 session_deps.net_log = log.bound().net_log(); |
| 1852 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1852 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 1853 | 1853 |
| 1854 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1854 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1855 | 1855 |
| 1856 // Since we have proxy, should try to establish tunnel. | 1856 // Since we have proxy, should try to establish tunnel. |
| 1857 MockWrite data_writes1[] = { | 1857 MockWrite data_writes1[] = { |
| 1858 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 1858 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 1859 "Host: www.google.com\r\n" | 1859 "Host: www.google.com\r\n" |
| 1860 "Proxy-Connection: keep-alive\r\n\r\n"), | 1860 "Proxy-Connection: keep-alive\r\n\r\n"), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1888 data_writes1, arraysize(data_writes1)); | 1888 data_writes1, arraysize(data_writes1)); |
| 1889 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1889 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 1890 | 1890 |
| 1891 TestCompletionCallback callback1; | 1891 TestCompletionCallback callback1; |
| 1892 | 1892 |
| 1893 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 1893 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 1894 EXPECT_EQ(ERR_IO_PENDING, rv); | 1894 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1895 | 1895 |
| 1896 rv = callback1.WaitForResult(); | 1896 rv = callback1.WaitForResult(); |
| 1897 EXPECT_EQ(OK, rv); | 1897 EXPECT_EQ(OK, rv); |
| 1898 net::CapturingNetLog::CapturedEntryList entries; | 1898 CapturingNetLog::CapturedEntryList entries; |
| 1899 log.GetEntries(&entries); | 1899 log.GetEntries(&entries); |
| 1900 size_t pos = ExpectLogContainsSomewhere( | 1900 size_t pos = ExpectLogContainsSomewhere( |
| 1901 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 1901 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 1902 NetLog::PHASE_NONE); | 1902 NetLog::PHASE_NONE); |
| 1903 ExpectLogContainsSomewhere( | 1903 ExpectLogContainsSomewhere( |
| 1904 entries, pos, | 1904 entries, pos, |
| 1905 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 1905 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 1906 NetLog::PHASE_NONE); | 1906 NetLog::PHASE_NONE); |
| 1907 | 1907 |
| 1908 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1908 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2043 // a non-authenticating proxy - there is nothing to indicate whether the | 2043 // a non-authenticating proxy - there is nothing to indicate whether the |
| 2044 // response came from the proxy or the server, so it is treated as if the proxy | 2044 // response came from the proxy or the server, so it is treated as if the proxy |
| 2045 // issued the challenge. | 2045 // issued the challenge. |
| 2046 TEST_F(HttpNetworkTransactionSpdy3Test, | 2046 TEST_F(HttpNetworkTransactionSpdy3Test, |
| 2047 HttpsServerRequestsProxyAuthThroughProxy) { | 2047 HttpsServerRequestsProxyAuthThroughProxy) { |
| 2048 HttpRequestInfo request; | 2048 HttpRequestInfo request; |
| 2049 request.method = "GET"; | 2049 request.method = "GET"; |
| 2050 request.url = GURL("https://www.google.com/"); | 2050 request.url = GURL("https://www.google.com/"); |
| 2051 | 2051 |
| 2052 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 2052 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 2053 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2053 CapturingBoundNetLog log; |
| 2054 session_deps.net_log = log.bound().net_log(); | 2054 session_deps.net_log = log.bound().net_log(); |
| 2055 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2055 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2056 | 2056 |
| 2057 // Since we have proxy, should try to establish tunnel. | 2057 // Since we have proxy, should try to establish tunnel. |
| 2058 MockWrite data_writes1[] = { | 2058 MockWrite data_writes1[] = { |
| 2059 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 2059 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 2060 "Host: www.google.com\r\n" | 2060 "Host: www.google.com\r\n" |
| 2061 "Proxy-Connection: keep-alive\r\n\r\n"), | 2061 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 2062 | 2062 |
| 2063 MockWrite("GET / HTTP/1.1\r\n" | 2063 MockWrite("GET / HTTP/1.1\r\n" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2082 | 2082 |
| 2083 TestCompletionCallback callback1; | 2083 TestCompletionCallback callback1; |
| 2084 | 2084 |
| 2085 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2085 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2086 | 2086 |
| 2087 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2087 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2088 EXPECT_EQ(ERR_IO_PENDING, rv); | 2088 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2089 | 2089 |
| 2090 rv = callback1.WaitForResult(); | 2090 rv = callback1.WaitForResult(); |
| 2091 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); | 2091 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); |
| 2092 net::CapturingNetLog::CapturedEntryList entries; | 2092 CapturingNetLog::CapturedEntryList entries; |
| 2093 log.GetEntries(&entries); | 2093 log.GetEntries(&entries); |
| 2094 size_t pos = ExpectLogContainsSomewhere( | 2094 size_t pos = ExpectLogContainsSomewhere( |
| 2095 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 2095 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 2096 NetLog::PHASE_NONE); | 2096 NetLog::PHASE_NONE); |
| 2097 ExpectLogContainsSomewhere( | 2097 ExpectLogContainsSomewhere( |
| 2098 entries, pos, | 2098 entries, pos, |
| 2099 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 2099 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 2100 NetLog::PHASE_NONE); | 2100 NetLog::PHASE_NONE); |
| 2101 } | 2101 } |
| 2102 | 2102 |
| 2103 // Test a simple get through an HTTPS Proxy. | 2103 // Test a simple get through an HTTPS Proxy. |
| 2104 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxyGet) { | 2104 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxyGet) { |
| 2105 HttpRequestInfo request; | 2105 HttpRequestInfo request; |
| 2106 request.method = "GET"; | 2106 request.method = "GET"; |
| 2107 request.url = GURL("http://www.google.com/"); | 2107 request.url = GURL("http://www.google.com/"); |
| 2108 | 2108 |
| 2109 // Configure against https proxy server "proxy:70". | 2109 // Configure against https proxy server "proxy:70". |
| 2110 SessionDependencies session_deps(ProxyService::CreateFixed( | 2110 SessionDependencies session_deps(ProxyService::CreateFixed( |
| 2111 "https://proxy:70")); | 2111 "https://proxy:70")); |
| 2112 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2112 CapturingBoundNetLog log; |
| 2113 session_deps.net_log = log.bound().net_log(); | 2113 session_deps.net_log = log.bound().net_log(); |
| 2114 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2114 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2115 | 2115 |
| 2116 // Since we have proxy, should use full url | 2116 // Since we have proxy, should use full url |
| 2117 MockWrite data_writes1[] = { | 2117 MockWrite data_writes1[] = { |
| 2118 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" | 2118 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" |
| 2119 "Host: www.google.com\r\n" | 2119 "Host: www.google.com\r\n" |
| 2120 "Proxy-Connection: keep-alive\r\n\r\n"), | 2120 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 2121 }; | 2121 }; |
| 2122 | 2122 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2158 // Test a SPDY get through an HTTPS Proxy. | 2158 // Test a SPDY get through an HTTPS Proxy. |
| 2159 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyGet) { | 2159 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyGet) { |
| 2160 HttpRequestInfo request; | 2160 HttpRequestInfo request; |
| 2161 request.method = "GET"; | 2161 request.method = "GET"; |
| 2162 request.url = GURL("http://www.google.com/"); | 2162 request.url = GURL("http://www.google.com/"); |
| 2163 request.load_flags = 0; | 2163 request.load_flags = 0; |
| 2164 | 2164 |
| 2165 // Configure against https proxy server "proxy:70". | 2165 // Configure against https proxy server "proxy:70". |
| 2166 SessionDependencies session_deps(ProxyService::CreateFixed( | 2166 SessionDependencies session_deps(ProxyService::CreateFixed( |
| 2167 "https://proxy:70")); | 2167 "https://proxy:70")); |
| 2168 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2168 CapturingBoundNetLog log; |
| 2169 session_deps.net_log = log.bound().net_log(); | 2169 session_deps.net_log = log.bound().net_log(); |
| 2170 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2170 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2171 | 2171 |
| 2172 // fetch http://www.google.com/ via SPDY | 2172 // fetch http://www.google.com/ via SPDY |
| 2173 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST, | 2173 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST, |
| 2174 false)); | 2174 false)); |
| 2175 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 2175 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
| 2176 | 2176 |
| 2177 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 2177 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 2178 scoped_ptr<SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); | 2178 scoped_ptr<SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2216 // Test a SPDY get through an HTTPS Proxy. | 2216 // Test a SPDY get through an HTTPS Proxy. |
| 2217 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyGetWithProxyAuth) { | 2217 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyGetWithProxyAuth) { |
| 2218 HttpRequestInfo request; | 2218 HttpRequestInfo request; |
| 2219 request.method = "GET"; | 2219 request.method = "GET"; |
| 2220 request.url = GURL("http://www.google.com/"); | 2220 request.url = GURL("http://www.google.com/"); |
| 2221 request.load_flags = 0; | 2221 request.load_flags = 0; |
| 2222 | 2222 |
| 2223 // Configure against https proxy server "myproxy:70". | 2223 // Configure against https proxy server "myproxy:70". |
| 2224 SessionDependencies session_deps( | 2224 SessionDependencies session_deps( |
| 2225 ProxyService::CreateFixed("https://myproxy:70")); | 2225 ProxyService::CreateFixed("https://myproxy:70")); |
| 2226 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2226 CapturingBoundNetLog log; |
| 2227 session_deps.net_log = log.bound().net_log(); | 2227 session_deps.net_log = log.bound().net_log(); |
| 2228 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2228 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2229 | 2229 |
| 2230 // The first request will be a bare GET, the second request will be a | 2230 // The first request will be a bare GET, the second request will be a |
| 2231 // GET with a Proxy-Authorization header. | 2231 // GET with a Proxy-Authorization header. |
| 2232 scoped_ptr<SpdyFrame> req_get( | 2232 scoped_ptr<SpdyFrame> req_get( |
| 2233 ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); | 2233 ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); |
| 2234 const char* const kExtraAuthorizationHeaders[] = { | 2234 const char* const kExtraAuthorizationHeaders[] = { |
| 2235 "proxy-authorization", | 2235 "proxy-authorization", |
| 2236 "Basic Zm9vOmJhcg==", | 2236 "Basic Zm9vOmJhcg==", |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2316 // Test a SPDY CONNECT through an HTTPS Proxy to an HTTPS (non-SPDY) Server. | 2316 // Test a SPDY CONNECT through an HTTPS Proxy to an HTTPS (non-SPDY) Server. |
| 2317 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyConnectHttps) { | 2317 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyConnectHttps) { |
| 2318 HttpRequestInfo request; | 2318 HttpRequestInfo request; |
| 2319 request.method = "GET"; | 2319 request.method = "GET"; |
| 2320 request.url = GURL("https://www.google.com/"); | 2320 request.url = GURL("https://www.google.com/"); |
| 2321 request.load_flags = 0; | 2321 request.load_flags = 0; |
| 2322 | 2322 |
| 2323 // Configure against https proxy server "proxy:70". | 2323 // Configure against https proxy server "proxy:70". |
| 2324 SessionDependencies session_deps(ProxyService::CreateFixed( | 2324 SessionDependencies session_deps(ProxyService::CreateFixed( |
| 2325 "https://proxy:70")); | 2325 "https://proxy:70")); |
| 2326 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2326 CapturingBoundNetLog log; |
| 2327 session_deps.net_log = log.bound().net_log(); | 2327 session_deps.net_log = log.bound().net_log(); |
| 2328 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2328 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2329 | 2329 |
| 2330 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2330 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2331 | 2331 |
| 2332 // CONNECT to www.google.com:443 via SPDY | 2332 // CONNECT to www.google.com:443 via SPDY |
| 2333 scoped_ptr<SpdyFrame> connect(ConstructSpdyConnect(NULL, 0, 1)); | 2333 scoped_ptr<SpdyFrame> connect(ConstructSpdyConnect(NULL, 0, 1)); |
| 2334 // fetch https://www.google.com/ via HTTP | 2334 // fetch https://www.google.com/ via HTTP |
| 2335 | 2335 |
| 2336 const char get[] = "GET / HTTP/1.1\r\n" | 2336 const char get[] = "GET / HTTP/1.1\r\n" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2397 // Test a SPDY CONNECT through an HTTPS Proxy to a SPDY server. | 2397 // Test a SPDY CONNECT through an HTTPS Proxy to a SPDY server. |
| 2398 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyConnectSpdy) { | 2398 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyConnectSpdy) { |
| 2399 HttpRequestInfo request; | 2399 HttpRequestInfo request; |
| 2400 request.method = "GET"; | 2400 request.method = "GET"; |
| 2401 request.url = GURL("https://www.google.com/"); | 2401 request.url = GURL("https://www.google.com/"); |
| 2402 request.load_flags = 0; | 2402 request.load_flags = 0; |
| 2403 | 2403 |
| 2404 // Configure against https proxy server "proxy:70". | 2404 // Configure against https proxy server "proxy:70". |
| 2405 SessionDependencies session_deps(ProxyService::CreateFixed( | 2405 SessionDependencies session_deps(ProxyService::CreateFixed( |
| 2406 "https://proxy:70")); | 2406 "https://proxy:70")); |
| 2407 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2407 CapturingBoundNetLog log; |
| 2408 session_deps.net_log = log.bound().net_log(); | 2408 session_deps.net_log = log.bound().net_log(); |
| 2409 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2409 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2410 | 2410 |
| 2411 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2411 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2412 | 2412 |
| 2413 // CONNECT to www.google.com:443 via SPDY | 2413 // CONNECT to www.google.com:443 via SPDY |
| 2414 scoped_ptr<SpdyFrame> connect(ConstructSpdyConnect(NULL, 0, 1)); | 2414 scoped_ptr<SpdyFrame> connect(ConstructSpdyConnect(NULL, 0, 1)); |
| 2415 // fetch https://www.google.com/ via SPDY | 2415 // fetch https://www.google.com/ via SPDY |
| 2416 const char* const kMyUrl = "https://www.google.com/"; | 2416 const char* const kMyUrl = "https://www.google.com/"; |
| 2417 scoped_ptr<SpdyFrame> get(ConstructSpdyGet(kMyUrl, false, 1, LOWEST)); | 2417 scoped_ptr<SpdyFrame> get(ConstructSpdyGet(kMyUrl, false, 1, LOWEST)); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2476 // Test a SPDY CONNECT failure through an HTTPS Proxy. | 2476 // Test a SPDY CONNECT failure through an HTTPS Proxy. |
| 2477 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyConnectFailure) { | 2477 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxySpdyConnectFailure) { |
| 2478 HttpRequestInfo request; | 2478 HttpRequestInfo request; |
| 2479 request.method = "GET"; | 2479 request.method = "GET"; |
| 2480 request.url = GURL("https://www.google.com/"); | 2480 request.url = GURL("https://www.google.com/"); |
| 2481 request.load_flags = 0; | 2481 request.load_flags = 0; |
| 2482 | 2482 |
| 2483 // Configure against https proxy server "proxy:70". | 2483 // Configure against https proxy server "proxy:70". |
| 2484 SessionDependencies session_deps(ProxyService::CreateFixed( | 2484 SessionDependencies session_deps(ProxyService::CreateFixed( |
| 2485 "https://proxy:70")); | 2485 "https://proxy:70")); |
| 2486 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2486 CapturingBoundNetLog log; |
| 2487 session_deps.net_log = log.bound().net_log(); | 2487 session_deps.net_log = log.bound().net_log(); |
| 2488 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2488 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2489 | 2489 |
| 2490 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2490 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2491 | 2491 |
| 2492 // CONNECT to www.google.com:443 via SPDY | 2492 // CONNECT to www.google.com:443 via SPDY |
| 2493 scoped_ptr<SpdyFrame> connect(ConstructSpdyConnect(NULL, 0, 1)); | 2493 scoped_ptr<SpdyFrame> connect(ConstructSpdyConnect(NULL, 0, 1)); |
| 2494 scoped_ptr<SpdyFrame> get(ConstructSpdyRstStream(1, CANCEL)); | 2494 scoped_ptr<SpdyFrame> get(ConstructSpdyRstStream(1, CANCEL)); |
| 2495 | 2495 |
| 2496 MockWrite spdy_writes[] = { | 2496 MockWrite spdy_writes[] = { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2535 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxyAuthRetry) { | 2535 TEST_F(HttpNetworkTransactionSpdy3Test, HttpsProxyAuthRetry) { |
| 2536 HttpRequestInfo request; | 2536 HttpRequestInfo request; |
| 2537 request.method = "GET"; | 2537 request.method = "GET"; |
| 2538 request.url = GURL("http://www.google.com/"); | 2538 request.url = GURL("http://www.google.com/"); |
| 2539 // when the no authentication data flag is set. | 2539 // when the no authentication data flag is set. |
| 2540 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 2540 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
| 2541 | 2541 |
| 2542 // Configure against https proxy server "myproxy:70". | 2542 // Configure against https proxy server "myproxy:70". |
| 2543 SessionDependencies session_deps( | 2543 SessionDependencies session_deps( |
| 2544 ProxyService::CreateFixed("https://myproxy:70")); | 2544 ProxyService::CreateFixed("https://myproxy:70")); |
| 2545 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 2545 CapturingBoundNetLog log; |
| 2546 session_deps.net_log = log.bound().net_log(); | 2546 session_deps.net_log = log.bound().net_log(); |
| 2547 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2547 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2548 | 2548 |
| 2549 // Since we have proxy, should use full url | 2549 // Since we have proxy, should use full url |
| 2550 MockWrite data_writes1[] = { | 2550 MockWrite data_writes1[] = { |
| 2551 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" | 2551 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" |
| 2552 "Host: www.google.com\r\n" | 2552 "Host: www.google.com\r\n" |
| 2553 "Proxy-Connection: keep-alive\r\n\r\n"), | 2553 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 2554 | 2554 |
| 2555 // After calling trans->RestartWithAuth(), this is the request we should | 2555 // After calling trans->RestartWithAuth(), this is the request we should |
| (...skipping 2355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4911 TEST_F(HttpNetworkTransactionSpdy3Test, BasicAuthSpdyProxy) { | 4911 TEST_F(HttpNetworkTransactionSpdy3Test, BasicAuthSpdyProxy) { |
| 4912 HttpRequestInfo request; | 4912 HttpRequestInfo request; |
| 4913 request.method = "GET"; | 4913 request.method = "GET"; |
| 4914 request.url = GURL("https://www.google.com/"); | 4914 request.url = GURL("https://www.google.com/"); |
| 4915 // when the no authentication data flag is set. | 4915 // when the no authentication data flag is set. |
| 4916 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 4916 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
| 4917 | 4917 |
| 4918 // Configure against https proxy server "myproxy:70". | 4918 // Configure against https proxy server "myproxy:70". |
| 4919 SessionDependencies session_deps( | 4919 SessionDependencies session_deps( |
| 4920 ProxyService::CreateFixed("https://myproxy:70")); | 4920 ProxyService::CreateFixed("https://myproxy:70")); |
| 4921 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 4921 CapturingBoundNetLog log; |
| 4922 session_deps.net_log = log.bound().net_log(); | 4922 session_deps.net_log = log.bound().net_log(); |
| 4923 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 4923 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 4924 | 4924 |
| 4925 // Since we have proxy, should try to establish tunnel. | 4925 // Since we have proxy, should try to establish tunnel. |
| 4926 scoped_ptr<SpdyFrame> req(ConstructSpdyConnect(NULL, 0, 1)); | 4926 scoped_ptr<SpdyFrame> req(ConstructSpdyConnect(NULL, 0, 1)); |
| 4927 scoped_ptr<SpdyFrame> rst(ConstructSpdyRstStream(1, CANCEL)); | 4927 scoped_ptr<SpdyFrame> rst(ConstructSpdyRstStream(1, CANCEL)); |
| 4928 | 4928 |
| 4929 // After calling trans->RestartWithAuth(), this is the request we should | 4929 // After calling trans->RestartWithAuth(), this is the request we should |
| 4930 // be issuing -- the final header line contains the credentials. | 4930 // be issuing -- the final header line contains the credentials. |
| 4931 const char* const kAuthCredentials[] = { | 4931 const char* const kAuthCredentials[] = { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4997 | 4997 |
| 4998 TestCompletionCallback callback1; | 4998 TestCompletionCallback callback1; |
| 4999 | 4999 |
| 5000 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 5000 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 5001 | 5001 |
| 5002 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 5002 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 5003 EXPECT_EQ(ERR_IO_PENDING, rv); | 5003 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5004 | 5004 |
| 5005 rv = callback1.WaitForResult(); | 5005 rv = callback1.WaitForResult(); |
| 5006 EXPECT_EQ(OK, rv); | 5006 EXPECT_EQ(OK, rv); |
| 5007 net::CapturingNetLog::CapturedEntryList entries; | 5007 CapturingNetLog::CapturedEntryList entries; |
| 5008 log.GetEntries(&entries); | 5008 log.GetEntries(&entries); |
| 5009 size_t pos = ExpectLogContainsSomewhere( | 5009 size_t pos = ExpectLogContainsSomewhere( |
| 5010 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 5010 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 5011 NetLog::PHASE_NONE); | 5011 NetLog::PHASE_NONE); |
| 5012 ExpectLogContainsSomewhere( | 5012 ExpectLogContainsSomewhere( |
| 5013 entries, pos, | 5013 entries, pos, |
| 5014 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 5014 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 5015 NetLog::PHASE_NONE); | 5015 NetLog::PHASE_NONE); |
| 5016 | 5016 |
| 5017 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5017 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5059 }; | 5059 }; |
| 5060 | 5060 |
| 5061 request.method = "GET"; | 5061 request.method = "GET"; |
| 5062 request.url = GURL("http://www.google.com/"); | 5062 request.url = GURL("http://www.google.com/"); |
| 5063 push_request.method = "GET"; | 5063 push_request.method = "GET"; |
| 5064 push_request.url = GURL("http://www.another-origin.com/foo.dat"); | 5064 push_request.url = GURL("http://www.another-origin.com/foo.dat"); |
| 5065 | 5065 |
| 5066 // Configure against https proxy server "myproxy:70". | 5066 // Configure against https proxy server "myproxy:70". |
| 5067 SessionDependencies session_deps( | 5067 SessionDependencies session_deps( |
| 5068 ProxyService::CreateFixed("https://myproxy:70")); | 5068 ProxyService::CreateFixed("https://myproxy:70")); |
| 5069 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 5069 CapturingBoundNetLog log; |
| 5070 session_deps.net_log = log.bound().net_log(); | 5070 session_deps.net_log = log.bound().net_log(); |
| 5071 | 5071 |
| 5072 // Enable cross-origin push. | 5072 // Enable cross-origin push. |
| 5073 session_deps.trusted_spdy_proxy = "myproxy:70"; | 5073 session_deps.trusted_spdy_proxy = "myproxy:70"; |
| 5074 | 5074 |
| 5075 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 5075 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 5076 | 5076 |
| 5077 scoped_ptr<SpdyFrame> | 5077 scoped_ptr<SpdyFrame> |
| 5078 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); | 5078 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); |
| 5079 | 5079 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5157 // Test that an explicitly trusted SPDY proxy cannot push HTTPS content. | 5157 // Test that an explicitly trusted SPDY proxy cannot push HTTPS content. |
| 5158 TEST_F(HttpNetworkTransactionSpdy3Test, CrossOriginProxyPushCorrectness) { | 5158 TEST_F(HttpNetworkTransactionSpdy3Test, CrossOriginProxyPushCorrectness) { |
| 5159 HttpRequestInfo request; | 5159 HttpRequestInfo request; |
| 5160 | 5160 |
| 5161 request.method = "GET"; | 5161 request.method = "GET"; |
| 5162 request.url = GURL("http://www.google.com/"); | 5162 request.url = GURL("http://www.google.com/"); |
| 5163 | 5163 |
| 5164 // Configure against https proxy server "myproxy:70". | 5164 // Configure against https proxy server "myproxy:70". |
| 5165 SessionDependencies session_deps( | 5165 SessionDependencies session_deps( |
| 5166 ProxyService::CreateFixed("https://myproxy:70")); | 5166 ProxyService::CreateFixed("https://myproxy:70")); |
| 5167 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 5167 CapturingBoundNetLog log; |
| 5168 session_deps.net_log = log.bound().net_log(); | 5168 session_deps.net_log = log.bound().net_log(); |
| 5169 | 5169 |
| 5170 // Enable cross-origin push. | 5170 // Enable cross-origin push. |
| 5171 session_deps.trusted_spdy_proxy = "myproxy:70"; | 5171 session_deps.trusted_spdy_proxy = "myproxy:70"; |
| 5172 | 5172 |
| 5173 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 5173 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 5174 | 5174 |
| 5175 scoped_ptr<SpdyFrame> | 5175 scoped_ptr<SpdyFrame> |
| 5176 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); | 5176 stream1_syn(ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); |
| 5177 | 5177 |
| (...skipping 3607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8785 session_deps.host_resolver->set_synchronous_mode(true); | 8785 session_deps.host_resolver->set_synchronous_mode(true); |
| 8786 scoped_ptr<HttpTransaction> trans( | 8786 scoped_ptr<HttpTransaction> trans( |
| 8787 new HttpNetworkTransaction(CreateSession(&session_deps))); | 8787 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 8788 | 8788 |
| 8789 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 8789 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 8790 data.set_connect_data(mock_connect); | 8790 data.set_connect_data(mock_connect); |
| 8791 session_deps.socket_factory.AddSocketDataProvider(&data); | 8791 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 8792 | 8792 |
| 8793 TestCompletionCallback callback; | 8793 TestCompletionCallback callback; |
| 8794 | 8794 |
| 8795 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8795 CapturingBoundNetLog log; |
| 8796 int rv = trans->Start(&request, callback.callback(), log.bound()); | 8796 int rv = trans->Start(&request, callback.callback(), log.bound()); |
| 8797 EXPECT_EQ(ERR_IO_PENDING, rv); | 8797 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8798 trans.reset(); // Cancel the transaction here. | 8798 trans.reset(); // Cancel the transaction here. |
| 8799 | 8799 |
| 8800 MessageLoop::current()->RunAllPending(); | 8800 MessageLoop::current()->RunAllPending(); |
| 8801 } | 8801 } |
| 8802 | 8802 |
| 8803 // Test a basic GET request through a proxy. | 8803 // Test a basic GET request through a proxy. |
| 8804 TEST_F(HttpNetworkTransactionSpdy3Test, ProxyGet) { | 8804 TEST_F(HttpNetworkTransactionSpdy3Test, ProxyGet) { |
| 8805 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8805 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 8806 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8806 CapturingBoundNetLog log; |
| 8807 session_deps.net_log = log.bound().net_log(); | 8807 session_deps.net_log = log.bound().net_log(); |
| 8808 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8808 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8809 | 8809 |
| 8810 HttpRequestInfo request; | 8810 HttpRequestInfo request; |
| 8811 request.method = "GET"; | 8811 request.method = "GET"; |
| 8812 request.url = GURL("http://www.google.com/"); | 8812 request.url = GURL("http://www.google.com/"); |
| 8813 | 8813 |
| 8814 MockWrite data_writes1[] = { | 8814 MockWrite data_writes1[] = { |
| 8815 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" | 8815 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" |
| 8816 "Host: www.google.com\r\n" | 8816 "Host: www.google.com\r\n" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 8844 EXPECT_TRUE(response->headers->IsKeepAlive()); | 8844 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 8845 EXPECT_EQ(200, response->headers->response_code()); | 8845 EXPECT_EQ(200, response->headers->response_code()); |
| 8846 EXPECT_EQ(100, response->headers->GetContentLength()); | 8846 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 8847 EXPECT_TRUE(response->was_fetched_via_proxy); | 8847 EXPECT_TRUE(response->was_fetched_via_proxy); |
| 8848 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 8848 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 8849 } | 8849 } |
| 8850 | 8850 |
| 8851 // Test a basic HTTPS GET request through a proxy. | 8851 // Test a basic HTTPS GET request through a proxy. |
| 8852 TEST_F(HttpNetworkTransactionSpdy3Test, ProxyTunnelGet) { | 8852 TEST_F(HttpNetworkTransactionSpdy3Test, ProxyTunnelGet) { |
| 8853 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8853 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 8854 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8854 CapturingBoundNetLog log; |
| 8855 session_deps.net_log = log.bound().net_log(); | 8855 session_deps.net_log = log.bound().net_log(); |
| 8856 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8856 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8857 | 8857 |
| 8858 HttpRequestInfo request; | 8858 HttpRequestInfo request; |
| 8859 request.method = "GET"; | 8859 request.method = "GET"; |
| 8860 request.url = GURL("https://www.google.com/"); | 8860 request.url = GURL("https://www.google.com/"); |
| 8861 | 8861 |
| 8862 // Since we have proxy, should try to establish tunnel. | 8862 // Since we have proxy, should try to establish tunnel. |
| 8863 MockWrite data_writes1[] = { | 8863 MockWrite data_writes1[] = { |
| 8864 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 8864 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 8887 | 8887 |
| 8888 TestCompletionCallback callback1; | 8888 TestCompletionCallback callback1; |
| 8889 | 8889 |
| 8890 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8890 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 8891 | 8891 |
| 8892 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 8892 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 8893 EXPECT_EQ(ERR_IO_PENDING, rv); | 8893 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8894 | 8894 |
| 8895 rv = callback1.WaitForResult(); | 8895 rv = callback1.WaitForResult(); |
| 8896 EXPECT_EQ(OK, rv); | 8896 EXPECT_EQ(OK, rv); |
| 8897 net::CapturingNetLog::CapturedEntryList entries; | 8897 CapturingNetLog::CapturedEntryList entries; |
| 8898 log.GetEntries(&entries); | 8898 log.GetEntries(&entries); |
| 8899 size_t pos = ExpectLogContainsSomewhere( | 8899 size_t pos = ExpectLogContainsSomewhere( |
| 8900 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 8900 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 8901 NetLog::PHASE_NONE); | 8901 NetLog::PHASE_NONE); |
| 8902 ExpectLogContainsSomewhere( | 8902 ExpectLogContainsSomewhere( |
| 8903 entries, pos, | 8903 entries, pos, |
| 8904 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 8904 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 8905 NetLog::PHASE_NONE); | 8905 NetLog::PHASE_NONE); |
| 8906 | 8906 |
| 8907 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8907 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 8908 ASSERT_TRUE(response != NULL); | 8908 ASSERT_TRUE(response != NULL); |
| 8909 | 8909 |
| 8910 EXPECT_TRUE(response->headers->IsKeepAlive()); | 8910 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 8911 EXPECT_EQ(200, response->headers->response_code()); | 8911 EXPECT_EQ(200, response->headers->response_code()); |
| 8912 EXPECT_EQ(100, response->headers->GetContentLength()); | 8912 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 8913 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 8913 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 8914 EXPECT_TRUE(response->was_fetched_via_proxy); | 8914 EXPECT_TRUE(response->was_fetched_via_proxy); |
| 8915 } | 8915 } |
| 8916 | 8916 |
| 8917 // Test a basic HTTPS GET request through a proxy, but the server hangs up | 8917 // Test a basic HTTPS GET request through a proxy, but the server hangs up |
| 8918 // while establishing the tunnel. | 8918 // while establishing the tunnel. |
| 8919 TEST_F(HttpNetworkTransactionSpdy3Test, ProxyTunnelGetHangup) { | 8919 TEST_F(HttpNetworkTransactionSpdy3Test, ProxyTunnelGetHangup) { |
| 8920 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8920 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 8921 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8921 CapturingBoundNetLog log; |
| 8922 session_deps.net_log = log.bound().net_log(); | 8922 session_deps.net_log = log.bound().net_log(); |
| 8923 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8923 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8924 | 8924 |
| 8925 HttpRequestInfo request; | 8925 HttpRequestInfo request; |
| 8926 request.method = "GET"; | 8926 request.method = "GET"; |
| 8927 request.url = GURL("https://www.google.com/"); | 8927 request.url = GURL("https://www.google.com/"); |
| 8928 | 8928 |
| 8929 // Since we have proxy, should try to establish tunnel. | 8929 // Since we have proxy, should try to establish tunnel. |
| 8930 MockWrite data_writes1[] = { | 8930 MockWrite data_writes1[] = { |
| 8931 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 8931 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 8951 | 8951 |
| 8952 TestCompletionCallback callback1; | 8952 TestCompletionCallback callback1; |
| 8953 | 8953 |
| 8954 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8954 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 8955 | 8955 |
| 8956 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 8956 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 8957 EXPECT_EQ(ERR_IO_PENDING, rv); | 8957 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8958 | 8958 |
| 8959 rv = callback1.WaitForResult(); | 8959 rv = callback1.WaitForResult(); |
| 8960 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); | 8960 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); |
| 8961 net::CapturingNetLog::CapturedEntryList entries; | 8961 CapturingNetLog::CapturedEntryList entries; |
| 8962 log.GetEntries(&entries); | 8962 log.GetEntries(&entries); |
| 8963 size_t pos = ExpectLogContainsSomewhere( | 8963 size_t pos = ExpectLogContainsSomewhere( |
| 8964 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 8964 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 8965 NetLog::PHASE_NONE); | 8965 NetLog::PHASE_NONE); |
| 8966 ExpectLogContainsSomewhere( | 8966 ExpectLogContainsSomewhere( |
| 8967 entries, pos, | 8967 entries, pos, |
| 8968 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 8968 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 8969 NetLog::PHASE_NONE); | 8969 NetLog::PHASE_NONE); |
| 8970 } | 8970 } |
| 8971 | 8971 |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9298 // cache when: | 9298 // cache when: |
| 9299 // 1) An HTTPS proxy is involved. | 9299 // 1) An HTTPS proxy is involved. |
| 9300 // 3) The HTTPS proxy requests a client certificate. | 9300 // 3) The HTTPS proxy requests a client certificate. |
| 9301 // 4) The client supplies an invalid/unacceptable certificate for the | 9301 // 4) The client supplies an invalid/unacceptable certificate for the |
| 9302 // proxy. | 9302 // proxy. |
| 9303 // The test is repeated twice, first for connecting to an HTTPS endpoint, | 9303 // The test is repeated twice, first for connecting to an HTTPS endpoint, |
| 9304 // then for connecting to an HTTP endpoint. | 9304 // then for connecting to an HTTP endpoint. |
| 9305 TEST_F(HttpNetworkTransactionSpdy3Test, ClientAuthCertCache_Proxy_Fail) { | 9305 TEST_F(HttpNetworkTransactionSpdy3Test, ClientAuthCertCache_Proxy_Fail) { |
| 9306 SessionDependencies session_deps( | 9306 SessionDependencies session_deps( |
| 9307 ProxyService::CreateFixed("https://proxy:70")); | 9307 ProxyService::CreateFixed("https://proxy:70")); |
| 9308 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 9308 CapturingBoundNetLog log; |
| 9309 session_deps.net_log = log.bound().net_log(); | 9309 session_deps.net_log = log.bound().net_log(); |
| 9310 | 9310 |
| 9311 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); | 9311 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); |
| 9312 cert_request->host_and_port = "proxy:70"; | 9312 cert_request->host_and_port = "proxy:70"; |
| 9313 | 9313 |
| 9314 // See ClientAuthCertCache_Direct_NoFalseStart for the explanation of | 9314 // See ClientAuthCertCache_Direct_NoFalseStart for the explanation of |
| 9315 // [ssl_]data[1-3]. Rather than represending the endpoint | 9315 // [ssl_]data[1-3]. Rather than represending the endpoint |
| 9316 // (www.example.com:443), they represent failures with the HTTPS proxy | 9316 // (www.example.com:443), they represent failures with the HTTPS proxy |
| 9317 // (proxy:70). | 9317 // (proxy:70). |
| 9318 SSLSocketDataProvider ssl_data1(ASYNC, net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED); | 9318 SSLSocketDataProvider ssl_data1(ASYNC, net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED); |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9732 StaticSocketDataProvider* data[] = { &data1, &data2 }; | 9732 StaticSocketDataProvider* data[] = { &data1, &data2 }; |
| 9733 | 9733 |
| 9734 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); | 9734 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); |
| 9735 | 9735 |
| 9736 EXPECT_EQ(OK, out.rv); | 9736 EXPECT_EQ(OK, out.rv); |
| 9737 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | 9737 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); |
| 9738 EXPECT_EQ("hello world", out.response_data); | 9738 EXPECT_EQ("hello world", out.response_data); |
| 9739 } | 9739 } |
| 9740 | 9740 |
| 9741 } // namespace net | 9741 } // namespace net |
| OLD | NEW |