| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <math.h> // ceil | 5 #include <math.h> // ceil |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "net/base/client_socket_factory.h" | 8 #include "net/base/client_socket_factory.h" |
| 9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
| 10 #include "net/base/ssl_client_socket.h" | 10 #include "net/base/ssl_client_socket.h" |
| (...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 session.get(), &mock_socket_factory)); | 1249 session.get(), &mock_socket_factory)); |
| 1250 | 1250 |
| 1251 net::HttpRequestInfo request; | 1251 net::HttpRequestInfo request; |
| 1252 request.method = "GET"; | 1252 request.method = "GET"; |
| 1253 request.url = GURL("https://www.google.com/"); | 1253 request.url = GURL("https://www.google.com/"); |
| 1254 request.load_flags = 0; | 1254 request.load_flags = 0; |
| 1255 | 1255 |
| 1256 // Since we have proxy, should try to establish tunnel. | 1256 // Since we have proxy, should try to establish tunnel. |
| 1257 MockWrite data_writes1[] = { | 1257 MockWrite data_writes1[] = { |
| 1258 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 1258 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 1259 "Host: www.google.com\r\n\r\n"), | 1259 "Host: www.google.com\r\n" |
| 1260 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 1260 | 1261 |
| 1261 // After calling trans->RestartWithAuth(), this is the request we should | 1262 // After calling trans->RestartWithAuth(), this is the request we should |
| 1262 // be issuing -- the final header line contains the credentials. | 1263 // be issuing -- the final header line contains the credentials. |
| 1263 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 1264 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 1264 "Host: www.google.com\r\n" | 1265 "Host: www.google.com\r\n" |
| 1266 "Proxy-Connection: keep-alive\r\n" |
| 1265 "Proxy-Authorization: Basic Zm9vOmJheg==\r\n\r\n"), | 1267 "Proxy-Authorization: Basic Zm9vOmJheg==\r\n\r\n"), |
| 1266 }; | 1268 }; |
| 1267 | 1269 |
| 1268 // The proxy responds to the connect with a 407, using a persistent | 1270 // The proxy responds to the connect with a 407, using a persistent |
| 1269 // connection. | 1271 // connection. |
| 1270 MockRead data_reads1[] = { | 1272 MockRead data_reads1[] = { |
| 1271 // No credentials. | 1273 // No credentials. |
| 1272 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), | 1274 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), |
| 1273 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 1275 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 1274 MockRead("Content-Length: 10\r\n\r\n"), | 1276 MockRead("Content-Length: 10\r\n\r\n"), |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 session.get(), &mock_socket_factory)); | 1354 session.get(), &mock_socket_factory)); |
| 1353 | 1355 |
| 1354 net::HttpRequestInfo request; | 1356 net::HttpRequestInfo request; |
| 1355 request.method = "GET"; | 1357 request.method = "GET"; |
| 1356 request.url = GURL("https://www.google.com/"); | 1358 request.url = GURL("https://www.google.com/"); |
| 1357 request.load_flags = 0; | 1359 request.load_flags = 0; |
| 1358 | 1360 |
| 1359 // Since we have proxy, should try to establish tunnel. | 1361 // Since we have proxy, should try to establish tunnel. |
| 1360 MockWrite data_writes[] = { | 1362 MockWrite data_writes[] = { |
| 1361 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 1363 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 1362 "Host: www.google.com\r\n\r\n"), | 1364 "Host: www.google.com\r\n" |
| 1365 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 1363 }; | 1366 }; |
| 1364 | 1367 |
| 1365 // The proxy responds to the connect with a 407. | 1368 // The proxy responds to the connect with a 407. |
| 1366 MockRead data_reads[] = { | 1369 MockRead data_reads[] = { |
| 1367 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), | 1370 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), |
| 1368 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 1371 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 1369 MockRead("Content-Length: 10\r\n\r\n"), | 1372 MockRead("Content-Length: 10\r\n\r\n"), |
| 1370 MockRead(false, net::ERR_UNEXPECTED), // Should not be reached. | 1373 MockRead(false, net::ERR_UNEXPECTED), // Should not be reached. |
| 1371 }; | 1374 }; |
| 1372 | 1375 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 session.get(), &mock_socket_factory)); | 1413 session.get(), &mock_socket_factory)); |
| 1411 | 1414 |
| 1412 net::HttpRequestInfo request; | 1415 net::HttpRequestInfo request; |
| 1413 request.method = "GET"; | 1416 request.method = "GET"; |
| 1414 request.url = GURL("https://www.google.com/"); | 1417 request.url = GURL("https://www.google.com/"); |
| 1415 request.load_flags = 0; | 1418 request.load_flags = 0; |
| 1416 | 1419 |
| 1417 // Since we have proxy, should try to establish tunnel. | 1420 // Since we have proxy, should try to establish tunnel. |
| 1418 MockWrite data_writes[] = { | 1421 MockWrite data_writes[] = { |
| 1419 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 1422 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 1420 "Host: www.google.com\r\n\r\n"), | 1423 "Host: www.google.com\r\n" |
| 1424 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 1421 }; | 1425 }; |
| 1422 | 1426 |
| 1423 MockRead data_reads[] = { | 1427 MockRead data_reads[] = { |
| 1424 status, | 1428 status, |
| 1425 MockRead("Content-Length: 10\r\n\r\n"), | 1429 MockRead("Content-Length: 10\r\n\r\n"), |
| 1426 // No response body because the test stops reading here. | 1430 // No response body because the test stops reading here. |
| 1427 MockRead(false, net::ERR_UNEXPECTED), // Should not be reached. | 1431 MockRead(false, net::ERR_UNEXPECTED), // Should not be reached. |
| 1428 }; | 1432 }; |
| 1429 | 1433 |
| 1430 MockSocket data; | 1434 MockSocket data; |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2152 session.get(), &mock_socket_factory)); | 2156 session.get(), &mock_socket_factory)); |
| 2153 | 2157 |
| 2154 net::HttpRequestInfo request; | 2158 net::HttpRequestInfo request; |
| 2155 request.method = "GET"; | 2159 request.method = "GET"; |
| 2156 request.url = GURL("https://www.google.com/"); | 2160 request.url = GURL("https://www.google.com/"); |
| 2157 request.load_flags = 0; | 2161 request.load_flags = 0; |
| 2158 | 2162 |
| 2159 // Since we have proxy, should try to establish tunnel. | 2163 // Since we have proxy, should try to establish tunnel. |
| 2160 MockWrite data_writes1[] = { | 2164 MockWrite data_writes1[] = { |
| 2161 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 2165 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 2162 "Host: www.google.com\r\n\r\n"), | 2166 "Host: www.google.com\r\n" |
| 2167 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 2163 }; | 2168 }; |
| 2164 | 2169 |
| 2165 // The proxy responds to the connect with a 404, using a persistent | 2170 // The proxy responds to the connect with a 404, using a persistent |
| 2166 // connection. Usually a proxy would return 501 (not implemented), | 2171 // connection. Usually a proxy would return 501 (not implemented), |
| 2167 // or 200 (tunnel established). | 2172 // or 200 (tunnel established). |
| 2168 MockRead data_reads1[] = { | 2173 MockRead data_reads1[] = { |
| 2169 MockRead("HTTP/1.1 404 Not Found\r\n"), | 2174 MockRead("HTTP/1.1 404 Not Found\r\n"), |
| 2170 MockRead("Content-Length: 10\r\n\r\n"), | 2175 MockRead("Content-Length: 10\r\n\r\n"), |
| 2171 MockRead(false, net::ERR_UNEXPECTED), // Should not be reached. | 2176 MockRead(false, net::ERR_UNEXPECTED), // Should not be reached. |
| 2172 }; | 2177 }; |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2976 scoped_ptr<ProxyService> proxy_service( | 2981 scoped_ptr<ProxyService> proxy_service( |
| 2977 CreateFixedProxyService("myproxy:70")); | 2982 CreateFixedProxyService("myproxy:70")); |
| 2978 | 2983 |
| 2979 HttpRequestInfo request; | 2984 HttpRequestInfo request; |
| 2980 request.method = "GET"; | 2985 request.method = "GET"; |
| 2981 request.url = GURL("https://www.google.com/"); | 2986 request.url = GURL("https://www.google.com/"); |
| 2982 request.load_flags = 0; | 2987 request.load_flags = 0; |
| 2983 | 2988 |
| 2984 MockWrite proxy_writes[] = { | 2989 MockWrite proxy_writes[] = { |
| 2985 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 2990 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 2986 "Host: www.google.com\r\n\r\n"), | 2991 "Host: www.google.com\r\n" |
| 2992 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 2987 }; | 2993 }; |
| 2988 | 2994 |
| 2989 MockRead proxy_reads[] = { | 2995 MockRead proxy_reads[] = { |
| 2990 MockRead("HTTP/1.0 200 Connected\r\n\r\n"), | 2996 MockRead("HTTP/1.0 200 Connected\r\n\r\n"), |
| 2991 MockRead(false, net::OK) | 2997 MockRead(false, net::OK) |
| 2992 }; | 2998 }; |
| 2993 | 2999 |
| 2994 MockWrite data_writes[] = { | 3000 MockWrite data_writes[] = { |
| 2995 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 3001 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 2996 "Host: www.google.com\r\n\r\n"), | 3002 "Host: www.google.com\r\n" |
| 3003 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 2997 MockWrite("GET / HTTP/1.1\r\n" | 3004 MockWrite("GET / HTTP/1.1\r\n" |
| 2998 "Host: www.google.com\r\n" | 3005 "Host: www.google.com\r\n" |
| 2999 "Connection: keep-alive\r\n\r\n"), | 3006 "Connection: keep-alive\r\n\r\n"), |
| 3000 }; | 3007 }; |
| 3001 | 3008 |
| 3002 MockRead data_reads[] = { | 3009 MockRead data_reads[] = { |
| 3003 MockRead("HTTP/1.0 200 Connected\r\n\r\n"), | 3010 MockRead("HTTP/1.0 200 Connected\r\n\r\n"), |
| 3004 MockRead("HTTP/1.0 200 OK\r\n"), | 3011 MockRead("HTTP/1.0 200 OK\r\n"), |
| 3005 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 3012 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 3006 MockRead("Content-Length: 100\r\n\r\n"), | 3013 MockRead("Content-Length: 100\r\n\r\n"), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3042 EXPECT_EQ(OK, rv); | 3049 EXPECT_EQ(OK, rv); |
| 3043 | 3050 |
| 3044 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3051 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3045 | 3052 |
| 3046 EXPECT_FALSE(response == NULL); | 3053 EXPECT_FALSE(response == NULL); |
| 3047 EXPECT_EQ(100, response->headers->GetContentLength()); | 3054 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 3048 } | 3055 } |
| 3049 } | 3056 } |
| 3050 | 3057 |
| 3051 } // namespace net | 3058 } // namespace net |
| OLD | NEW |