Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 1290243007: Shift URLRequestContextStorage over to taking scoped_ptrs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Paul_BuilderGrab
Patch Set: Sync'd to revision p347709. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 // Test the request-challenge-retry sequence for basic auth, over a connection 2392 // Test the request-challenge-retry sequence for basic auth, over a connection
2393 // that requires a restart when setting up an SSL tunnel. 2393 // that requires a restart when setting up an SSL tunnel.
2394 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyNoKeepAliveHttp10) { 2394 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyNoKeepAliveHttp10) {
2395 HttpRequestInfo request; 2395 HttpRequestInfo request;
2396 request.method = "GET"; 2396 request.method = "GET";
2397 request.url = GURL("https://www.example.org/"); 2397 request.url = GURL("https://www.example.org/");
2398 // when the no authentication data flag is set. 2398 // when the no authentication data flag is set.
2399 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 2399 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
2400 2400
2401 // Configure against proxy server "myproxy:70". 2401 // Configure against proxy server "myproxy:70".
2402 session_deps_.proxy_service.reset( 2402 session_deps_.proxy_service =
2403 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 2403 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70");
2404 BoundTestNetLog log; 2404 BoundTestNetLog log;
2405 session_deps_.net_log = log.bound().net_log(); 2405 session_deps_.net_log = log.bound().net_log();
2406 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2406 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2407 2407
2408 // Since we have proxy, should try to establish tunnel. 2408 // Since we have proxy, should try to establish tunnel.
2409 MockWrite data_writes1[] = { 2409 MockWrite data_writes1[] = {
2410 MockWrite("CONNECT www.example.org:443 HTTP/1.1\r\n" 2410 MockWrite("CONNECT www.example.org:443 HTTP/1.1\r\n"
2411 "Host: www.example.org\r\n" 2411 "Host: www.example.org\r\n"
2412 "Proxy-Connection: keep-alive\r\n\r\n"), 2412 "Proxy-Connection: keep-alive\r\n\r\n"),
2413 }; 2413 };
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 // Test the request-challenge-retry sequence for basic auth, over a connection 2516 // Test the request-challenge-retry sequence for basic auth, over a connection
2517 // that requires a restart when setting up an SSL tunnel. 2517 // that requires a restart when setting up an SSL tunnel.
2518 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyNoKeepAliveHttp11) { 2518 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyNoKeepAliveHttp11) {
2519 HttpRequestInfo request; 2519 HttpRequestInfo request;
2520 request.method = "GET"; 2520 request.method = "GET";
2521 request.url = GURL("https://www.example.org/"); 2521 request.url = GURL("https://www.example.org/");
2522 // when the no authentication data flag is set. 2522 // when the no authentication data flag is set.
2523 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 2523 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
2524 2524
2525 // Configure against proxy server "myproxy:70". 2525 // Configure against proxy server "myproxy:70".
2526 session_deps_.proxy_service.reset( 2526 session_deps_.proxy_service =
2527 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 2527 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70");
2528 BoundTestNetLog log; 2528 BoundTestNetLog log;
2529 session_deps_.net_log = log.bound().net_log(); 2529 session_deps_.net_log = log.bound().net_log();
2530 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2530 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2531 2531
2532 // Since we have proxy, should try to establish tunnel. 2532 // Since we have proxy, should try to establish tunnel.
2533 MockWrite data_writes1[] = { 2533 MockWrite data_writes1[] = {
2534 MockWrite("CONNECT www.example.org:443 HTTP/1.1\r\n" 2534 MockWrite("CONNECT www.example.org:443 HTTP/1.1\r\n"
2535 "Host: www.example.org\r\n" 2535 "Host: www.example.org\r\n"
2536 "Proxy-Connection: keep-alive\r\n\r\n"), 2536 "Proxy-Connection: keep-alive\r\n\r\n"),
2537 }; 2537 };
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2641 // proxy connection with HTTP/1.0 responses, when setting up an SSL tunnel. 2641 // proxy connection with HTTP/1.0 responses, when setting up an SSL tunnel.
2642 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyKeepAliveHttp10) { 2642 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyKeepAliveHttp10) {
2643 HttpRequestInfo request; 2643 HttpRequestInfo request;
2644 request.method = "GET"; 2644 request.method = "GET";
2645 request.url = GURL("https://www.example.org/"); 2645 request.url = GURL("https://www.example.org/");
2646 // Ensure that proxy authentication is attempted even 2646 // Ensure that proxy authentication is attempted even
2647 // when the no authentication data flag is set. 2647 // when the no authentication data flag is set.
2648 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 2648 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
2649 2649
2650 // Configure against proxy server "myproxy:70". 2650 // Configure against proxy server "myproxy:70".
2651 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 2651 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70");
2652 BoundTestNetLog log; 2652 BoundTestNetLog log;
2653 session_deps_.net_log = log.bound().net_log(); 2653 session_deps_.net_log = log.bound().net_log();
2654 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2654 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2655 2655
2656 scoped_ptr<HttpTransaction> trans( 2656 scoped_ptr<HttpTransaction> trans(
2657 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 2657 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
2658 2658
2659 // Since we have proxy, should try to establish tunnel. 2659 // Since we have proxy, should try to establish tunnel.
2660 MockWrite data_writes1[] = { 2660 MockWrite data_writes1[] = {
2661 MockWrite( 2661 MockWrite(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 // proxy connection with HTTP/1.1 responses, when setting up an SSL tunnel. 2748 // proxy connection with HTTP/1.1 responses, when setting up an SSL tunnel.
2749 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyKeepAliveHttp11) { 2749 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyKeepAliveHttp11) {
2750 HttpRequestInfo request; 2750 HttpRequestInfo request;
2751 request.method = "GET"; 2751 request.method = "GET";
2752 request.url = GURL("https://www.example.org/"); 2752 request.url = GURL("https://www.example.org/");
2753 // Ensure that proxy authentication is attempted even 2753 // Ensure that proxy authentication is attempted even
2754 // when the no authentication data flag is set. 2754 // when the no authentication data flag is set.
2755 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 2755 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
2756 2756
2757 // Configure against proxy server "myproxy:70". 2757 // Configure against proxy server "myproxy:70".
2758 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 2758 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70");
2759 BoundTestNetLog log; 2759 BoundTestNetLog log;
2760 session_deps_.net_log = log.bound().net_log(); 2760 session_deps_.net_log = log.bound().net_log();
2761 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2761 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2762 2762
2763 scoped_ptr<HttpTransaction> trans( 2763 scoped_ptr<HttpTransaction> trans(
2764 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 2764 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
2765 2765
2766 // Since we have proxy, should try to establish tunnel. 2766 // Since we have proxy, should try to establish tunnel.
2767 MockWrite data_writes1[] = { 2767 MockWrite data_writes1[] = {
2768 MockWrite( 2768 MockWrite(
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2854 // drained. 2854 // drained.
2855 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyKeepAliveHangupDuringBody) { 2855 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyKeepAliveHangupDuringBody) {
2856 HttpRequestInfo request; 2856 HttpRequestInfo request;
2857 request.method = "GET"; 2857 request.method = "GET";
2858 request.url = GURL("https://www.example.org/"); 2858 request.url = GURL("https://www.example.org/");
2859 // Ensure that proxy authentication is attempted even 2859 // Ensure that proxy authentication is attempted even
2860 // when the no authentication data flag is set. 2860 // when the no authentication data flag is set.
2861 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 2861 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
2862 2862
2863 // Configure against proxy server "myproxy:70". 2863 // Configure against proxy server "myproxy:70".
2864 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 2864 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70");
2865 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2865 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2866 2866
2867 scoped_ptr<HttpTransaction> trans( 2867 scoped_ptr<HttpTransaction> trans(
2868 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 2868 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
2869 2869
2870 // Since we have proxy, should try to establish tunnel. 2870 // Since we have proxy, should try to establish tunnel.
2871 MockWrite data_writes1[] = { 2871 MockWrite data_writes1[] = {
2872 MockWrite("CONNECT www.example.org:443 HTTP/1.1\r\n" 2872 MockWrite("CONNECT www.example.org:443 HTTP/1.1\r\n"
2873 "Host: www.example.org\r\n" 2873 "Host: www.example.org\r\n"
2874 "Proxy-Connection: keep-alive\r\n\r\n"), 2874 "Proxy-Connection: keep-alive\r\n\r\n"),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2943 2943
2944 // Test that we don't read the response body when we fail to establish a tunnel, 2944 // Test that we don't read the response body when we fail to establish a tunnel,
2945 // even if the user cancels the proxy's auth attempt. 2945 // even if the user cancels the proxy's auth attempt.
2946 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyCancelTunnel) { 2946 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyCancelTunnel) {
2947 HttpRequestInfo request; 2947 HttpRequestInfo request;
2948 request.method = "GET"; 2948 request.method = "GET";
2949 request.url = GURL("https://www.example.org/"); 2949 request.url = GURL("https://www.example.org/");
2950 request.load_flags = 0; 2950 request.load_flags = 0;
2951 2951
2952 // Configure against proxy server "myproxy:70". 2952 // Configure against proxy server "myproxy:70".
2953 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 2953 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70");
2954 2954
2955 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 2955 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
2956 2956
2957 scoped_ptr<HttpTransaction> trans( 2957 scoped_ptr<HttpTransaction> trans(
2958 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 2958 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
2959 2959
2960 // Since we have proxy, should try to establish tunnel. 2960 // Since we have proxy, should try to establish tunnel.
2961 MockWrite data_writes[] = { 2961 MockWrite data_writes[] = {
2962 MockWrite( 2962 MockWrite(
2963 "CONNECT www.example.org:443 HTTP/1.1\r\n" 2963 "CONNECT www.example.org:443 HTTP/1.1\r\n"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3003 3003
3004 // Test that we don't pass extraneous headers from the proxy's response to the 3004 // Test that we don't pass extraneous headers from the proxy's response to the
3005 // caller when the proxy responds to CONNECT with 407. 3005 // caller when the proxy responds to CONNECT with 407.
3006 TEST_P(HttpNetworkTransactionTest, SanitizeProxyAuthHeaders) { 3006 TEST_P(HttpNetworkTransactionTest, SanitizeProxyAuthHeaders) {
3007 HttpRequestInfo request; 3007 HttpRequestInfo request;
3008 request.method = "GET"; 3008 request.method = "GET";
3009 request.url = GURL("https://www.example.org/"); 3009 request.url = GURL("https://www.example.org/");
3010 request.load_flags = 0; 3010 request.load_flags = 0;
3011 3011
3012 // Configure against proxy server "myproxy:70". 3012 // Configure against proxy server "myproxy:70".
3013 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 3013 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70");
3014 3014
3015 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3015 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3016 3016
3017 scoped_ptr<HttpTransaction> trans( 3017 scoped_ptr<HttpTransaction> trans(
3018 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 3018 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
3019 3019
3020 // Since we have proxy, should try to establish tunnel. 3020 // Since we have proxy, should try to establish tunnel.
3021 MockWrite data_writes[] = { 3021 MockWrite data_writes[] = {
3022 MockWrite( 3022 MockWrite(
3023 "CONNECT www.example.org:443 HTTP/1.1\r\n" 3023 "CONNECT www.example.org:443 HTTP/1.1\r\n"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
3111 // Note that it is impossible to detect if an HTTP server returns a 407 through 3111 // Note that it is impossible to detect if an HTTP server returns a 407 through
3112 // a non-authenticating proxy - there is nothing to indicate whether the 3112 // a non-authenticating proxy - there is nothing to indicate whether the
3113 // response came from the proxy or the server, so it is treated as if the proxy 3113 // response came from the proxy or the server, so it is treated as if the proxy
3114 // issued the challenge. 3114 // issued the challenge.
3115 TEST_P(HttpNetworkTransactionTest, 3115 TEST_P(HttpNetworkTransactionTest,
3116 HttpsServerRequestsProxyAuthThroughProxy) { 3116 HttpsServerRequestsProxyAuthThroughProxy) {
3117 HttpRequestInfo request; 3117 HttpRequestInfo request;
3118 request.method = "GET"; 3118 request.method = "GET";
3119 request.url = GURL("https://www.example.org/"); 3119 request.url = GURL("https://www.example.org/");
3120 3120
3121 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 3121 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70");
3122 BoundTestNetLog log; 3122 BoundTestNetLog log;
3123 session_deps_.net_log = log.bound().net_log(); 3123 session_deps_.net_log = log.bound().net_log();
3124 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3124 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3125 3125
3126 // Since we have proxy, should try to establish tunnel. 3126 // Since we have proxy, should try to establish tunnel.
3127 MockWrite data_writes1[] = { 3127 MockWrite data_writes1[] = {
3128 MockWrite( 3128 MockWrite(
3129 "CONNECT www.example.org:443 HTTP/1.1\r\n" 3129 "CONNECT www.example.org:443 HTTP/1.1\r\n"
3130 "Host: www.example.org\r\n" 3130 "Host: www.example.org\r\n"
3131 "Proxy-Connection: keep-alive\r\n\r\n"), 3131 "Proxy-Connection: keep-alive\r\n\r\n"),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3176 TEST_P(HttpNetworkTransactionTest, HttpProxyLoadTimingNoPacTwoRequests) { 3176 TEST_P(HttpNetworkTransactionTest, HttpProxyLoadTimingNoPacTwoRequests) {
3177 HttpRequestInfo request1; 3177 HttpRequestInfo request1;
3178 request1.method = "GET"; 3178 request1.method = "GET";
3179 request1.url = GURL("https://www.example.org/1"); 3179 request1.url = GURL("https://www.example.org/1");
3180 3180
3181 HttpRequestInfo request2; 3181 HttpRequestInfo request2;
3182 request2.method = "GET"; 3182 request2.method = "GET";
3183 request2.url = GURL("https://www.example.org/2"); 3183 request2.url = GURL("https://www.example.org/2");
3184 3184
3185 // Configure against proxy server "myproxy:70". 3185 // Configure against proxy server "myproxy:70".
3186 session_deps_.proxy_service.reset( 3186 session_deps_.proxy_service = ProxyService::CreateFixed("PROXY myproxy:70");
3187 ProxyService::CreateFixed("PROXY myproxy:70"));
3188 BoundTestNetLog log; 3187 BoundTestNetLog log;
3189 session_deps_.net_log = log.bound().net_log(); 3188 session_deps_.net_log = log.bound().net_log();
3190 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3189 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3191 3190
3192 // Since we have proxy, should try to establish tunnel. 3191 // Since we have proxy, should try to establish tunnel.
3193 MockWrite data_writes1[] = { 3192 MockWrite data_writes1[] = {
3194 MockWrite( 3193 MockWrite(
3195 "CONNECT www.example.org:443 HTTP/1.1\r\n" 3194 "CONNECT www.example.org:443 HTTP/1.1\r\n"
3196 "Host: www.example.org\r\n" 3195 "Host: www.example.org\r\n"
3197 "Proxy-Connection: keep-alive\r\n\r\n"), 3196 "Proxy-Connection: keep-alive\r\n\r\n"),
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3277 TEST_P(HttpNetworkTransactionTest, HttpProxyLoadTimingWithPacTwoRequests) { 3276 TEST_P(HttpNetworkTransactionTest, HttpProxyLoadTimingWithPacTwoRequests) {
3278 HttpRequestInfo request1; 3277 HttpRequestInfo request1;
3279 request1.method = "GET"; 3278 request1.method = "GET";
3280 request1.url = GURL("https://www.example.org/1"); 3279 request1.url = GURL("https://www.example.org/1");
3281 3280
3282 HttpRequestInfo request2; 3281 HttpRequestInfo request2;
3283 request2.method = "GET"; 3282 request2.method = "GET";
3284 request2.url = GURL("https://www.example.org/2"); 3283 request2.url = GURL("https://www.example.org/2");
3285 3284
3286 // Configure against proxy server "myproxy:70". 3285 // Configure against proxy server "myproxy:70".
3287 session_deps_.proxy_service.reset( 3286 session_deps_.proxy_service =
3288 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 3287 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70");
3289 BoundTestNetLog log; 3288 BoundTestNetLog log;
3290 session_deps_.net_log = log.bound().net_log(); 3289 session_deps_.net_log = log.bound().net_log();
3291 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3290 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3292 3291
3293 // Since we have proxy, should try to establish tunnel. 3292 // Since we have proxy, should try to establish tunnel.
3294 MockWrite data_writes1[] = { 3293 MockWrite data_writes1[] = {
3295 MockWrite( 3294 MockWrite(
3296 "CONNECT www.example.org:443 HTTP/1.1\r\n" 3295 "CONNECT www.example.org:443 HTTP/1.1\r\n"
3297 "Host: www.example.org\r\n" 3296 "Host: www.example.org\r\n"
3298 "Proxy-Connection: keep-alive\r\n\r\n"), 3297 "Proxy-Connection: keep-alive\r\n\r\n"),
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
3375 session->CloseAllConnections(); 3374 session->CloseAllConnections();
3376 } 3375 }
3377 3376
3378 // Test a simple get through an HTTPS Proxy. 3377 // Test a simple get through an HTTPS Proxy.
3379 TEST_P(HttpNetworkTransactionTest, HttpsProxyGet) { 3378 TEST_P(HttpNetworkTransactionTest, HttpsProxyGet) {
3380 HttpRequestInfo request; 3379 HttpRequestInfo request;
3381 request.method = "GET"; 3380 request.method = "GET";
3382 request.url = GURL("http://www.example.org/"); 3381 request.url = GURL("http://www.example.org/");
3383 3382
3384 // Configure against https proxy server "proxy:70". 3383 // Configure against https proxy server "proxy:70".
3385 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 3384 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
3386 "https://proxy:70"));
3387 BoundTestNetLog log; 3385 BoundTestNetLog log;
3388 session_deps_.net_log = log.bound().net_log(); 3386 session_deps_.net_log = log.bound().net_log();
3389 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3387 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3390 3388
3391 // Since we have proxy, should use full url 3389 // Since we have proxy, should use full url
3392 MockWrite data_writes1[] = { 3390 MockWrite data_writes1[] = {
3393 MockWrite( 3391 MockWrite(
3394 "GET http://www.example.org/ HTTP/1.1\r\n" 3392 "GET http://www.example.org/ HTTP/1.1\r\n"
3395 "Host: www.example.org\r\n" 3393 "Host: www.example.org\r\n"
3396 "Proxy-Connection: keep-alive\r\n\r\n"), 3394 "Proxy-Connection: keep-alive\r\n\r\n"),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3438 } 3436 }
3439 3437
3440 // Test a SPDY get through an HTTPS Proxy. 3438 // Test a SPDY get through an HTTPS Proxy.
3441 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyGet) { 3439 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyGet) {
3442 HttpRequestInfo request; 3440 HttpRequestInfo request;
3443 request.method = "GET"; 3441 request.method = "GET";
3444 request.url = GURL("http://www.example.org/"); 3442 request.url = GURL("http://www.example.org/");
3445 request.load_flags = 0; 3443 request.load_flags = 0;
3446 3444
3447 // Configure against https proxy server "proxy:70". 3445 // Configure against https proxy server "proxy:70".
3448 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 3446 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
3449 "https://proxy:70"));
3450 BoundTestNetLog log; 3447 BoundTestNetLog log;
3451 session_deps_.net_log = log.bound().net_log(); 3448 session_deps_.net_log = log.bound().net_log();
3452 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3449 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3453 3450
3454 // fetch http://www.example.org/ via SPDY 3451 // fetch http://www.example.org/ via SPDY
3455 scoped_ptr<SpdyFrame> req( 3452 scoped_ptr<SpdyFrame> req(
3456 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); 3453 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false));
3457 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)}; 3454 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)};
3458 3455
3459 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); 3456 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3499 // Verifies that a session which races and wins against the owning transaction 3496 // Verifies that a session which races and wins against the owning transaction
3500 // (completing prior to host resolution), doesn't fail the transaction. 3497 // (completing prior to host resolution), doesn't fail the transaction.
3501 // Regression test for crbug.com/334413. 3498 // Regression test for crbug.com/334413.
3502 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyGetWithSessionRace) { 3499 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyGetWithSessionRace) {
3503 HttpRequestInfo request; 3500 HttpRequestInfo request;
3504 request.method = "GET"; 3501 request.method = "GET";
3505 request.url = GURL("http://www.example.org/"); 3502 request.url = GURL("http://www.example.org/");
3506 request.load_flags = 0; 3503 request.load_flags = 0;
3507 3504
3508 // Configure SPDY proxy server "proxy:70". 3505 // Configure SPDY proxy server "proxy:70".
3509 session_deps_.proxy_service.reset( 3506 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
3510 ProxyService::CreateFixed("https://proxy:70"));
3511 BoundTestNetLog log; 3507 BoundTestNetLog log;
3512 session_deps_.net_log = log.bound().net_log(); 3508 session_deps_.net_log = log.bound().net_log();
3513 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3509 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3514 3510
3515 // Fetch http://www.example.org/ through the SPDY proxy. 3511 // Fetch http://www.example.org/ through the SPDY proxy.
3516 scoped_ptr<SpdyFrame> req( 3512 scoped_ptr<SpdyFrame> req(
3517 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); 3513 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false));
3518 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)}; 3514 MockWrite spdy_writes[] = {CreateMockWrite(*req, 0)};
3519 3515
3520 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); 3516 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3569 } 3565 }
3570 3566
3571 // Test a SPDY get through an HTTPS Proxy. 3567 // Test a SPDY get through an HTTPS Proxy.
3572 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyGetWithProxyAuth) { 3568 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyGetWithProxyAuth) {
3573 HttpRequestInfo request; 3569 HttpRequestInfo request;
3574 request.method = "GET"; 3570 request.method = "GET";
3575 request.url = GURL("http://www.example.org/"); 3571 request.url = GURL("http://www.example.org/");
3576 request.load_flags = 0; 3572 request.load_flags = 0;
3577 3573
3578 // Configure against https proxy server "myproxy:70". 3574 // Configure against https proxy server "myproxy:70".
3579 session_deps_.proxy_service.reset( 3575 session_deps_.proxy_service = ProxyService::CreateFixed("https://myproxy:70");
3580 ProxyService::CreateFixed("https://myproxy:70"));
3581 BoundTestNetLog log; 3576 BoundTestNetLog log;
3582 session_deps_.net_log = log.bound().net_log(); 3577 session_deps_.net_log = log.bound().net_log();
3583 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3578 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3584 3579
3585 // The first request will be a bare GET, the second request will be a 3580 // The first request will be a bare GET, the second request will be a
3586 // GET with a Proxy-Authorization header. 3581 // GET with a Proxy-Authorization header.
3587 scoped_ptr<SpdyFrame> req_get( 3582 scoped_ptr<SpdyFrame> req_get(
3588 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); 3583 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false));
3589 const char* const kExtraAuthorizationHeaders[] = { 3584 const char* const kExtraAuthorizationHeaders[] = {
3590 "proxy-authorization", "Basic Zm9vOmJhcg==" 3585 "proxy-authorization", "Basic Zm9vOmJhcg=="
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3670 } 3665 }
3671 3666
3672 // Test a SPDY CONNECT through an HTTPS Proxy to an HTTPS (non-SPDY) Server. 3667 // Test a SPDY CONNECT through an HTTPS Proxy to an HTTPS (non-SPDY) Server.
3673 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyConnectHttps) { 3668 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyConnectHttps) {
3674 HttpRequestInfo request; 3669 HttpRequestInfo request;
3675 request.method = "GET"; 3670 request.method = "GET";
3676 request.url = GURL("https://www.example.org/"); 3671 request.url = GURL("https://www.example.org/");
3677 request.load_flags = 0; 3672 request.load_flags = 0;
3678 3673
3679 // Configure against https proxy server "proxy:70". 3674 // Configure against https proxy server "proxy:70".
3680 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 3675 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
3681 "https://proxy:70"));
3682 BoundTestNetLog log; 3676 BoundTestNetLog log;
3683 session_deps_.net_log = log.bound().net_log(); 3677 session_deps_.net_log = log.bound().net_log();
3684 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3678 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3685 3679
3686 scoped_ptr<HttpTransaction> trans( 3680 scoped_ptr<HttpTransaction> trans(
3687 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 3681 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
3688 3682
3689 // CONNECT to www.example.org:443 via SPDY 3683 // CONNECT to www.example.org:443 via SPDY
3690 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect( 3684 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(
3691 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); 3685 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3755 } 3749 }
3756 3750
3757 // Test a SPDY CONNECT through an HTTPS Proxy to a SPDY server. 3751 // Test a SPDY CONNECT through an HTTPS Proxy to a SPDY server.
3758 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyConnectSpdy) { 3752 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyConnectSpdy) {
3759 HttpRequestInfo request; 3753 HttpRequestInfo request;
3760 request.method = "GET"; 3754 request.method = "GET";
3761 request.url = GURL("https://www.example.org/"); 3755 request.url = GURL("https://www.example.org/");
3762 request.load_flags = 0; 3756 request.load_flags = 0;
3763 3757
3764 // Configure against https proxy server "proxy:70". 3758 // Configure against https proxy server "proxy:70".
3765 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 3759 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
3766 "https://proxy:70"));
3767 BoundTestNetLog log; 3760 BoundTestNetLog log;
3768 session_deps_.net_log = log.bound().net_log(); 3761 session_deps_.net_log = log.bound().net_log();
3769 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3762 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3770 3763
3771 scoped_ptr<HttpTransaction> trans( 3764 scoped_ptr<HttpTransaction> trans(
3772 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 3765 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
3773 3766
3774 // CONNECT to www.example.org:443 via SPDY 3767 // CONNECT to www.example.org:443 via SPDY
3775 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect( 3768 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(
3776 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); 3769 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3847 } 3840 }
3848 3841
3849 // Test a SPDY CONNECT failure through an HTTPS Proxy. 3842 // Test a SPDY CONNECT failure through an HTTPS Proxy.
3850 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyConnectFailure) { 3843 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyConnectFailure) {
3851 HttpRequestInfo request; 3844 HttpRequestInfo request;
3852 request.method = "GET"; 3845 request.method = "GET";
3853 request.url = GURL("https://www.example.org/"); 3846 request.url = GURL("https://www.example.org/");
3854 request.load_flags = 0; 3847 request.load_flags = 0;
3855 3848
3856 // Configure against https proxy server "proxy:70". 3849 // Configure against https proxy server "proxy:70".
3857 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 3850 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
3858 "https://proxy:70"));
3859 BoundTestNetLog log; 3851 BoundTestNetLog log;
3860 session_deps_.net_log = log.bound().net_log(); 3852 session_deps_.net_log = log.bound().net_log();
3861 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 3853 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3862 3854
3863 scoped_ptr<HttpTransaction> trans( 3855 scoped_ptr<HttpTransaction> trans(
3864 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 3856 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
3865 3857
3866 // CONNECT to www.example.org:443 via SPDY 3858 // CONNECT to www.example.org:443 via SPDY
3867 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect( 3859 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(
3868 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); 3860 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
(...skipping 30 matching lines...) Expand all
3899 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); 3891 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv);
3900 3892
3901 // TODO(ttuttle): Anything else to check here? 3893 // TODO(ttuttle): Anything else to check here?
3902 } 3894 }
3903 3895
3904 // Test load timing in the case of two HTTPS (non-SPDY) requests through a SPDY 3896 // Test load timing in the case of two HTTPS (non-SPDY) requests through a SPDY
3905 // HTTPS Proxy to different servers. 3897 // HTTPS Proxy to different servers.
3906 TEST_P(HttpNetworkTransactionTest, 3898 TEST_P(HttpNetworkTransactionTest,
3907 HttpsProxySpdyConnectHttpsLoadTimingTwoRequestsTwoServers) { 3899 HttpsProxySpdyConnectHttpsLoadTimingTwoRequestsTwoServers) {
3908 // Configure against https proxy server "proxy:70". 3900 // Configure against https proxy server "proxy:70".
3909 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 3901 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
3910 "https://proxy:70"));
3911 BoundTestNetLog log; 3902 BoundTestNetLog log;
3912 session_deps_.net_log = log.bound().net_log(); 3903 session_deps_.net_log = log.bound().net_log();
3913 scoped_refptr<HttpNetworkSession> session( 3904 scoped_refptr<HttpNetworkSession> session(
3914 SpdySessionDependencies::SpdyCreateSession(&session_deps_)); 3905 SpdySessionDependencies::SpdyCreateSession(&session_deps_));
3915 3906
3916 HttpRequestInfo request1; 3907 HttpRequestInfo request1;
3917 request1.method = "GET"; 3908 request1.method = "GET";
3918 request1.url = GURL("https://www.example.org/"); 3909 request1.url = GURL("https://www.example.org/");
3919 request1.load_flags = 0; 3910 request1.load_flags = 0;
3920 3911
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
4042 4033
4043 rv = trans2->Read(buf.get(), 256, callback.callback()); 4034 rv = trans2->Read(buf.get(), 256, callback.callback());
4044 EXPECT_EQ(2, callback.GetResult(rv)); 4035 EXPECT_EQ(2, callback.GetResult(rv));
4045 } 4036 }
4046 4037
4047 // Test load timing in the case of two HTTPS (non-SPDY) requests through a SPDY 4038 // Test load timing in the case of two HTTPS (non-SPDY) requests through a SPDY
4048 // HTTPS Proxy to the same server. 4039 // HTTPS Proxy to the same server.
4049 TEST_P(HttpNetworkTransactionTest, 4040 TEST_P(HttpNetworkTransactionTest,
4050 HttpsProxySpdyConnectHttpsLoadTimingTwoRequestsSameServer) { 4041 HttpsProxySpdyConnectHttpsLoadTimingTwoRequestsSameServer) {
4051 // Configure against https proxy server "proxy:70". 4042 // Configure against https proxy server "proxy:70".
4052 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 4043 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
4053 "https://proxy:70"));
4054 BoundTestNetLog log; 4044 BoundTestNetLog log;
4055 session_deps_.net_log = log.bound().net_log(); 4045 session_deps_.net_log = log.bound().net_log();
4056 scoped_refptr<HttpNetworkSession> session( 4046 scoped_refptr<HttpNetworkSession> session(
4057 SpdySessionDependencies::SpdyCreateSession(&session_deps_)); 4047 SpdySessionDependencies::SpdyCreateSession(&session_deps_));
4058 4048
4059 HttpRequestInfo request1; 4049 HttpRequestInfo request1;
4060 request1.method = "GET"; 4050 request1.method = "GET";
4061 request1.url = GURL("https://www.example.org/"); 4051 request1.url = GURL("https://www.example.org/");
4062 request1.load_flags = 0; 4052 request1.load_flags = 0;
4063 4053
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
4166 // The requests should have the same ID. 4156 // The requests should have the same ID.
4167 EXPECT_EQ(load_timing_info.socket_log_id, load_timing_info2.socket_log_id); 4157 EXPECT_EQ(load_timing_info.socket_log_id, load_timing_info2.socket_log_id);
4168 4158
4169 EXPECT_EQ(2, trans2->Read(buf.get(), 256, callback.callback())); 4159 EXPECT_EQ(2, trans2->Read(buf.get(), 256, callback.callback()));
4170 } 4160 }
4171 4161
4172 // Test load timing in the case of of two HTTP requests through a SPDY HTTPS 4162 // Test load timing in the case of of two HTTP requests through a SPDY HTTPS
4173 // Proxy to different servers. 4163 // Proxy to different servers.
4174 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyLoadTimingTwoHttpRequests) { 4164 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyLoadTimingTwoHttpRequests) {
4175 // Configure against https proxy server "proxy:70". 4165 // Configure against https proxy server "proxy:70".
4176 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 4166 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
4177 "https://proxy:70"));
4178 BoundTestNetLog log; 4167 BoundTestNetLog log;
4179 session_deps_.net_log = log.bound().net_log(); 4168 session_deps_.net_log = log.bound().net_log();
4180 scoped_refptr<HttpNetworkSession> session( 4169 scoped_refptr<HttpNetworkSession> session(
4181 SpdySessionDependencies::SpdyCreateSession(&session_deps_)); 4170 SpdySessionDependencies::SpdyCreateSession(&session_deps_));
4182 4171
4183 HttpRequestInfo request1; 4172 HttpRequestInfo request1;
4184 request1.method = "GET"; 4173 request1.method = "GET";
4185 request1.url = GURL("http://www.example.org/"); 4174 request1.url = GURL("http://www.example.org/");
4186 request1.load_flags = 0; 4175 request1.load_flags = 0;
4187 4176
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
4273 4262
4274 // Test the challenge-response-retry sequence through an HTTPS Proxy 4263 // Test the challenge-response-retry sequence through an HTTPS Proxy
4275 TEST_P(HttpNetworkTransactionTest, HttpsProxyAuthRetry) { 4264 TEST_P(HttpNetworkTransactionTest, HttpsProxyAuthRetry) {
4276 HttpRequestInfo request; 4265 HttpRequestInfo request;
4277 request.method = "GET"; 4266 request.method = "GET";
4278 request.url = GURL("http://www.example.org/"); 4267 request.url = GURL("http://www.example.org/");
4279 // when the no authentication data flag is set. 4268 // when the no authentication data flag is set.
4280 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 4269 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
4281 4270
4282 // Configure against https proxy server "myproxy:70". 4271 // Configure against https proxy server "myproxy:70".
4283 session_deps_.proxy_service.reset( 4272 session_deps_.proxy_service = ProxyService::CreateFixed("https://myproxy:70");
4284 ProxyService::CreateFixed("https://myproxy:70"));
4285 BoundTestNetLog log; 4273 BoundTestNetLog log;
4286 session_deps_.net_log = log.bound().net_log(); 4274 session_deps_.net_log = log.bound().net_log();
4287 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 4275 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
4288 4276
4289 // Since we have proxy, should use full url 4277 // Since we have proxy, should use full url
4290 MockWrite data_writes1[] = { 4278 MockWrite data_writes1[] = {
4291 MockWrite( 4279 MockWrite(
4292 "GET http://www.example.org/ HTTP/1.1\r\n" 4280 "GET http://www.example.org/ HTTP/1.1\r\n"
4293 "Host: www.example.org\r\n" 4281 "Host: www.example.org\r\n"
4294 "Proxy-Connection: keep-alive\r\n\r\n"), 4282 "Proxy-Connection: keep-alive\r\n\r\n"),
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
4373 } 4361 }
4374 4362
4375 void HttpNetworkTransactionTest::ConnectStatusHelperWithExpectedStatus( 4363 void HttpNetworkTransactionTest::ConnectStatusHelperWithExpectedStatus(
4376 const MockRead& status, int expected_status) { 4364 const MockRead& status, int expected_status) {
4377 HttpRequestInfo request; 4365 HttpRequestInfo request;
4378 request.method = "GET"; 4366 request.method = "GET";
4379 request.url = GURL("https://www.example.org/"); 4367 request.url = GURL("https://www.example.org/");
4380 request.load_flags = 0; 4368 request.load_flags = 0;
4381 4369
4382 // Configure against proxy server "myproxy:70". 4370 // Configure against proxy server "myproxy:70".
4383 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 4371 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70");
4384 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 4372 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
4385 4373
4386 // Since we have proxy, should try to establish tunnel. 4374 // Since we have proxy, should try to establish tunnel.
4387 MockWrite data_writes[] = { 4375 MockWrite data_writes[] = {
4388 MockWrite( 4376 MockWrite(
4389 "CONNECT www.example.org:443 HTTP/1.1\r\n" 4377 "CONNECT www.example.org:443 HTTP/1.1\r\n"
4390 "Host: www.example.org\r\n" 4378 "Host: www.example.org\r\n"
4391 "Proxy-Connection: keep-alive\r\n\r\n"), 4379 "Proxy-Connection: keep-alive\r\n\r\n"),
4392 }; 4380 };
4393 4381
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
4591 // Test the flow when both the proxy server AND origin server require 4579 // Test the flow when both the proxy server AND origin server require
4592 // authentication. Again, this uses basic auth for both since that is 4580 // authentication. Again, this uses basic auth for both since that is
4593 // the simplest to mock. 4581 // the simplest to mock.
4594 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyThenServer) { 4582 TEST_P(HttpNetworkTransactionTest, BasicAuthProxyThenServer) {
4595 HttpRequestInfo request; 4583 HttpRequestInfo request;
4596 request.method = "GET"; 4584 request.method = "GET";
4597 request.url = GURL("http://www.example.org/"); 4585 request.url = GURL("http://www.example.org/");
4598 request.load_flags = 0; 4586 request.load_flags = 0;
4599 4587
4600 // Configure against proxy server "myproxy:70". 4588 // Configure against proxy server "myproxy:70".
4601 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 4589 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70");
4602 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 4590 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
4603 4591
4604 scoped_ptr<HttpTransaction> trans( 4592 scoped_ptr<HttpTransaction> trans(
4605 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 4593 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
4606 4594
4607 MockWrite data_writes1[] = { 4595 MockWrite data_writes1[] = {
4608 MockWrite( 4596 MockWrite(
4609 "GET http://www.example.org/ HTTP/1.1\r\n" 4597 "GET http://www.example.org/ HTTP/1.1\r\n"
4610 "Host: www.example.org\r\n" 4598 "Host: www.example.org\r\n"
4611 "Proxy-Connection: keep-alive\r\n\r\n"), 4599 "Proxy-Connection: keep-alive\r\n\r\n"),
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
5094 // establish tunnel. 5082 // establish tunnel.
5095 // http://code.google.com/p/chromium/issues/detail?id=3772 5083 // http://code.google.com/p/chromium/issues/detail?id=3772
5096 TEST_P(HttpNetworkTransactionTest, 5084 TEST_P(HttpNetworkTransactionTest,
5097 DontRecycleTransportSocketForSSLTunnel) { 5085 DontRecycleTransportSocketForSSLTunnel) {
5098 HttpRequestInfo request; 5086 HttpRequestInfo request;
5099 request.method = "GET"; 5087 request.method = "GET";
5100 request.url = GURL("https://www.example.org/"); 5088 request.url = GURL("https://www.example.org/");
5101 request.load_flags = 0; 5089 request.load_flags = 0;
5102 5090
5103 // Configure against proxy server "myproxy:70". 5091 // Configure against proxy server "myproxy:70".
5104 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 5092 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70");
5105 5093
5106 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 5094 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
5107 5095
5108 scoped_ptr<HttpTransaction> trans( 5096 scoped_ptr<HttpTransaction> trans(
5109 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 5097 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
5110 5098
5111 // Since we have proxy, should try to establish tunnel. 5099 // Since we have proxy, should try to establish tunnel.
5112 MockWrite data_writes1[] = { 5100 MockWrite data_writes1[] = {
5113 MockWrite( 5101 MockWrite(
5114 "CONNECT www.example.org:443 HTTP/1.1\r\n" 5102 "CONNECT www.example.org:443 HTTP/1.1\r\n"
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
6410 6398
6411 const HttpResponseInfo* response = trans->GetResponseInfo(); 6399 const HttpResponseInfo* response = trans->GetResponseInfo();
6412 6400
6413 ASSERT_TRUE(response != NULL); 6401 ASSERT_TRUE(response != NULL);
6414 EXPECT_EQ(100, response->headers->GetContentLength()); 6402 EXPECT_EQ(100, response->headers->GetContentLength());
6415 } 6403 }
6416 6404
6417 // Test HTTPS connections to a site with a bad certificate, going through a 6405 // Test HTTPS connections to a site with a bad certificate, going through a
6418 // proxy 6406 // proxy
6419 TEST_P(HttpNetworkTransactionTest, HTTPSBadCertificateViaProxy) { 6407 TEST_P(HttpNetworkTransactionTest, HTTPSBadCertificateViaProxy) {
6420 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 6408 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70");
6421 6409
6422 HttpRequestInfo request; 6410 HttpRequestInfo request;
6423 request.method = "GET"; 6411 request.method = "GET";
6424 request.url = GURL("https://www.example.org/"); 6412 request.url = GURL("https://www.example.org/");
6425 request.load_flags = 0; 6413 request.load_flags = 0;
6426 6414
6427 MockWrite proxy_writes[] = { 6415 MockWrite proxy_writes[] = {
6428 MockWrite( 6416 MockWrite(
6429 "CONNECT www.example.org:443 HTTP/1.1\r\n" 6417 "CONNECT www.example.org:443 HTTP/1.1\r\n"
6430 "Host: www.example.org\r\n" 6418 "Host: www.example.org\r\n"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
6492 const HttpResponseInfo* response = trans->GetResponseInfo(); 6480 const HttpResponseInfo* response = trans->GetResponseInfo();
6493 6481
6494 ASSERT_TRUE(response != NULL); 6482 ASSERT_TRUE(response != NULL);
6495 EXPECT_EQ(100, response->headers->GetContentLength()); 6483 EXPECT_EQ(100, response->headers->GetContentLength());
6496 } 6484 }
6497 } 6485 }
6498 6486
6499 6487
6500 // Test HTTPS connections to a site, going through an HTTPS proxy 6488 // Test HTTPS connections to a site, going through an HTTPS proxy
6501 TEST_P(HttpNetworkTransactionTest, HTTPSViaHttpsProxy) { 6489 TEST_P(HttpNetworkTransactionTest, HTTPSViaHttpsProxy) {
6502 session_deps_.proxy_service.reset( 6490 session_deps_.proxy_service =
6503 ProxyService::CreateFixedFromPacResult("HTTPS proxy:70")); 6491 ProxyService::CreateFixedFromPacResult("HTTPS proxy:70");
6504 TestNetLog net_log; 6492 TestNetLog net_log;
6505 session_deps_.net_log = &net_log; 6493 session_deps_.net_log = &net_log;
6506 6494
6507 HttpRequestInfo request; 6495 HttpRequestInfo request;
6508 request.method = "GET"; 6496 request.method = "GET";
6509 request.url = GURL("https://www.example.org/"); 6497 request.url = GURL("https://www.example.org/");
6510 request.load_flags = 0; 6498 request.load_flags = 0;
6511 6499
6512 MockWrite data_writes[] = { 6500 MockWrite data_writes[] = {
6513 MockWrite( 6501 MockWrite(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
6558 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); 6546 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion());
6559 6547
6560 LoadTimingInfo load_timing_info; 6548 LoadTimingInfo load_timing_info;
6561 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); 6549 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info));
6562 TestLoadTimingNotReusedWithPac(load_timing_info, 6550 TestLoadTimingNotReusedWithPac(load_timing_info,
6563 CONNECT_TIMING_HAS_SSL_TIMES); 6551 CONNECT_TIMING_HAS_SSL_TIMES);
6564 } 6552 }
6565 6553
6566 // Test an HTTPS Proxy's ability to redirect a CONNECT request 6554 // Test an HTTPS Proxy's ability to redirect a CONNECT request
6567 TEST_P(HttpNetworkTransactionTest, RedirectOfHttpsConnectViaHttpsProxy) { 6555 TEST_P(HttpNetworkTransactionTest, RedirectOfHttpsConnectViaHttpsProxy) {
6568 session_deps_.proxy_service.reset( 6556 session_deps_.proxy_service =
6569 ProxyService::CreateFixedFromPacResult("HTTPS proxy:70")); 6557 ProxyService::CreateFixedFromPacResult("HTTPS proxy:70");
6570 TestNetLog net_log; 6558 TestNetLog net_log;
6571 session_deps_.net_log = &net_log; 6559 session_deps_.net_log = &net_log;
6572 6560
6573 HttpRequestInfo request; 6561 HttpRequestInfo request;
6574 request.method = "GET"; 6562 request.method = "GET";
6575 request.url = GURL("https://www.example.org/"); 6563 request.url = GURL("https://www.example.org/");
6576 request.load_flags = 0; 6564 request.load_flags = 0;
6577 6565
6578 MockWrite data_writes[] = { 6566 MockWrite data_writes[] = {
6579 MockWrite( 6567 MockWrite(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
6635 load_timing_info.connect_timing, 6623 load_timing_info.connect_timing,
6636 CONNECT_TIMING_HAS_DNS_TIMES | CONNECT_TIMING_HAS_SSL_TIMES); 6624 CONNECT_TIMING_HAS_DNS_TIMES | CONNECT_TIMING_HAS_SSL_TIMES);
6637 6625
6638 EXPECT_TRUE(load_timing_info.send_start.is_null()); 6626 EXPECT_TRUE(load_timing_info.send_start.is_null());
6639 EXPECT_TRUE(load_timing_info.send_end.is_null()); 6627 EXPECT_TRUE(load_timing_info.send_end.is_null());
6640 EXPECT_TRUE(load_timing_info.receive_headers_end.is_null()); 6628 EXPECT_TRUE(load_timing_info.receive_headers_end.is_null());
6641 } 6629 }
6642 6630
6643 // Test an HTTPS (SPDY) Proxy's ability to redirect a CONNECT request 6631 // Test an HTTPS (SPDY) Proxy's ability to redirect a CONNECT request
6644 TEST_P(HttpNetworkTransactionTest, RedirectOfHttpsConnectViaSpdyProxy) { 6632 TEST_P(HttpNetworkTransactionTest, RedirectOfHttpsConnectViaSpdyProxy) {
6645 session_deps_.proxy_service.reset( 6633 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
6646 ProxyService::CreateFixed("https://proxy:70"));
6647 6634
6648 HttpRequestInfo request; 6635 HttpRequestInfo request;
6649 request.method = "GET"; 6636 request.method = "GET";
6650 request.url = GURL("https://www.example.org/"); 6637 request.url = GURL("https://www.example.org/");
6651 request.load_flags = 0; 6638 request.load_flags = 0;
6652 6639
6653 scoped_ptr<SpdyFrame> conn(spdy_util_.ConstructSpdyConnect( 6640 scoped_ptr<SpdyFrame> conn(spdy_util_.ConstructSpdyConnect(
6654 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); 6641 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
6655 scoped_ptr<SpdyFrame> goaway( 6642 scoped_ptr<SpdyFrame> goaway(
6656 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); 6643 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
6695 6682
6696 EXPECT_EQ(302, response->headers->response_code()); 6683 EXPECT_EQ(302, response->headers->response_code());
6697 std::string url; 6684 std::string url;
6698 EXPECT_TRUE(response->headers->IsRedirect(&url)); 6685 EXPECT_TRUE(response->headers->IsRedirect(&url));
6699 EXPECT_EQ("http://login.example.com/", url); 6686 EXPECT_EQ("http://login.example.com/", url);
6700 } 6687 }
6701 6688
6702 // Test that an HTTPS proxy's response to a CONNECT request is filtered. 6689 // Test that an HTTPS proxy's response to a CONNECT request is filtered.
6703 TEST_P(HttpNetworkTransactionTest, 6690 TEST_P(HttpNetworkTransactionTest,
6704 ErrorResponseToHttpsConnectViaHttpsProxy) { 6691 ErrorResponseToHttpsConnectViaHttpsProxy) {
6705 session_deps_.proxy_service.reset( 6692 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
6706 ProxyService::CreateFixed("https://proxy:70"));
6707 6693
6708 HttpRequestInfo request; 6694 HttpRequestInfo request;
6709 request.method = "GET"; 6695 request.method = "GET";
6710 request.url = GURL("https://www.example.org/"); 6696 request.url = GURL("https://www.example.org/");
6711 request.load_flags = 0; 6697 request.load_flags = 0;
6712 6698
6713 MockWrite data_writes[] = { 6699 MockWrite data_writes[] = {
6714 MockWrite( 6700 MockWrite(
6715 "CONNECT www.example.org:443 HTTP/1.1\r\n" 6701 "CONNECT www.example.org:443 HTTP/1.1\r\n"
6716 "Host: www.example.org\r\n" 6702 "Host: www.example.org\r\n"
(...skipping 25 matching lines...) Expand all
6742 6728
6743 rv = callback.WaitForResult(); 6729 rv = callback.WaitForResult();
6744 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); 6730 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv);
6745 6731
6746 // TODO(ttuttle): Anything else to check here? 6732 // TODO(ttuttle): Anything else to check here?
6747 } 6733 }
6748 6734
6749 // Test that a SPDY proxy's response to a CONNECT request is filtered. 6735 // Test that a SPDY proxy's response to a CONNECT request is filtered.
6750 TEST_P(HttpNetworkTransactionTest, 6736 TEST_P(HttpNetworkTransactionTest,
6751 ErrorResponseToHttpsConnectViaSpdyProxy) { 6737 ErrorResponseToHttpsConnectViaSpdyProxy) {
6752 session_deps_.proxy_service.reset( 6738 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
6753 ProxyService::CreateFixed("https://proxy:70"));
6754 6739
6755 HttpRequestInfo request; 6740 HttpRequestInfo request;
6756 request.method = "GET"; 6741 request.method = "GET";
6757 request.url = GURL("https://www.example.org/"); 6742 request.url = GURL("https://www.example.org/");
6758 request.load_flags = 0; 6743 request.load_flags = 0;
6759 6744
6760 scoped_ptr<SpdyFrame> conn(spdy_util_.ConstructSpdyConnect( 6745 scoped_ptr<SpdyFrame> conn(spdy_util_.ConstructSpdyConnect(
6761 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); 6746 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
6762 scoped_ptr<SpdyFrame> rst( 6747 scoped_ptr<SpdyFrame> rst(
6763 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); 6748 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
6807 // Test the request-challenge-retry sequence for basic auth, through 6792 // Test the request-challenge-retry sequence for basic auth, through
6808 // a SPDY proxy over a single SPDY session. 6793 // a SPDY proxy over a single SPDY session.
6809 TEST_P(HttpNetworkTransactionTest, BasicAuthSpdyProxy) { 6794 TEST_P(HttpNetworkTransactionTest, BasicAuthSpdyProxy) {
6810 HttpRequestInfo request; 6795 HttpRequestInfo request;
6811 request.method = "GET"; 6796 request.method = "GET";
6812 request.url = GURL("https://www.example.org/"); 6797 request.url = GURL("https://www.example.org/");
6813 // when the no authentication data flag is set. 6798 // when the no authentication data flag is set.
6814 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA; 6799 request.load_flags = LOAD_DO_NOT_SEND_AUTH_DATA;
6815 6800
6816 // Configure against https proxy server "myproxy:70". 6801 // Configure against https proxy server "myproxy:70".
6817 session_deps_.proxy_service.reset( 6802 session_deps_.proxy_service =
6818 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70")); 6803 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70");
6819 BoundTestNetLog log; 6804 BoundTestNetLog log;
6820 session_deps_.net_log = log.bound().net_log(); 6805 session_deps_.net_log = log.bound().net_log();
6821 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 6806 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6822 6807
6823 // Since we have proxy, should try to establish tunnel. 6808 // Since we have proxy, should try to establish tunnel.
6824 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyConnect( 6809 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyConnect(
6825 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443))); 6810 NULL, 0, 1, LOWEST, HostPortPair("www.example.org", 443)));
6826 scoped_ptr<SpdyFrame> rst( 6811 scoped_ptr<SpdyFrame> rst(
6827 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); 6812 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL));
6828 6813
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
6948 TEST_P(HttpNetworkTransactionTest, CrossOriginProxyPush) { 6933 TEST_P(HttpNetworkTransactionTest, CrossOriginProxyPush) {
6949 HttpRequestInfo request; 6934 HttpRequestInfo request;
6950 HttpRequestInfo push_request; 6935 HttpRequestInfo push_request;
6951 6936
6952 request.method = "GET"; 6937 request.method = "GET";
6953 request.url = GURL("http://www.example.org/"); 6938 request.url = GURL("http://www.example.org/");
6954 push_request.method = "GET"; 6939 push_request.method = "GET";
6955 push_request.url = GURL("http://www.another-origin.com/foo.dat"); 6940 push_request.url = GURL("http://www.another-origin.com/foo.dat");
6956 6941
6957 // Configure against https proxy server "myproxy:70". 6942 // Configure against https proxy server "myproxy:70".
6958 session_deps_.proxy_service.reset( 6943 session_deps_.proxy_service =
6959 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70")); 6944 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70");
6960 BoundTestNetLog log; 6945 BoundTestNetLog log;
6961 session_deps_.net_log = log.bound().net_log(); 6946 session_deps_.net_log = log.bound().net_log();
6962 6947
6963 // Enable cross-origin push. 6948 // Enable cross-origin push.
6964 session_deps_.trusted_spdy_proxy = "myproxy:70"; 6949 session_deps_.trusted_spdy_proxy = "myproxy:70";
6965 6950
6966 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 6951 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
6967 6952
6968 scoped_ptr<SpdyFrame> stream1_syn( 6953 scoped_ptr<SpdyFrame> stream1_syn(
6969 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); 6954 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false));
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
7062 } 7047 }
7063 7048
7064 // Test that an explicitly trusted SPDY proxy cannot push HTTPS content. 7049 // Test that an explicitly trusted SPDY proxy cannot push HTTPS content.
7065 TEST_P(HttpNetworkTransactionTest, CrossOriginProxyPushCorrectness) { 7050 TEST_P(HttpNetworkTransactionTest, CrossOriginProxyPushCorrectness) {
7066 HttpRequestInfo request; 7051 HttpRequestInfo request;
7067 7052
7068 request.method = "GET"; 7053 request.method = "GET";
7069 request.url = GURL("http://www.example.org/"); 7054 request.url = GURL("http://www.example.org/");
7070 7055
7071 // Configure against https proxy server "myproxy:70". 7056 // Configure against https proxy server "myproxy:70".
7072 session_deps_.proxy_service.reset( 7057 session_deps_.proxy_service = ProxyService::CreateFixed("https://myproxy:70");
7073 ProxyService::CreateFixed("https://myproxy:70"));
7074 BoundTestNetLog log; 7058 BoundTestNetLog log;
7075 session_deps_.net_log = log.bound().net_log(); 7059 session_deps_.net_log = log.bound().net_log();
7076 7060
7077 // Enable cross-origin push. 7061 // Enable cross-origin push.
7078 session_deps_.trusted_spdy_proxy = "myproxy:70"; 7062 session_deps_.trusted_spdy_proxy = "myproxy:70";
7079 7063
7080 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7064 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7081 7065
7082 scoped_ptr<SpdyFrame> stream1_syn( 7066 scoped_ptr<SpdyFrame> stream1_syn(
7083 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); 7067 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
7138 EXPECT_EQ(OK, rv); 7122 EXPECT_EQ(OK, rv);
7139 EXPECT_EQ("hello!", response_data); 7123 EXPECT_EQ("hello!", response_data);
7140 7124
7141 trans.reset(); 7125 trans.reset();
7142 session->CloseAllConnections(); 7126 session->CloseAllConnections();
7143 } 7127 }
7144 7128
7145 // Test HTTPS connections to a site with a bad certificate, going through an 7129 // Test HTTPS connections to a site with a bad certificate, going through an
7146 // HTTPS proxy 7130 // HTTPS proxy
7147 TEST_P(HttpNetworkTransactionTest, HTTPSBadCertificateViaHttpsProxy) { 7131 TEST_P(HttpNetworkTransactionTest, HTTPSBadCertificateViaHttpsProxy) {
7148 session_deps_.proxy_service.reset(ProxyService::CreateFixed( 7132 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
7149 "https://proxy:70"));
7150 7133
7151 HttpRequestInfo request; 7134 HttpRequestInfo request;
7152 request.method = "GET"; 7135 request.method = "GET";
7153 request.url = GURL("https://www.example.org/"); 7136 request.url = GURL("https://www.example.org/");
7154 request.load_flags = 0; 7137 request.load_flags = 0;
7155 7138
7156 // Attempt to fetch the URL from a server with a bad cert 7139 // Attempt to fetch the URL from a server with a bad cert
7157 MockWrite bad_cert_writes[] = { 7140 MockWrite bad_cert_writes[] = {
7158 MockWrite( 7141 MockWrite(
7159 "CONNECT www.example.org:443 HTTP/1.1\r\n" 7142 "CONNECT www.example.org:443 HTTP/1.1\r\n"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
7268 EXPECT_EQ(OK, rv); 7251 EXPECT_EQ(OK, rv);
7269 } 7252 }
7270 7253
7271 TEST_P(HttpNetworkTransactionTest, BuildRequest_UserAgentOverTunnel) { 7254 TEST_P(HttpNetworkTransactionTest, BuildRequest_UserAgentOverTunnel) {
7272 HttpRequestInfo request; 7255 HttpRequestInfo request;
7273 request.method = "GET"; 7256 request.method = "GET";
7274 request.url = GURL("https://www.example.org/"); 7257 request.url = GURL("https://www.example.org/");
7275 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, 7258 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent,
7276 "Chromium Ultra Awesome X Edition"); 7259 "Chromium Ultra Awesome X Edition");
7277 7260
7278 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 7261 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70");
7279 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7262 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7280 scoped_ptr<HttpTransaction> trans( 7263 scoped_ptr<HttpTransaction> trans(
7281 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7264 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7282 7265
7283 MockWrite data_writes[] = { 7266 MockWrite data_writes[] = {
7284 MockWrite( 7267 MockWrite(
7285 "CONNECT www.example.org:443 HTTP/1.1\r\n" 7268 "CONNECT www.example.org:443 HTTP/1.1\r\n"
7286 "Host: www.example.org\r\n" 7269 "Host: www.example.org\r\n"
7287 "Proxy-Connection: keep-alive\r\n" 7270 "Proxy-Connection: keep-alive\r\n"
7288 "User-Agent: Chromium Ultra Awesome X Edition\r\n\r\n"), 7271 "User-Agent: Chromium Ultra Awesome X Edition\r\n\r\n"),
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
7622 rv = callback.WaitForResult(); 7605 rv = callback.WaitForResult();
7623 EXPECT_EQ(OK, rv); 7606 EXPECT_EQ(OK, rv);
7624 } 7607 }
7625 7608
7626 TEST_P(HttpNetworkTransactionTest, SOCKS4_HTTP_GET) { 7609 TEST_P(HttpNetworkTransactionTest, SOCKS4_HTTP_GET) {
7627 HttpRequestInfo request; 7610 HttpRequestInfo request;
7628 request.method = "GET"; 7611 request.method = "GET";
7629 request.url = GURL("http://www.example.org/"); 7612 request.url = GURL("http://www.example.org/");
7630 request.load_flags = 0; 7613 request.load_flags = 0;
7631 7614
7632 session_deps_.proxy_service.reset( 7615 session_deps_.proxy_service =
7633 ProxyService::CreateFixedFromPacResult("SOCKS myproxy:1080")); 7616 ProxyService::CreateFixedFromPacResult("SOCKS myproxy:1080");
7634 TestNetLog net_log; 7617 TestNetLog net_log;
7635 session_deps_.net_log = &net_log; 7618 session_deps_.net_log = &net_log;
7636 7619
7637 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7620 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7638 scoped_ptr<HttpTransaction> trans( 7621 scoped_ptr<HttpTransaction> trans(
7639 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7622 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7640 7623
7641 char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 }; 7624 char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 };
7642 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; 7625 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 };
7643 7626
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
7681 EXPECT_EQ(OK, rv); 7664 EXPECT_EQ(OK, rv);
7682 EXPECT_EQ("Payload", response_text); 7665 EXPECT_EQ("Payload", response_text);
7683 } 7666 }
7684 7667
7685 TEST_P(HttpNetworkTransactionTest, SOCKS4_SSL_GET) { 7668 TEST_P(HttpNetworkTransactionTest, SOCKS4_SSL_GET) {
7686 HttpRequestInfo request; 7669 HttpRequestInfo request;
7687 request.method = "GET"; 7670 request.method = "GET";
7688 request.url = GURL("https://www.example.org/"); 7671 request.url = GURL("https://www.example.org/");
7689 request.load_flags = 0; 7672 request.load_flags = 0;
7690 7673
7691 session_deps_.proxy_service.reset( 7674 session_deps_.proxy_service =
7692 ProxyService::CreateFixedFromPacResult("SOCKS myproxy:1080")); 7675 ProxyService::CreateFixedFromPacResult("SOCKS myproxy:1080");
7693 TestNetLog net_log; 7676 TestNetLog net_log;
7694 session_deps_.net_log = &net_log; 7677 session_deps_.net_log = &net_log;
7695 7678
7696 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7679 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7697 scoped_ptr<HttpTransaction> trans( 7680 scoped_ptr<HttpTransaction> trans(
7698 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7681 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7699 7682
7700 unsigned char write_buffer[] = { 0x04, 0x01, 0x01, 0xBB, 127, 0, 0, 1, 0 }; 7683 unsigned char write_buffer[] = { 0x04, 0x01, 0x01, 0xBB, 127, 0, 0, 1, 0 };
7701 unsigned char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; 7684 unsigned char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 };
7702 7685
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
7745 EXPECT_EQ(OK, rv); 7728 EXPECT_EQ(OK, rv);
7746 EXPECT_EQ("Payload", response_text); 7729 EXPECT_EQ("Payload", response_text);
7747 } 7730 }
7748 7731
7749 TEST_P(HttpNetworkTransactionTest, SOCKS4_HTTP_GET_no_PAC) { 7732 TEST_P(HttpNetworkTransactionTest, SOCKS4_HTTP_GET_no_PAC) {
7750 HttpRequestInfo request; 7733 HttpRequestInfo request;
7751 request.method = "GET"; 7734 request.method = "GET";
7752 request.url = GURL("http://www.example.org/"); 7735 request.url = GURL("http://www.example.org/");
7753 request.load_flags = 0; 7736 request.load_flags = 0;
7754 7737
7755 session_deps_.proxy_service.reset( 7738 session_deps_.proxy_service =
7756 ProxyService::CreateFixed("socks4://myproxy:1080")); 7739 ProxyService::CreateFixed("socks4://myproxy:1080");
7757 TestNetLog net_log; 7740 TestNetLog net_log;
7758 session_deps_.net_log = &net_log; 7741 session_deps_.net_log = &net_log;
7759 7742
7760 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7743 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7761 scoped_ptr<HttpTransaction> trans( 7744 scoped_ptr<HttpTransaction> trans(
7762 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7745 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7763 7746
7764 char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 }; 7747 char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 };
7765 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; 7748 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 };
7766 7749
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
7804 EXPECT_EQ(OK, rv); 7787 EXPECT_EQ(OK, rv);
7805 EXPECT_EQ("Payload", response_text); 7788 EXPECT_EQ("Payload", response_text);
7806 } 7789 }
7807 7790
7808 TEST_P(HttpNetworkTransactionTest, SOCKS5_HTTP_GET) { 7791 TEST_P(HttpNetworkTransactionTest, SOCKS5_HTTP_GET) {
7809 HttpRequestInfo request; 7792 HttpRequestInfo request;
7810 request.method = "GET"; 7793 request.method = "GET";
7811 request.url = GURL("http://www.example.org/"); 7794 request.url = GURL("http://www.example.org/");
7812 request.load_flags = 0; 7795 request.load_flags = 0;
7813 7796
7814 session_deps_.proxy_service.reset( 7797 session_deps_.proxy_service =
7815 ProxyService::CreateFixedFromPacResult("SOCKS5 myproxy:1080")); 7798 ProxyService::CreateFixedFromPacResult("SOCKS5 myproxy:1080");
7816 TestNetLog net_log; 7799 TestNetLog net_log;
7817 session_deps_.net_log = &net_log; 7800 session_deps_.net_log = &net_log;
7818 7801
7819 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7802 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7820 scoped_ptr<HttpTransaction> trans( 7803 scoped_ptr<HttpTransaction> trans(
7821 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7804 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7822 7805
7823 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; 7806 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 };
7824 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; 7807 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 };
7825 const char kSOCKS5OkRequest[] = { 7808 const char kSOCKS5OkRequest[] = {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
7876 EXPECT_EQ(OK, rv); 7859 EXPECT_EQ(OK, rv);
7877 EXPECT_EQ("Payload", response_text); 7860 EXPECT_EQ("Payload", response_text);
7878 } 7861 }
7879 7862
7880 TEST_P(HttpNetworkTransactionTest, SOCKS5_SSL_GET) { 7863 TEST_P(HttpNetworkTransactionTest, SOCKS5_SSL_GET) {
7881 HttpRequestInfo request; 7864 HttpRequestInfo request;
7882 request.method = "GET"; 7865 request.method = "GET";
7883 request.url = GURL("https://www.example.org/"); 7866 request.url = GURL("https://www.example.org/");
7884 request.load_flags = 0; 7867 request.load_flags = 0;
7885 7868
7886 session_deps_.proxy_service.reset( 7869 session_deps_.proxy_service =
7887 ProxyService::CreateFixedFromPacResult("SOCKS5 myproxy:1080")); 7870 ProxyService::CreateFixedFromPacResult("SOCKS5 myproxy:1080");
7888 TestNetLog net_log; 7871 TestNetLog net_log;
7889 session_deps_.net_log = &net_log; 7872 session_deps_.net_log = &net_log;
7890 7873
7891 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 7874 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
7892 scoped_ptr<HttpTransaction> trans( 7875 scoped_ptr<HttpTransaction> trans(
7893 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 7876 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
7894 7877
7895 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; 7878 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 };
7896 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; 7879 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 };
7897 const unsigned char kSOCKS5OkRequest[] = { 7880 const unsigned char kSOCKS5OkRequest[] = {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
8033 "", // unused 8016 "", // unused
8034 "http://host.with.alternate/direct", 8017 "http://host.with.alternate/direct",
8035 "ssl/host.with.alternate:443", 8018 "ssl/host.with.alternate:443",
8036 true, 8019 true,
8037 }, 8020 },
8038 }; 8021 };
8039 8022
8040 session_deps_.use_alternative_services = true; 8023 session_deps_.use_alternative_services = true;
8041 8024
8042 for (size_t i = 0; i < arraysize(tests); ++i) { 8025 for (size_t i = 0; i < arraysize(tests); ++i) {
8043 session_deps_.proxy_service.reset( 8026 session_deps_.proxy_service =
8044 ProxyService::CreateFixed(tests[i].proxy_server)); 8027 ProxyService::CreateFixed(tests[i].proxy_server);
8045 scoped_refptr<HttpNetworkSession> session( 8028 scoped_refptr<HttpNetworkSession> session(
8046 SetupSessionForGroupNameTests(GetParam(), &session_deps_)); 8029 SetupSessionForGroupNameTests(GetParam(), &session_deps_));
8047 8030
8048 HttpNetworkSessionPeer peer(session); 8031 HttpNetworkSessionPeer peer(session);
8049 CaptureGroupNameTransportSocketPool* transport_conn_pool = 8032 CaptureGroupNameTransportSocketPool* transport_conn_pool =
8050 new CaptureGroupNameTransportSocketPool(NULL, NULL); 8033 new CaptureGroupNameTransportSocketPool(NULL, NULL);
8051 CaptureGroupNameSSLSocketPool* ssl_conn_pool = 8034 CaptureGroupNameSSLSocketPool* ssl_conn_pool =
8052 new CaptureGroupNameSSLSocketPool(NULL, NULL); 8035 new CaptureGroupNameSSLSocketPool(NULL, NULL);
8053 scoped_ptr<MockClientSocketPoolManager> mock_pool_manager( 8036 scoped_ptr<MockClientSocketPoolManager> mock_pool_manager(
8054 new MockClientSocketPoolManager); 8037 new MockClientSocketPoolManager);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
8095 "http_proxy", 8078 "http_proxy",
8096 "ftp://ftp.google.com/http_proxy_normal", 8079 "ftp://ftp.google.com/http_proxy_normal",
8097 "ftp/ftp.google.com:21", 8080 "ftp/ftp.google.com:21",
8098 false, 8081 false,
8099 }, 8082 },
8100 }; 8083 };
8101 8084
8102 session_deps_.use_alternative_services = true; 8085 session_deps_.use_alternative_services = true;
8103 8086
8104 for (size_t i = 0; i < arraysize(tests); ++i) { 8087 for (size_t i = 0; i < arraysize(tests); ++i) {
8105 session_deps_.proxy_service.reset( 8088 session_deps_.proxy_service =
8106 ProxyService::CreateFixed(tests[i].proxy_server)); 8089 ProxyService::CreateFixed(tests[i].proxy_server);
8107 scoped_refptr<HttpNetworkSession> session( 8090 scoped_refptr<HttpNetworkSession> session(
8108 SetupSessionForGroupNameTests(GetParam(), &session_deps_)); 8091 SetupSessionForGroupNameTests(GetParam(), &session_deps_));
8109 8092
8110 HttpNetworkSessionPeer peer(session); 8093 HttpNetworkSessionPeer peer(session);
8111 8094
8112 HostPortPair proxy_host("http_proxy", 80); 8095 HostPortPair proxy_host("http_proxy", 80);
8113 CaptureGroupNameHttpProxySocketPool* http_proxy_pool = 8096 CaptureGroupNameHttpProxySocketPool* http_proxy_pool =
8114 new CaptureGroupNameHttpProxySocketPool(NULL, NULL); 8097 new CaptureGroupNameHttpProxySocketPool(NULL, NULL);
8115 CaptureGroupNameSSLSocketPool* ssl_conn_pool = 8098 CaptureGroupNameSSLSocketPool* ssl_conn_pool =
8116 new CaptureGroupNameSSLSocketPool(NULL, NULL); 8099 new CaptureGroupNameSSLSocketPool(NULL, NULL);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
8165 "socks4://socks_proxy:1080", 8148 "socks4://socks_proxy:1080",
8166 "http://host.with.alternate/direct", 8149 "http://host.with.alternate/direct",
8167 "socks4/ssl/host.with.alternate:443", 8150 "socks4/ssl/host.with.alternate:443",
8168 true, 8151 true,
8169 }, 8152 },
8170 }; 8153 };
8171 8154
8172 session_deps_.use_alternative_services = true; 8155 session_deps_.use_alternative_services = true;
8173 8156
8174 for (size_t i = 0; i < arraysize(tests); ++i) { 8157 for (size_t i = 0; i < arraysize(tests); ++i) {
8175 session_deps_.proxy_service.reset( 8158 session_deps_.proxy_service =
8176 ProxyService::CreateFixed(tests[i].proxy_server)); 8159 ProxyService::CreateFixed(tests[i].proxy_server);
8177 scoped_refptr<HttpNetworkSession> session( 8160 scoped_refptr<HttpNetworkSession> session(
8178 SetupSessionForGroupNameTests(GetParam(), &session_deps_)); 8161 SetupSessionForGroupNameTests(GetParam(), &session_deps_));
8179 8162
8180 HttpNetworkSessionPeer peer(session); 8163 HttpNetworkSessionPeer peer(session);
8181 8164
8182 HostPortPair proxy_host("socks_proxy", 1080); 8165 HostPortPair proxy_host("socks_proxy", 1080);
8183 CaptureGroupNameSOCKSSocketPool* socks_conn_pool = 8166 CaptureGroupNameSOCKSSocketPool* socks_conn_pool =
8184 new CaptureGroupNameSOCKSSocketPool(NULL, NULL); 8167 new CaptureGroupNameSOCKSSocketPool(NULL, NULL);
8185 CaptureGroupNameSSLSocketPool* ssl_conn_pool = 8168 CaptureGroupNameSSLSocketPool* ssl_conn_pool =
8186 new CaptureGroupNameSSLSocketPool(NULL, NULL); 8169 new CaptureGroupNameSSLSocketPool(NULL, NULL);
(...skipping 16 matching lines...) Expand all
8203 EXPECT_EQ(tests[i].expected_group_name, 8186 EXPECT_EQ(tests[i].expected_group_name,
8204 socks_conn_pool->last_group_name_received()); 8187 socks_conn_pool->last_group_name_received());
8205 } 8188 }
8206 } 8189 }
8207 8190
8208 TEST_P(HttpNetworkTransactionTest, ReconsiderProxyAfterFailedConnection) { 8191 TEST_P(HttpNetworkTransactionTest, ReconsiderProxyAfterFailedConnection) {
8209 HttpRequestInfo request; 8192 HttpRequestInfo request;
8210 request.method = "GET"; 8193 request.method = "GET";
8211 request.url = GURL("http://www.example.org/"); 8194 request.url = GURL("http://www.example.org/");
8212 8195
8213 session_deps_.proxy_service.reset( 8196 session_deps_.proxy_service =
8214 ProxyService::CreateFixed("myproxy:70;foobar:80")); 8197 ProxyService::CreateFixed("myproxy:70;foobar:80");
8215 8198
8216 // This simulates failure resolving all hostnames; that means we will fail 8199 // This simulates failure resolving all hostnames; that means we will fail
8217 // connecting to both proxies (myproxy:70 and foobar:80). 8200 // connecting to both proxies (myproxy:70 and foobar:80).
8218 session_deps_.host_resolver->rules()->AddSimulatedFailure("*"); 8201 session_deps_.host_resolver->rules()->AddSimulatedFailure("*");
8219 8202
8220 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8203 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8221 scoped_ptr<HttpTransaction> trans( 8204 scoped_ptr<HttpTransaction> trans(
8222 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 8205 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
8223 8206
8224 TestCompletionCallback callback; 8207 TestCompletionCallback callback;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
8441 EXPECT_EQ(OK, rv); 8424 EXPECT_EQ(OK, rv);
8442 8425
8443 response = trans->GetResponseInfo(); 8426 response = trans->GetResponseInfo();
8444 ASSERT_TRUE(response != NULL); 8427 ASSERT_TRUE(response != NULL);
8445 EXPECT_TRUE(response->auth_challenge.get() == NULL); 8428 EXPECT_TRUE(response->auth_challenge.get() == NULL);
8446 EXPECT_EQ(100, response->headers->GetContentLength()); 8429 EXPECT_EQ(100, response->headers->GetContentLength());
8447 } 8430 }
8448 8431
8449 // Test HTTPS connections going through a proxy that sends extra data. 8432 // Test HTTPS connections going through a proxy that sends extra data.
8450 TEST_P(HttpNetworkTransactionTest, HTTPSViaProxyWithExtraData) { 8433 TEST_P(HttpNetworkTransactionTest, HTTPSViaProxyWithExtraData) {
8451 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 8434 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70");
8452 8435
8453 HttpRequestInfo request; 8436 HttpRequestInfo request;
8454 request.method = "GET"; 8437 request.method = "GET";
8455 request.url = GURL("https://www.example.org/"); 8438 request.url = GURL("https://www.example.org/");
8456 request.load_flags = 0; 8439 request.load_flags = 0;
8457 8440
8458 MockRead proxy_reads[] = { 8441 MockRead proxy_reads[] = {
8459 MockRead("HTTP/1.0 200 Connected\r\n\r\nExtra data"), 8442 MockRead("HTTP/1.0 200 Connected\r\n\r\nExtra data"),
8460 MockRead(SYNCHRONOUS, OK) 8443 MockRead(SYNCHRONOUS, OK)
8461 }; 8444 };
(...skipping 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after
10489 HttpAuthChallengeTokenizer tokenizer(auth_challenge.begin(), 10472 HttpAuthChallengeTokenizer tokenizer(auth_challenge.begin(),
10490 auth_challenge.end()); 10473 auth_challenge.end());
10491 auth_handler->InitFromChallenge(&tokenizer, HttpAuth::AUTH_SERVER, 10474 auth_handler->InitFromChallenge(&tokenizer, HttpAuth::AUTH_SERVER,
10492 origin, BoundNetLog()); 10475 origin, BoundNetLog());
10493 auth_handler->SetGenerateExpectation( 10476 auth_handler->SetGenerateExpectation(
10494 test_config.server_auth_timing == AUTH_ASYNC, 10477 test_config.server_auth_timing == AUTH_ASYNC,
10495 test_config.server_auth_rv); 10478 test_config.server_auth_rv);
10496 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_SERVER); 10479 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_SERVER);
10497 } 10480 }
10498 if (test_config.proxy_url) { 10481 if (test_config.proxy_url) {
10499 session_deps_.proxy_service.reset( 10482 session_deps_.proxy_service =
10500 ProxyService::CreateFixed(test_config.proxy_url)); 10483 ProxyService::CreateFixed(test_config.proxy_url);
10501 } else { 10484 } else {
10502 session_deps_.proxy_service.reset(ProxyService::CreateDirect()); 10485 session_deps_.proxy_service = ProxyService::CreateDirect();
10503 } 10486 }
10504 10487
10505 HttpRequestInfo request; 10488 HttpRequestInfo request;
10506 request.method = "GET"; 10489 request.method = "GET";
10507 request.url = GURL(test_config.server_url); 10490 request.url = GURL(test_config.server_url);
10508 request.load_flags = 0; 10491 request.load_flags = 0;
10509 10492
10510 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 10493 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
10511 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); 10494 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
10512 10495
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
10578 } 10561 }
10579 } 10562 }
10580 } 10563 }
10581 } 10564 }
10582 10565
10583 TEST_P(HttpNetworkTransactionTest, MultiRoundAuth) { 10566 TEST_P(HttpNetworkTransactionTest, MultiRoundAuth) {
10584 // Do multi-round authentication and make sure it works correctly. 10567 // Do multi-round authentication and make sure it works correctly.
10585 HttpAuthHandlerMock::Factory* auth_factory( 10568 HttpAuthHandlerMock::Factory* auth_factory(
10586 new HttpAuthHandlerMock::Factory()); 10569 new HttpAuthHandlerMock::Factory());
10587 session_deps_.http_auth_handler_factory.reset(auth_factory); 10570 session_deps_.http_auth_handler_factory.reset(auth_factory);
10588 session_deps_.proxy_service.reset(ProxyService::CreateDirect()); 10571 session_deps_.proxy_service = ProxyService::CreateDirect();
10589 session_deps_.host_resolver->rules()->AddRule("www.example.com", "10.0.0.1"); 10572 session_deps_.host_resolver->rules()->AddRule("www.example.com", "10.0.0.1");
10590 session_deps_.host_resolver->set_synchronous_mode(true); 10573 session_deps_.host_resolver->set_synchronous_mode(true);
10591 10574
10592 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); 10575 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock());
10593 auth_handler->set_connection_based(true); 10576 auth_handler->set_connection_based(true);
10594 std::string auth_challenge = "Mock realm=server"; 10577 std::string auth_challenge = "Mock realm=server";
10595 GURL origin("http://www.example.com"); 10578 GURL origin("http://www.example.com");
10596 HttpAuthChallengeTokenizer tokenizer(auth_challenge.begin(), 10579 HttpAuthChallengeTokenizer tokenizer(auth_challenge.begin(),
10597 auth_challenge.end()); 10580 auth_challenge.end());
10598 auth_handler->InitFromChallenge(&tokenizer, HttpAuth::AUTH_SERVER, 10581 auth_handler->InitFromChallenge(&tokenizer, HttpAuth::AUTH_SERVER,
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
10889 private: 10872 private:
10890 GURL* url_; 10873 GURL* url_;
10891 }; 10874 };
10892 10875
10893 // This test ensures that the URL passed into the proxy is upgraded to https 10876 // This test ensures that the URL passed into the proxy is upgraded to https
10894 // when doing an Alternate Protocol upgrade. 10877 // when doing an Alternate Protocol upgrade.
10895 TEST_P(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { 10878 TEST_P(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) {
10896 session_deps_.use_alternative_services = true; 10879 session_deps_.use_alternative_services = true;
10897 session_deps_.next_protos = SpdyNextProtos(); 10880 session_deps_.next_protos = SpdyNextProtos();
10898 10881
10899 session_deps_.proxy_service.reset( 10882 session_deps_.proxy_service =
10900 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 10883 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70");
10901 TestNetLog net_log; 10884 TestNetLog net_log;
10902 session_deps_.net_log = &net_log; 10885 session_deps_.net_log = &net_log;
10903 GURL request_url; 10886 GURL request_url;
10904 { 10887 {
10905 HttpAuthHandlerMock::Factory* auth_factory = 10888 HttpAuthHandlerMock::Factory* auth_factory =
10906 new HttpAuthHandlerMock::Factory(); 10889 new HttpAuthHandlerMock::Factory();
10907 UrlRecordingHttpAuthHandlerMock* auth_handler = 10890 UrlRecordingHttpAuthHandlerMock* auth_handler =
10908 new UrlRecordingHttpAuthHandlerMock(&request_url); 10891 new UrlRecordingHttpAuthHandlerMock(&request_url);
10909 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY); 10892 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY);
10910 auth_factory->set_do_init_from_challenge(true); 10893 auth_factory->set_do_init_from_challenge(true);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
11135 11118
11136 // Let the HttpResponseBodyDrainer drain the socket. 11119 // Let the HttpResponseBodyDrainer drain the socket.
11137 base::MessageLoop::current()->RunUntilIdle(); 11120 base::MessageLoop::current()->RunUntilIdle();
11138 11121
11139 // Socket should now be idle, waiting to be reused. 11122 // Socket should now be idle, waiting to be reused.
11140 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get())); 11123 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session.get()));
11141 } 11124 }
11142 11125
11143 // Test a basic GET request through a proxy. 11126 // Test a basic GET request through a proxy.
11144 TEST_P(HttpNetworkTransactionTest, ProxyGet) { 11127 TEST_P(HttpNetworkTransactionTest, ProxyGet) {
11145 session_deps_.proxy_service.reset( 11128 session_deps_.proxy_service =
11146 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 11129 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70");
11147 BoundTestNetLog log; 11130 BoundTestNetLog log;
11148 session_deps_.net_log = log.bound().net_log(); 11131 session_deps_.net_log = log.bound().net_log();
11149 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11132 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11150 11133
11151 HttpRequestInfo request; 11134 HttpRequestInfo request;
11152 request.method = "GET"; 11135 request.method = "GET";
11153 request.url = GURL("http://www.example.org/"); 11136 request.url = GURL("http://www.example.org/");
11154 11137
11155 MockWrite data_writes1[] = { 11138 MockWrite data_writes1[] = {
11156 MockWrite( 11139 MockWrite(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
11199 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); 11182 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion());
11200 11183
11201 LoadTimingInfo load_timing_info; 11184 LoadTimingInfo load_timing_info;
11202 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); 11185 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info));
11203 TestLoadTimingNotReusedWithPac(load_timing_info, 11186 TestLoadTimingNotReusedWithPac(load_timing_info,
11204 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); 11187 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY);
11205 } 11188 }
11206 11189
11207 // Test a basic HTTPS GET request through a proxy. 11190 // Test a basic HTTPS GET request through a proxy.
11208 TEST_P(HttpNetworkTransactionTest, ProxyTunnelGet) { 11191 TEST_P(HttpNetworkTransactionTest, ProxyTunnelGet) {
11209 session_deps_.proxy_service.reset( 11192 session_deps_.proxy_service =
11210 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 11193 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70");
11211 BoundTestNetLog log; 11194 BoundTestNetLog log;
11212 session_deps_.net_log = log.bound().net_log(); 11195 session_deps_.net_log = log.bound().net_log();
11213 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11196 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11214 11197
11215 HttpRequestInfo request; 11198 HttpRequestInfo request;
11216 request.method = "GET"; 11199 request.method = "GET";
11217 request.url = GURL("https://www.example.org/"); 11200 request.url = GURL("https://www.example.org/");
11218 11201
11219 // Since we have proxy, should try to establish tunnel. 11202 // Since we have proxy, should try to establish tunnel.
11220 MockWrite data_writes1[] = { 11203 MockWrite data_writes1[] = {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
11277 11260
11278 LoadTimingInfo load_timing_info; 11261 LoadTimingInfo load_timing_info;
11279 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info)); 11262 EXPECT_TRUE(trans->GetLoadTimingInfo(&load_timing_info));
11280 TestLoadTimingNotReusedWithPac(load_timing_info, 11263 TestLoadTimingNotReusedWithPac(load_timing_info,
11281 CONNECT_TIMING_HAS_SSL_TIMES); 11264 CONNECT_TIMING_HAS_SSL_TIMES);
11282 } 11265 }
11283 11266
11284 // Test a basic HTTPS GET request through a proxy, but the server hangs up 11267 // Test a basic HTTPS GET request through a proxy, but the server hangs up
11285 // while establishing the tunnel. 11268 // while establishing the tunnel.
11286 TEST_P(HttpNetworkTransactionTest, ProxyTunnelGetHangup) { 11269 TEST_P(HttpNetworkTransactionTest, ProxyTunnelGetHangup) {
11287 session_deps_.proxy_service.reset(ProxyService::CreateFixed("myproxy:70")); 11270 session_deps_.proxy_service = ProxyService::CreateFixed("myproxy:70");
11288 BoundTestNetLog log; 11271 BoundTestNetLog log;
11289 session_deps_.net_log = log.bound().net_log(); 11272 session_deps_.net_log = log.bound().net_log();
11290 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 11273 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
11291 11274
11292 HttpRequestInfo request; 11275 HttpRequestInfo request;
11293 request.method = "GET"; 11276 request.method = "GET";
11294 request.url = GURL("https://www.example.org/"); 11277 request.url = GURL("https://www.example.org/");
11295 11278
11296 // Since we have proxy, should try to establish tunnel. 11279 // Since we have proxy, should try to establish tunnel.
11297 MockWrite data_writes1[] = { 11280 MockWrite data_writes1[] = {
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
11648 11631
11649 // Ensure that a client certificate is removed from the SSL client auth 11632 // Ensure that a client certificate is removed from the SSL client auth
11650 // cache when: 11633 // cache when:
11651 // 1) An HTTPS proxy is involved. 11634 // 1) An HTTPS proxy is involved.
11652 // 3) The HTTPS proxy requests a client certificate. 11635 // 3) The HTTPS proxy requests a client certificate.
11653 // 4) The client supplies an invalid/unacceptable certificate for the 11636 // 4) The client supplies an invalid/unacceptable certificate for the
11654 // proxy. 11637 // proxy.
11655 // The test is repeated twice, first for connecting to an HTTPS endpoint, 11638 // The test is repeated twice, first for connecting to an HTTPS endpoint,
11656 // then for connecting to an HTTP endpoint. 11639 // then for connecting to an HTTP endpoint.
11657 TEST_P(HttpNetworkTransactionTest, ClientAuthCertCache_Proxy_Fail) { 11640 TEST_P(HttpNetworkTransactionTest, ClientAuthCertCache_Proxy_Fail) {
11658 session_deps_.proxy_service.reset( 11641 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
11659 ProxyService::CreateFixed("https://proxy:70"));
11660 BoundTestNetLog log; 11642 BoundTestNetLog log;
11661 session_deps_.net_log = log.bound().net_log(); 11643 session_deps_.net_log = log.bound().net_log();
11662 11644
11663 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); 11645 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo());
11664 cert_request->host_and_port = HostPortPair("proxy", 70); 11646 cert_request->host_and_port = HostPortPair("proxy", 70);
11665 11647
11666 // See ClientAuthCertCache_Direct_NoFalseStart for the explanation of 11648 // See ClientAuthCertCache_Direct_NoFalseStart for the explanation of
11667 // [ssl_]data[1-3]. Rather than represending the endpoint 11649 // [ssl_]data[1-3]. Rather than represending the endpoint
11668 // (www.example.com:443), they represent failures with the HTTPS proxy 11650 // (www.example.com:443), they represent failures with the HTTPS proxy
11669 // (proxy:70). 11651 // (proxy:70).
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
12634 CreateMockRead(*resp2, 6), 12616 CreateMockRead(*resp2, 6),
12635 CreateMockRead(*body2, 7), 12617 CreateMockRead(*body2, 7),
12636 MockRead(ASYNC, ERR_IO_PENDING, 8) 12618 MockRead(ASYNC, ERR_IO_PENDING, 8)
12637 }; 12619 };
12638 12620
12639 DeterministicSocketData data1(reads1, arraysize(reads1), 12621 DeterministicSocketData data1(reads1, arraysize(reads1),
12640 writes1, arraysize(writes1)); 12622 writes1, arraysize(writes1));
12641 MockConnect connect_data1(ASYNC, OK); 12623 MockConnect connect_data1(ASYNC, OK);
12642 data1.set_connect_data(connect_data1); 12624 data1.set_connect_data(connect_data1);
12643 12625
12644 session_deps_.proxy_service.reset( 12626 session_deps_.proxy_service =
12645 ProxyService::CreateFixedFromPacResult("HTTPS proxy:70")); 12627 ProxyService::CreateFixedFromPacResult("HTTPS proxy:70");
12646 TestNetLog log; 12628 TestNetLog log;
12647 session_deps_.net_log = &log; 12629 session_deps_.net_log = &log;
12648 SSLSocketDataProvider ssl1(ASYNC, OK); // to the proxy 12630 SSLSocketDataProvider ssl1(ASYNC, OK); // to the proxy
12649 ssl1.SetNextProto(GetParam()); 12631 ssl1.SetNextProto(GetParam());
12650 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl1); 12632 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl1);
12651 SSLSocketDataProvider ssl2(ASYNC, OK); // to the server 12633 SSLSocketDataProvider ssl2(ASYNC, OK); // to the server
12652 ssl2.SetNextProto(GetParam()); 12634 ssl2.SetNextProto(GetParam());
12653 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2); 12635 session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl2);
12654 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data1); 12636 session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data1);
12655 12637
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after
14401 14383
14402 // Verify that proxy headers are not sent to the destination server when 14384 // Verify that proxy headers are not sent to the destination server when
14403 // establishing a tunnel for a secure WebSocket connection. 14385 // establishing a tunnel for a secure WebSocket connection.
14404 TEST_P(HttpNetworkTransactionTest, ProxyHeadersNotSentOverWssTunnel) { 14386 TEST_P(HttpNetworkTransactionTest, ProxyHeadersNotSentOverWssTunnel) {
14405 HttpRequestInfo request; 14387 HttpRequestInfo request;
14406 request.method = "GET"; 14388 request.method = "GET";
14407 request.url = GURL("wss://www.example.org/"); 14389 request.url = GURL("wss://www.example.org/");
14408 AddWebSocketHeaders(&request.extra_headers); 14390 AddWebSocketHeaders(&request.extra_headers);
14409 14391
14410 // Configure against proxy server "myproxy:70". 14392 // Configure against proxy server "myproxy:70".
14411 session_deps_.proxy_service.reset( 14393 session_deps_.proxy_service =
14412 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 14394 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70");
14413 14395
14414 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14396 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14415 14397
14416 // Since a proxy is configured, try to establish a tunnel. 14398 // Since a proxy is configured, try to establish a tunnel.
14417 MockWrite data_writes[] = { 14399 MockWrite data_writes[] = {
14418 MockWrite( 14400 MockWrite(
14419 "CONNECT www.example.org:443 HTTP/1.1\r\n" 14401 "CONNECT www.example.org:443 HTTP/1.1\r\n"
14420 "Host: www.example.org\r\n" 14402 "Host: www.example.org\r\n"
14421 "Proxy-Connection: keep-alive\r\n\r\n"), 14403 "Proxy-Connection: keep-alive\r\n\r\n"),
14422 14404
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
14508 // This requires the authentication info to be injected into the auth cache 14490 // This requires the authentication info to be injected into the auth cache
14509 // due to crbug.com/395064 14491 // due to crbug.com/395064
14510 // TODO(ricea): Change to use a 407 response once issue 395064 is fixed. 14492 // TODO(ricea): Change to use a 407 response once issue 395064 is fixed.
14511 TEST_P(HttpNetworkTransactionTest, ProxyHeadersNotSentOverWsTunnel) { 14493 TEST_P(HttpNetworkTransactionTest, ProxyHeadersNotSentOverWsTunnel) {
14512 HttpRequestInfo request; 14494 HttpRequestInfo request;
14513 request.method = "GET"; 14495 request.method = "GET";
14514 request.url = GURL("ws://www.example.org/"); 14496 request.url = GURL("ws://www.example.org/");
14515 AddWebSocketHeaders(&request.extra_headers); 14497 AddWebSocketHeaders(&request.extra_headers);
14516 14498
14517 // Configure against proxy server "myproxy:70". 14499 // Configure against proxy server "myproxy:70".
14518 session_deps_.proxy_service.reset( 14500 session_deps_.proxy_service =
14519 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); 14501 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70");
14520 14502
14521 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 14503 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
14522 14504
14523 MockWrite data_writes[] = { 14505 MockWrite data_writes[] = {
14524 // Try to establish a tunnel for the WebSocket connection, with 14506 // Try to establish a tunnel for the WebSocket connection, with
14525 // credentials. Because WebSockets have a separate set of socket pools, 14507 // credentials. Because WebSockets have a separate set of socket pools,
14526 // they cannot and will not use the same TCP/IP connection as the 14508 // they cannot and will not use the same TCP/IP connection as the
14527 // preflight HTTP request. 14509 // preflight HTTP request.
14528 MockWrite( 14510 MockWrite(
14529 "CONNECT www.example.org:80 HTTP/1.1\r\n" 14511 "CONNECT www.example.org:80 HTTP/1.1\r\n"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
14578 ASSERT_TRUE(response); 14560 ASSERT_TRUE(response);
14579 ASSERT_TRUE(response->headers.get()); 14561 ASSERT_TRUE(response->headers.get());
14580 14562
14581 EXPECT_EQ(101, response->headers->response_code()); 14563 EXPECT_EQ(101, response->headers->response_code());
14582 14564
14583 trans.reset(); 14565 trans.reset();
14584 session->CloseAllConnections(); 14566 session->CloseAllConnections();
14585 } 14567 }
14586 14568
14587 } // namespace net 14569 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698