OLD | NEW |
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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 3244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3255 session_deps_.proxy_service.reset(ProxyService::CreateFixed( | 3255 session_deps_.proxy_service.reset(ProxyService::CreateFixed( |
3256 "https://proxy:70")); | 3256 "https://proxy:70")); |
3257 CapturingBoundNetLog log; | 3257 CapturingBoundNetLog log; |
3258 session_deps_.net_log = log.bound().net_log(); | 3258 session_deps_.net_log = log.bound().net_log(); |
3259 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 3259 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
3260 | 3260 |
3261 scoped_ptr<HttpTransaction> trans( | 3261 scoped_ptr<HttpTransaction> trans( |
3262 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 3262 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3263 | 3263 |
3264 // CONNECT to www.google.com:443 via SPDY | 3264 // CONNECT to www.google.com:443 via SPDY |
3265 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1, | 3265 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect( |
3266 LOWEST)); | 3266 NULL, 0, 1, LOWEST, HostPortPair("www.google.com", 443))); |
3267 // fetch https://www.google.com/ via HTTP | 3267 // fetch https://www.google.com/ via HTTP |
3268 | 3268 |
3269 const char get[] = "GET / HTTP/1.1\r\n" | 3269 const char get[] = "GET / HTTP/1.1\r\n" |
3270 "Host: www.google.com\r\n" | 3270 "Host: www.google.com\r\n" |
3271 "Connection: keep-alive\r\n\r\n"; | 3271 "Connection: keep-alive\r\n\r\n"; |
3272 scoped_ptr<SpdyFrame> wrapped_get( | 3272 scoped_ptr<SpdyFrame> wrapped_get( |
3273 spdy_util_.ConstructSpdyBodyFrame(1, get, strlen(get), false)); | 3273 spdy_util_.ConstructSpdyBodyFrame(1, get, strlen(get), false)); |
3274 scoped_ptr<SpdyFrame> conn_resp( | 3274 scoped_ptr<SpdyFrame> conn_resp( |
3275 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3275 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
3276 const char resp[] = "HTTP/1.1 200 OK\r\n" | 3276 const char resp[] = "HTTP/1.1 200 OK\r\n" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3342 session_deps_.proxy_service.reset(ProxyService::CreateFixed( | 3342 session_deps_.proxy_service.reset(ProxyService::CreateFixed( |
3343 "https://proxy:70")); | 3343 "https://proxy:70")); |
3344 CapturingBoundNetLog log; | 3344 CapturingBoundNetLog log; |
3345 session_deps_.net_log = log.bound().net_log(); | 3345 session_deps_.net_log = log.bound().net_log(); |
3346 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 3346 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
3347 | 3347 |
3348 scoped_ptr<HttpTransaction> trans( | 3348 scoped_ptr<HttpTransaction> trans( |
3349 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 3349 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3350 | 3350 |
3351 // CONNECT to www.google.com:443 via SPDY | 3351 // CONNECT to www.google.com:443 via SPDY |
3352 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1, | 3352 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect( |
3353 LOWEST)); | 3353 NULL, 0, 1, LOWEST, HostPortPair("www.google.com", 443))); |
3354 // fetch https://www.google.com/ via SPDY | 3354 // fetch https://www.google.com/ via SPDY |
3355 const char* const kMyUrl = "https://www.google.com/"; | 3355 const char* const kMyUrl = "https://www.google.com/"; |
3356 scoped_ptr<SpdyFrame> get( | 3356 scoped_ptr<SpdyFrame> get( |
3357 spdy_util_.ConstructSpdyGet(kMyUrl, false, 1, LOWEST)); | 3357 spdy_util_.ConstructSpdyGet(kMyUrl, false, 1, LOWEST)); |
3358 scoped_ptr<SpdyFrame> wrapped_get( | 3358 scoped_ptr<SpdyFrame> wrapped_get( |
3359 spdy_util_.ConstructWrappedSpdyFrame(get, 1)); | 3359 spdy_util_.ConstructWrappedSpdyFrame(get, 1)); |
3360 scoped_ptr<SpdyFrame> conn_resp( | 3360 scoped_ptr<SpdyFrame> conn_resp( |
3361 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3361 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
3362 scoped_ptr<SpdyFrame> get_resp( | 3362 scoped_ptr<SpdyFrame> get_resp( |
3363 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3363 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3431 session_deps_.proxy_service.reset(ProxyService::CreateFixed( | 3431 session_deps_.proxy_service.reset(ProxyService::CreateFixed( |
3432 "https://proxy:70")); | 3432 "https://proxy:70")); |
3433 CapturingBoundNetLog log; | 3433 CapturingBoundNetLog log; |
3434 session_deps_.net_log = log.bound().net_log(); | 3434 session_deps_.net_log = log.bound().net_log(); |
3435 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 3435 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
3436 | 3436 |
3437 scoped_ptr<HttpTransaction> trans( | 3437 scoped_ptr<HttpTransaction> trans( |
3438 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 3438 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
3439 | 3439 |
3440 // CONNECT to www.google.com:443 via SPDY | 3440 // CONNECT to www.google.com:443 via SPDY |
3441 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1, | 3441 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect( |
3442 LOWEST)); | 3442 NULL, 0, 1, LOWEST, HostPortPair("www.google.com", 443))); |
3443 scoped_ptr<SpdyFrame> get( | 3443 scoped_ptr<SpdyFrame> get( |
3444 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); | 3444 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); |
3445 | 3445 |
3446 MockWrite spdy_writes[] = { | 3446 MockWrite spdy_writes[] = { |
3447 CreateMockWrite(*connect, 1), | 3447 CreateMockWrite(*connect, 1), |
3448 CreateMockWrite(*get, 3), | 3448 CreateMockWrite(*get, 3), |
3449 }; | 3449 }; |
3450 | 3450 |
3451 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdySynReplyError(1)); | 3451 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdySynReplyError(1)); |
3452 scoped_ptr<SpdyFrame> data(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 3452 scoped_ptr<SpdyFrame> data(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3494 request1.method = "GET"; | 3494 request1.method = "GET"; |
3495 request1.url = GURL("https://www.google.com/"); | 3495 request1.url = GURL("https://www.google.com/"); |
3496 request1.load_flags = 0; | 3496 request1.load_flags = 0; |
3497 | 3497 |
3498 HttpRequestInfo request2; | 3498 HttpRequestInfo request2; |
3499 request2.method = "GET"; | 3499 request2.method = "GET"; |
3500 request2.url = GURL("https://news.google.com/"); | 3500 request2.url = GURL("https://news.google.com/"); |
3501 request2.load_flags = 0; | 3501 request2.load_flags = 0; |
3502 | 3502 |
3503 // CONNECT to www.google.com:443 via SPDY. | 3503 // CONNECT to www.google.com:443 via SPDY. |
3504 scoped_ptr<SpdyFrame> connect1(spdy_util_.ConstructSpdyConnect(NULL, 0, 1, | 3504 scoped_ptr<SpdyFrame> connect1(spdy_util_.ConstructSpdyConnect( |
3505 LOWEST)); | 3505 NULL, 0, 1, LOWEST, HostPortPair("www.google.com", 443))); |
3506 scoped_ptr<SpdyFrame> conn_resp1( | 3506 scoped_ptr<SpdyFrame> conn_resp1( |
3507 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3507 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
3508 | 3508 |
3509 // Fetch https://www.google.com/ via HTTP. | 3509 // Fetch https://www.google.com/ via HTTP. |
3510 const char get1[] = "GET / HTTP/1.1\r\n" | 3510 const char get1[] = "GET / HTTP/1.1\r\n" |
3511 "Host: www.google.com\r\n" | 3511 "Host: www.google.com\r\n" |
3512 "Connection: keep-alive\r\n\r\n"; | 3512 "Connection: keep-alive\r\n\r\n"; |
3513 scoped_ptr<SpdyFrame> wrapped_get1( | 3513 scoped_ptr<SpdyFrame> wrapped_get1( |
3514 spdy_util_.ConstructSpdyBodyFrame(1, get1, strlen(get1), false)); | 3514 spdy_util_.ConstructSpdyBodyFrame(1, get1, strlen(get1), false)); |
3515 const char resp1[] = "HTTP/1.1 200 OK\r\n" | 3515 const char resp1[] = "HTTP/1.1 200 OK\r\n" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3644 request1.method = "GET"; | 3644 request1.method = "GET"; |
3645 request1.url = GURL("https://www.google.com/"); | 3645 request1.url = GURL("https://www.google.com/"); |
3646 request1.load_flags = 0; | 3646 request1.load_flags = 0; |
3647 | 3647 |
3648 HttpRequestInfo request2; | 3648 HttpRequestInfo request2; |
3649 request2.method = "GET"; | 3649 request2.method = "GET"; |
3650 request2.url = GURL("https://www.google.com/2"); | 3650 request2.url = GURL("https://www.google.com/2"); |
3651 request2.load_flags = 0; | 3651 request2.load_flags = 0; |
3652 | 3652 |
3653 // CONNECT to www.google.com:443 via SPDY. | 3653 // CONNECT to www.google.com:443 via SPDY. |
3654 scoped_ptr<SpdyFrame> connect1(spdy_util_.ConstructSpdyConnect(NULL, 0, 1, | 3654 scoped_ptr<SpdyFrame> connect1(spdy_util_.ConstructSpdyConnect( |
3655 LOWEST)); | 3655 NULL, 0, 1, LOWEST, HostPortPair("www.google.com", 443))); |
3656 scoped_ptr<SpdyFrame> conn_resp1( | 3656 scoped_ptr<SpdyFrame> conn_resp1( |
3657 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 3657 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
3658 | 3658 |
3659 // Fetch https://www.google.com/ via HTTP. | 3659 // Fetch https://www.google.com/ via HTTP. |
3660 const char get1[] = "GET / HTTP/1.1\r\n" | 3660 const char get1[] = "GET / HTTP/1.1\r\n" |
3661 "Host: www.google.com\r\n" | 3661 "Host: www.google.com\r\n" |
3662 "Connection: keep-alive\r\n\r\n"; | 3662 "Connection: keep-alive\r\n\r\n"; |
3663 scoped_ptr<SpdyFrame> wrapped_get1( | 3663 scoped_ptr<SpdyFrame> wrapped_get1( |
3664 spdy_util_.ConstructSpdyBodyFrame(1, get1, strlen(get1), false)); | 3664 spdy_util_.ConstructSpdyBodyFrame(1, get1, strlen(get1), false)); |
3665 const char resp1[] = "HTTP/1.1 200 OK\r\n" | 3665 const char resp1[] = "HTTP/1.1 200 OK\r\n" |
(...skipping 2547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6213 // Test an HTTPS (SPDY) Proxy's ability to redirect a CONNECT request | 6213 // Test an HTTPS (SPDY) Proxy's ability to redirect a CONNECT request |
6214 TEST_P(HttpNetworkTransactionTest, RedirectOfHttpsConnectViaSpdyProxy) { | 6214 TEST_P(HttpNetworkTransactionTest, RedirectOfHttpsConnectViaSpdyProxy) { |
6215 session_deps_.proxy_service.reset( | 6215 session_deps_.proxy_service.reset( |
6216 ProxyService::CreateFixed("https://proxy:70")); | 6216 ProxyService::CreateFixed("https://proxy:70")); |
6217 | 6217 |
6218 HttpRequestInfo request; | 6218 HttpRequestInfo request; |
6219 request.method = "GET"; | 6219 request.method = "GET"; |
6220 request.url = GURL("https://www.google.com/"); | 6220 request.url = GURL("https://www.google.com/"); |
6221 request.load_flags = 0; | 6221 request.load_flags = 0; |
6222 | 6222 |
6223 scoped_ptr<SpdyFrame> conn(spdy_util_.ConstructSpdyConnect(NULL, 0, 1, | 6223 scoped_ptr<SpdyFrame> conn(spdy_util_.ConstructSpdyConnect( |
6224 LOWEST)); | 6224 NULL, 0, 1, LOWEST, HostPortPair("www.google.com", 443))); |
6225 scoped_ptr<SpdyFrame> goaway( | 6225 scoped_ptr<SpdyFrame> goaway( |
6226 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); | 6226 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); |
6227 MockWrite data_writes[] = { | 6227 MockWrite data_writes[] = { |
6228 CreateMockWrite(*conn.get(), 0, SYNCHRONOUS), | 6228 CreateMockWrite(*conn.get(), 0, SYNCHRONOUS), |
6229 CreateMockWrite(*goaway.get(), 3, SYNCHRONOUS), | 6229 CreateMockWrite(*goaway.get(), 3, SYNCHRONOUS), |
6230 }; | 6230 }; |
6231 | 6231 |
6232 static const char* const kExtraHeaders[] = { | 6232 static const char* const kExtraHeaders[] = { |
6233 "location", | 6233 "location", |
6234 "http://login.example.com/", | 6234 "http://login.example.com/", |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6322 TEST_P(HttpNetworkTransactionTest, | 6322 TEST_P(HttpNetworkTransactionTest, |
6323 ErrorResponseToHttpsConnectViaSpdyProxy) { | 6323 ErrorResponseToHttpsConnectViaSpdyProxy) { |
6324 session_deps_.proxy_service.reset( | 6324 session_deps_.proxy_service.reset( |
6325 ProxyService::CreateFixed("https://proxy:70")); | 6325 ProxyService::CreateFixed("https://proxy:70")); |
6326 | 6326 |
6327 HttpRequestInfo request; | 6327 HttpRequestInfo request; |
6328 request.method = "GET"; | 6328 request.method = "GET"; |
6329 request.url = GURL("https://www.google.com/"); | 6329 request.url = GURL("https://www.google.com/"); |
6330 request.load_flags = 0; | 6330 request.load_flags = 0; |
6331 | 6331 |
6332 scoped_ptr<SpdyFrame> conn(spdy_util_.ConstructSpdyConnect(NULL, 0, 1, | 6332 scoped_ptr<SpdyFrame> conn(spdy_util_.ConstructSpdyConnect( |
6333 LOWEST)); | 6333 NULL, 0, 1, LOWEST, HostPortPair("www.google.com", 443))); |
6334 scoped_ptr<SpdyFrame> rst( | 6334 scoped_ptr<SpdyFrame> rst( |
6335 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); | 6335 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); |
6336 MockWrite data_writes[] = { | 6336 MockWrite data_writes[] = { |
6337 CreateMockWrite(*conn.get(), 0, SYNCHRONOUS), | 6337 CreateMockWrite(*conn.get(), 0, SYNCHRONOUS), |
6338 CreateMockWrite(*rst.get(), 3, SYNCHRONOUS), | 6338 CreateMockWrite(*rst.get(), 3, SYNCHRONOUS), |
6339 }; | 6339 }; |
6340 | 6340 |
6341 static const char* const kExtraHeaders[] = { | 6341 static const char* const kExtraHeaders[] = { |
6342 "location", | 6342 "location", |
6343 "http://login.example.com/", | 6343 "http://login.example.com/", |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6389 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 6389 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
6390 | 6390 |
6391 // Configure against https proxy server "myproxy:70". | 6391 // Configure against https proxy server "myproxy:70". |
6392 session_deps_.proxy_service.reset( | 6392 session_deps_.proxy_service.reset( |
6393 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70")); | 6393 ProxyService::CreateFixedFromPacResult("HTTPS myproxy:70")); |
6394 CapturingBoundNetLog log; | 6394 CapturingBoundNetLog log; |
6395 session_deps_.net_log = log.bound().net_log(); | 6395 session_deps_.net_log = log.bound().net_log(); |
6396 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 6396 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
6397 | 6397 |
6398 // Since we have proxy, should try to establish tunnel. | 6398 // Since we have proxy, should try to establish tunnel. |
6399 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyConnect(NULL, 0, 1, | 6399 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyConnect( |
6400 LOWEST)); | 6400 NULL, 0, 1, LOWEST, HostPortPair("www.google.com", 443))); |
6401 scoped_ptr<SpdyFrame> rst( | 6401 scoped_ptr<SpdyFrame> rst( |
6402 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); | 6402 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); |
6403 | 6403 |
6404 // After calling trans->RestartWithAuth(), this is the request we should | 6404 // After calling trans->RestartWithAuth(), this is the request we should |
6405 // be issuing -- the final header line contains the credentials. | 6405 // be issuing -- the final header line contains the credentials. |
6406 const char* const kAuthCredentials[] = { | 6406 const char* const kAuthCredentials[] = { |
6407 "proxy-authorization", "Basic Zm9vOmJhcg==", | 6407 "proxy-authorization", "Basic Zm9vOmJhcg==", |
6408 }; | 6408 }; |
6409 scoped_ptr<SpdyFrame> connect2(spdy_util_.ConstructSpdyConnect( | 6409 scoped_ptr<SpdyFrame> connect2(spdy_util_.ConstructSpdyConnect( |
6410 kAuthCredentials, arraysize(kAuthCredentials) / 2, 3, LOWEST)); | 6410 kAuthCredentials, arraysize(kAuthCredentials) / 2, 3, LOWEST, |
| 6411 HostPortPair("www.google.com", 443))); |
6411 // fetch https://www.google.com/ via HTTP | 6412 // fetch https://www.google.com/ via HTTP |
6412 const char get[] = "GET / HTTP/1.1\r\n" | 6413 const char get[] = "GET / HTTP/1.1\r\n" |
6413 "Host: www.google.com\r\n" | 6414 "Host: www.google.com\r\n" |
6414 "Connection: keep-alive\r\n\r\n"; | 6415 "Connection: keep-alive\r\n\r\n"; |
6415 scoped_ptr<SpdyFrame> wrapped_get( | 6416 scoped_ptr<SpdyFrame> wrapped_get( |
6416 spdy_util_.ConstructSpdyBodyFrame(3, get, strlen(get), false)); | 6417 spdy_util_.ConstructSpdyBodyFrame(3, get, strlen(get), false)); |
6417 | 6418 |
6418 MockWrite spdy_writes[] = { | 6419 MockWrite spdy_writes[] = { |
6419 CreateMockWrite(*req, 1, ASYNC), | 6420 CreateMockWrite(*req, 1, ASYNC), |
6420 CreateMockWrite(*rst, 4, ASYNC), | 6421 CreateMockWrite(*rst, 4, ASYNC), |
(...skipping 4884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11305 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 11306 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
11306 EXPECT_TRUE(response->was_fetched_via_spdy); | 11307 EXPECT_TRUE(response->was_fetched_via_spdy); |
11307 EXPECT_TRUE(response->was_npn_negotiated); | 11308 EXPECT_TRUE(response->was_npn_negotiated); |
11308 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 11309 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
11309 EXPECT_EQ("hello!", response_data); | 11310 EXPECT_EQ("hello!", response_data); |
11310 #endif | 11311 #endif |
11311 } | 11312 } |
11312 #undef MAYBE_UseIPConnectionPoolingWithHostCacheExpiration | 11313 #undef MAYBE_UseIPConnectionPoolingWithHostCacheExpiration |
11313 | 11314 |
11314 TEST_P(HttpNetworkTransactionTest, DoNotUseSpdySessionForHttp) { | 11315 TEST_P(HttpNetworkTransactionTest, DoNotUseSpdySessionForHttp) { |
11315 const std::string https_url = "https://www.google.com/"; | 11316 const std::string https_url = "https://www.google.com:8080/"; |
11316 const std::string http_url = "http://www.google.com:443/"; | 11317 const std::string http_url = "http://www.google.com:8080/"; |
11317 | 11318 |
11318 // SPDY GET for HTTPS URL | 11319 // SPDY GET for HTTPS URL |
11319 scoped_ptr<SpdyFrame> req1( | 11320 scoped_ptr<SpdyFrame> req1( |
11320 spdy_util_.ConstructSpdyGet(https_url.c_str(), false, 1, LOWEST)); | 11321 spdy_util_.ConstructSpdyGet(https_url.c_str(), false, 1, LOWEST)); |
11321 | 11322 |
11322 MockWrite writes1[] = { | 11323 MockWrite writes1[] = { |
11323 CreateMockWrite(*req1, 0), | 11324 CreateMockWrite(*req1, 0), |
11324 }; | 11325 }; |
11325 | 11326 |
11326 scoped_ptr<SpdyFrame> resp1(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 11327 scoped_ptr<SpdyFrame> resp1(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
11327 scoped_ptr<SpdyFrame> body1(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 11328 scoped_ptr<SpdyFrame> body1(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
11328 MockRead reads1[] = { | 11329 MockRead reads1[] = { |
11329 CreateMockRead(*resp1, 1), | 11330 CreateMockRead(*resp1, 1), |
11330 CreateMockRead(*body1, 2), | 11331 CreateMockRead(*body1, 2), |
11331 MockRead(ASYNC, ERR_IO_PENDING, 3) | 11332 MockRead(ASYNC, ERR_IO_PENDING, 3) |
11332 }; | 11333 }; |
11333 | 11334 |
11334 DelayedSocketData data1( | 11335 DelayedSocketData data1( |
11335 1, reads1, arraysize(reads1), | 11336 1, reads1, arraysize(reads1), |
11336 writes1, arraysize(writes1)); | 11337 writes1, arraysize(writes1)); |
11337 MockConnect connect_data1(ASYNC, OK); | 11338 MockConnect connect_data1(ASYNC, OK); |
11338 data1.set_connect_data(connect_data1); | 11339 data1.set_connect_data(connect_data1); |
11339 | 11340 |
11340 // HTTP GET for the HTTP URL | 11341 // HTTP GET for the HTTP URL |
11341 MockWrite writes2[] = { | 11342 MockWrite writes2[] = { |
11342 MockWrite(ASYNC, 4, | 11343 MockWrite(ASYNC, 4, |
11343 "GET / HTTP/1.1\r\n" | 11344 "GET / HTTP/1.1\r\n" |
11344 "Host: www.google.com:443\r\n" | 11345 "Host: www.google.com:8080\r\n" |
11345 "Connection: keep-alive\r\n\r\n"), | 11346 "Connection: keep-alive\r\n\r\n"), |
11346 }; | 11347 }; |
11347 | 11348 |
11348 MockRead reads2[] = { | 11349 MockRead reads2[] = { |
11349 MockRead(ASYNC, 5, "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), | 11350 MockRead(ASYNC, 5, "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), |
11350 MockRead(ASYNC, 6, "hello"), | 11351 MockRead(ASYNC, 6, "hello"), |
11351 MockRead(ASYNC, 7, OK), | 11352 MockRead(ASYNC, 7, OK), |
11352 }; | 11353 }; |
11353 | 11354 |
11354 DelayedSocketData data2( | 11355 DelayedSocketData data2( |
11355 1, reads2, arraysize(reads2), | 11356 1, reads2, arraysize(reads2), |
(...skipping 30 matching lines...) Expand all Loading... |
11386 TestCompletionCallback callback2; | 11387 TestCompletionCallback callback2; |
11387 EXPECT_EQ(ERR_IO_PENDING, | 11388 EXPECT_EQ(ERR_IO_PENDING, |
11388 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 11389 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
11389 base::MessageLoop::current()->RunUntilIdle(); | 11390 base::MessageLoop::current()->RunUntilIdle(); |
11390 | 11391 |
11391 EXPECT_EQ(OK, callback2.WaitForResult()); | 11392 EXPECT_EQ(OK, callback2.WaitForResult()); |
11392 EXPECT_FALSE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 11393 EXPECT_FALSE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
11393 } | 11394 } |
11394 | 11395 |
11395 TEST_P(HttpNetworkTransactionTest, DoNotUseSpdySessionForHttpOverTunnel) { | 11396 TEST_P(HttpNetworkTransactionTest, DoNotUseSpdySessionForHttpOverTunnel) { |
11396 const std::string https_url = "https://www.google.com/"; | 11397 const std::string https_url = "https://www.google.com:8080/"; |
11397 const std::string http_url = "http://www.google.com:443/"; | 11398 const std::string http_url = "http://www.google.com:8080/"; |
11398 | 11399 |
11399 // SPDY GET for HTTPS URL (through CONNECT tunnel) | 11400 // SPDY GET for HTTPS URL (through CONNECT tunnel) |
11400 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1, | 11401 const HostPortPair host_port_pair("www.google.com", 8080); |
11401 LOWEST)); | 11402 scoped_ptr<SpdyFrame> connect( |
| 11403 spdy_util_.ConstructSpdyConnect(NULL, 0, 1, LOWEST, host_port_pair)); |
11402 scoped_ptr<SpdyFrame> req1( | 11404 scoped_ptr<SpdyFrame> req1( |
11403 spdy_util_.ConstructSpdyGet(https_url.c_str(), false, 1, LOWEST)); | 11405 spdy_util_.ConstructSpdyGet(https_url.c_str(), false, 1, LOWEST)); |
11404 scoped_ptr<SpdyFrame> wrapped_req1( | 11406 scoped_ptr<SpdyFrame> wrapped_req1( |
11405 spdy_util_.ConstructWrappedSpdyFrame(req1, 1)); | 11407 spdy_util_.ConstructWrappedSpdyFrame(req1, 1)); |
11406 | 11408 |
11407 // SPDY GET for HTTP URL (through the proxy, but not the tunnel). | 11409 // SPDY GET for HTTP URL (through the proxy, but not the tunnel). |
11408 SpdyHeaderBlock req2_block; | 11410 SpdyHeaderBlock req2_block; |
11409 req2_block[spdy_util_.GetMethodKey()] = "GET"; | 11411 req2_block[spdy_util_.GetMethodKey()] = "GET"; |
11410 req2_block[spdy_util_.GetPathKey()] = "/"; | 11412 req2_block[spdy_util_.GetPathKey()] = "/"; |
11411 req2_block[spdy_util_.GetHostKey()] = "www.google.com:443"; | 11413 req2_block[spdy_util_.GetHostKey()] = "www.google.com:8080"; |
11412 req2_block[spdy_util_.GetSchemeKey()] = "http"; | 11414 req2_block[spdy_util_.GetSchemeKey()] = "http"; |
11413 spdy_util_.MaybeAddVersionHeader(&req2_block); | 11415 spdy_util_.MaybeAddVersionHeader(&req2_block); |
11414 scoped_ptr<SpdyFrame> req2( | 11416 scoped_ptr<SpdyFrame> req2( |
11415 spdy_util_.ConstructSpdySyn(3, req2_block, MEDIUM, false, true)); | 11417 spdy_util_.ConstructSpdySyn(3, req2_block, MEDIUM, false, true)); |
11416 | 11418 |
11417 MockWrite writes1[] = { | 11419 MockWrite writes1[] = { |
11418 CreateMockWrite(*connect, 0), | 11420 CreateMockWrite(*connect, 0), |
11419 CreateMockWrite(*wrapped_req1, 2), | 11421 CreateMockWrite(*wrapped_req1, 2), |
11420 CreateMockWrite(*req2, 5), | 11422 CreateMockWrite(*req2, 5), |
11421 }; | 11423 }; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11498 EXPECT_TRUE(trans2.GetLoadTimingInfo(&load_timing_info2)); | 11500 EXPECT_TRUE(trans2.GetLoadTimingInfo(&load_timing_info2)); |
11499 // The established SPDY sessions is considered reused by the HTTP request. | 11501 // The established SPDY sessions is considered reused by the HTTP request. |
11500 TestLoadTimingReusedWithPac(load_timing_info2); | 11502 TestLoadTimingReusedWithPac(load_timing_info2); |
11501 // HTTP requests over a SPDY session should have a different connection | 11503 // HTTP requests over a SPDY session should have a different connection |
11502 // socket_log_id than requests over a tunnel. | 11504 // socket_log_id than requests over a tunnel. |
11503 EXPECT_NE(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); | 11505 EXPECT_NE(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); |
11504 } | 11506 } |
11505 | 11507 |
11506 TEST_P(HttpNetworkTransactionTest, UseSpdySessionForHttpWhenForced) { | 11508 TEST_P(HttpNetworkTransactionTest, UseSpdySessionForHttpWhenForced) { |
11507 session_deps_.force_spdy_always = true; | 11509 session_deps_.force_spdy_always = true; |
11508 const std::string https_url = "https://www.google.com/"; | 11510 const std::string https_url = "https://www.google.com:8080/"; |
11509 const std::string http_url = "http://www.google.com:443/"; | 11511 const std::string http_url = "http://www.google.com:8080/"; |
11510 | 11512 |
11511 // SPDY GET for HTTPS URL | 11513 // SPDY GET for HTTPS URL |
11512 scoped_ptr<SpdyFrame> req1( | 11514 scoped_ptr<SpdyFrame> req1( |
11513 spdy_util_.ConstructSpdyGet(https_url.c_str(), false, 1, LOWEST)); | 11515 spdy_util_.ConstructSpdyGet(https_url.c_str(), false, 1, LOWEST)); |
11514 // SPDY GET for the HTTP URL | 11516 // SPDY GET for the HTTP URL |
11515 scoped_ptr<SpdyFrame> req2( | 11517 scoped_ptr<SpdyFrame> req2( |
11516 spdy_util_.ConstructSpdyGet(http_url.c_str(), false, 3, MEDIUM)); | 11518 spdy_util_.ConstructSpdyGet(http_url.c_str(), false, 3, MEDIUM)); |
11517 | 11519 |
11518 MockWrite writes[] = { | 11520 MockWrite writes[] = { |
11519 CreateMockWrite(*req1, 1), | 11521 CreateMockWrite(*req1, 1), |
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13185 EXPECT_EQ(ERR_IO_PENDING, rv); | 13187 EXPECT_EQ(ERR_IO_PENDING, rv); |
13186 | 13188 |
13187 rv = callback.WaitForResult(); | 13189 rv = callback.WaitForResult(); |
13188 EXPECT_EQ(ERR_CONNECTION_RESET, rv); | 13190 EXPECT_EQ(ERR_CONNECTION_RESET, rv); |
13189 | 13191 |
13190 const HttpResponseInfo* response = trans->GetResponseInfo(); | 13192 const HttpResponseInfo* response = trans->GetResponseInfo(); |
13191 EXPECT_TRUE(response == NULL); | 13193 EXPECT_TRUE(response == NULL); |
13192 } | 13194 } |
13193 | 13195 |
13194 } // namespace net | 13196 } // namespace net |
OLD | NEW |