| 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 |
| (...skipping 1485 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(HttpNetworkTransactionSpdy2Test, BasicAuthProxyNoKeepAlive) { | 1735 TEST_F(HttpNetworkTransactionSpdy2Test, 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1840 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyKeepAlive) { | 1840 TEST_F(HttpNetworkTransactionSpdy2Test, 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 182 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(HttpNetworkTransactionSpdy2Test, | 2046 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2102 | 2102 |
| 2103 // Test a simple get through an HTTPS Proxy. | 2103 // Test a simple get through an HTTPS Proxy. |
| 2104 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxyGet) { | 2104 TEST_F(HttpNetworkTransactionSpdy2Test, 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(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyGet) { | 2159 TEST_F(HttpNetworkTransactionSpdy2Test, 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(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyGetWithProxyAuth) { | 2217 TEST_F(HttpNetworkTransactionSpdy2Test, 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(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectHttps) { | 2317 TEST_F(HttpNetworkTransactionSpdy2Test, 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(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectSpdy) { | 2398 TEST_F(HttpNetworkTransactionSpdy2Test, 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(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectFailure) { | 2477 TEST_F(HttpNetworkTransactionSpdy2Test, 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(HttpNetworkTransactionSpdy2Test, HttpsProxyAuthRetry) { | 2535 TEST_F(HttpNetworkTransactionSpdy2Test, 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(HttpNetworkTransactionSpdy2Test, BasicAuthSpdyProxy) { | 4911 TEST_F(HttpNetworkTransactionSpdy2Test, 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 127 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(HttpNetworkTransactionSpdy2Test, CrossOriginProxyPushCorrectness) { | 5158 TEST_F(HttpNetworkTransactionSpdy2Test, 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 3608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8786 session_deps.host_resolver->set_synchronous_mode(true); | 8786 session_deps.host_resolver->set_synchronous_mode(true); |
| 8787 scoped_ptr<HttpTransaction> trans( | 8787 scoped_ptr<HttpTransaction> trans( |
| 8788 new HttpNetworkTransaction(CreateSession(&session_deps))); | 8788 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 8789 | 8789 |
| 8790 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 8790 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 8791 data.set_connect_data(mock_connect); | 8791 data.set_connect_data(mock_connect); |
| 8792 session_deps.socket_factory.AddSocketDataProvider(&data); | 8792 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 8793 | 8793 |
| 8794 TestCompletionCallback callback; | 8794 TestCompletionCallback callback; |
| 8795 | 8795 |
| 8796 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8796 CapturingBoundNetLog log; |
| 8797 int rv = trans->Start(&request, callback.callback(), log.bound()); | 8797 int rv = trans->Start(&request, callback.callback(), log.bound()); |
| 8798 EXPECT_EQ(ERR_IO_PENDING, rv); | 8798 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8799 trans.reset(); // Cancel the transaction here. | 8799 trans.reset(); // Cancel the transaction here. |
| 8800 | 8800 |
| 8801 MessageLoop::current()->RunAllPending(); | 8801 MessageLoop::current()->RunAllPending(); |
| 8802 } | 8802 } |
| 8803 | 8803 |
| 8804 // Test a basic GET request through a proxy. | 8804 // Test a basic GET request through a proxy. |
| 8805 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyGet) { | 8805 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyGet) { |
| 8806 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8806 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 8807 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8807 CapturingBoundNetLog log; |
| 8808 session_deps.net_log = log.bound().net_log(); | 8808 session_deps.net_log = log.bound().net_log(); |
| 8809 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8809 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8810 | 8810 |
| 8811 HttpRequestInfo request; | 8811 HttpRequestInfo request; |
| 8812 request.method = "GET"; | 8812 request.method = "GET"; |
| 8813 request.url = GURL("http://www.google.com/"); | 8813 request.url = GURL("http://www.google.com/"); |
| 8814 | 8814 |
| 8815 MockWrite data_writes1[] = { | 8815 MockWrite data_writes1[] = { |
| 8816 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" | 8816 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" |
| 8817 "Host: www.google.com\r\n" | 8817 "Host: www.google.com\r\n" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 8845 EXPECT_TRUE(response->headers->IsKeepAlive()); | 8845 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 8846 EXPECT_EQ(200, response->headers->response_code()); | 8846 EXPECT_EQ(200, response->headers->response_code()); |
| 8847 EXPECT_EQ(100, response->headers->GetContentLength()); | 8847 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 8848 EXPECT_TRUE(response->was_fetched_via_proxy); | 8848 EXPECT_TRUE(response->was_fetched_via_proxy); |
| 8849 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 8849 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 8850 } | 8850 } |
| 8851 | 8851 |
| 8852 // Test a basic HTTPS GET request through a proxy. | 8852 // Test a basic HTTPS GET request through a proxy. |
| 8853 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGet) { | 8853 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGet) { |
| 8854 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8854 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 8855 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8855 CapturingBoundNetLog log; |
| 8856 session_deps.net_log = log.bound().net_log(); | 8856 session_deps.net_log = log.bound().net_log(); |
| 8857 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8857 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8858 | 8858 |
| 8859 HttpRequestInfo request; | 8859 HttpRequestInfo request; |
| 8860 request.method = "GET"; | 8860 request.method = "GET"; |
| 8861 request.url = GURL("https://www.google.com/"); | 8861 request.url = GURL("https://www.google.com/"); |
| 8862 | 8862 |
| 8863 // Since we have proxy, should try to establish tunnel. | 8863 // Since we have proxy, should try to establish tunnel. |
| 8864 MockWrite data_writes1[] = { | 8864 MockWrite data_writes1[] = { |
| 8865 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 8865 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8912 EXPECT_EQ(200, response->headers->response_code()); | 8912 EXPECT_EQ(200, response->headers->response_code()); |
| 8913 EXPECT_EQ(100, response->headers->GetContentLength()); | 8913 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 8914 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 8914 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 8915 EXPECT_TRUE(response->was_fetched_via_proxy); | 8915 EXPECT_TRUE(response->was_fetched_via_proxy); |
| 8916 } | 8916 } |
| 8917 | 8917 |
| 8918 // Test a basic HTTPS GET request through a proxy, but the server hangs up | 8918 // Test a basic HTTPS GET request through a proxy, but the server hangs up |
| 8919 // while establishing the tunnel. | 8919 // while establishing the tunnel. |
| 8920 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGetHangup) { | 8920 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGetHangup) { |
| 8921 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8921 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 8922 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8922 CapturingBoundNetLog log; |
| 8923 session_deps.net_log = log.bound().net_log(); | 8923 session_deps.net_log = log.bound().net_log(); |
| 8924 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8924 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8925 | 8925 |
| 8926 HttpRequestInfo request; | 8926 HttpRequestInfo request; |
| 8927 request.method = "GET"; | 8927 request.method = "GET"; |
| 8928 request.url = GURL("https://www.google.com/"); | 8928 request.url = GURL("https://www.google.com/"); |
| 8929 | 8929 |
| 8930 // Since we have proxy, should try to establish tunnel. | 8930 // Since we have proxy, should try to establish tunnel. |
| 8931 MockWrite data_writes1[] = { | 8931 MockWrite data_writes1[] = { |
| 8932 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 8932 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9300 // cache when: | 9300 // cache when: |
| 9301 // 1) An HTTPS proxy is involved. | 9301 // 1) An HTTPS proxy is involved. |
| 9302 // 3) The HTTPS proxy requests a client certificate. | 9302 // 3) The HTTPS proxy requests a client certificate. |
| 9303 // 4) The client supplies an invalid/unacceptable certificate for the | 9303 // 4) The client supplies an invalid/unacceptable certificate for the |
| 9304 // proxy. | 9304 // proxy. |
| 9305 // The test is repeated twice, first for connecting to an HTTPS endpoint, | 9305 // The test is repeated twice, first for connecting to an HTTPS endpoint, |
| 9306 // then for connecting to an HTTP endpoint. | 9306 // then for connecting to an HTTP endpoint. |
| 9307 TEST_F(HttpNetworkTransactionSpdy2Test, ClientAuthCertCache_Proxy_Fail) { | 9307 TEST_F(HttpNetworkTransactionSpdy2Test, ClientAuthCertCache_Proxy_Fail) { |
| 9308 SessionDependencies session_deps( | 9308 SessionDependencies session_deps( |
| 9309 ProxyService::CreateFixed("https://proxy:70")); | 9309 ProxyService::CreateFixed("https://proxy:70")); |
| 9310 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 9310 CapturingBoundNetLog log; |
| 9311 session_deps.net_log = log.bound().net_log(); | 9311 session_deps.net_log = log.bound().net_log(); |
| 9312 | 9312 |
| 9313 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); | 9313 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); |
| 9314 cert_request->host_and_port = "proxy:70"; | 9314 cert_request->host_and_port = "proxy:70"; |
| 9315 | 9315 |
| 9316 // See ClientAuthCertCache_Direct_NoFalseStart for the explanation of | 9316 // See ClientAuthCertCache_Direct_NoFalseStart for the explanation of |
| 9317 // [ssl_]data[1-3]. Rather than represending the endpoint | 9317 // [ssl_]data[1-3]. Rather than represending the endpoint |
| 9318 // (www.example.com:443), they represent failures with the HTTPS proxy | 9318 // (www.example.com:443), they represent failures with the HTTPS proxy |
| 9319 // (proxy:70). | 9319 // (proxy:70). |
| 9320 SSLSocketDataProvider ssl_data1(ASYNC, net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED); | 9320 SSLSocketDataProvider ssl_data1(ASYNC, net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED); |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9748 StaticSocketDataProvider* data[] = { &data1, &data2 }; | 9748 StaticSocketDataProvider* data[] = { &data1, &data2 }; |
| 9749 | 9749 |
| 9750 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); | 9750 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); |
| 9751 | 9751 |
| 9752 EXPECT_EQ(OK, out.rv); | 9752 EXPECT_EQ(OK, out.rv); |
| 9753 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | 9753 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); |
| 9754 EXPECT_EQ("hello world", out.response_data); | 9754 EXPECT_EQ("hello world", out.response_data); |
| 9755 } | 9755 } |
| 9756 | 9756 |
| 9757 } // namespace net | 9757 } // namespace net |
| OLD | NEW |