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 <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 | 1066 |
1067 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 1067 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
1068 | 1068 |
1069 const HttpResponseInfo* response = trans.GetResponseInfo(); | 1069 const HttpResponseInfo* response = trans.GetResponseInfo(); |
1070 ASSERT_TRUE(response); | 1070 ASSERT_TRUE(response); |
1071 ASSERT_TRUE(response->headers); | 1071 ASSERT_TRUE(response->headers); |
1072 EXPECT_EQ("HTTP/1.1 302 Redirect", response->headers->GetStatusLine()); | 1072 EXPECT_EQ("HTTP/1.1 302 Redirect", response->headers->GetStatusLine()); |
1073 std::string url; | 1073 std::string url; |
1074 EXPECT_TRUE(response->headers->IsRedirect(&url)); | 1074 EXPECT_TRUE(response->headers->IsRedirect(&url)); |
1075 EXPECT_EQ("http://good.com/", url); | 1075 EXPECT_EQ("http://good.com/", url); |
1076 EXPECT_TRUE(response->proxy_server.IsEmpty()); | 1076 EXPECT_TRUE(response->proxy_server.is_direct()); |
1077 } | 1077 } |
1078 | 1078 |
1079 // Checks that two distinct Location headers result in an error. | 1079 // Checks that two distinct Location headers result in an error. |
1080 TEST_F(HttpNetworkTransactionTest, TwoDistinctLocationHeaders) { | 1080 TEST_F(HttpNetworkTransactionTest, TwoDistinctLocationHeaders) { |
1081 MockRead data_reads[] = { | 1081 MockRead data_reads[] = { |
1082 MockRead("HTTP/1.1 302 Redirect\r\n"), | 1082 MockRead("HTTP/1.1 302 Redirect\r\n"), |
1083 MockRead("Location: http://good.com/\r\n"), | 1083 MockRead("Location: http://good.com/\r\n"), |
1084 MockRead("Location: http://evil.com/\r\n"), | 1084 MockRead("Location: http://evil.com/\r\n"), |
1085 MockRead("Content-Length: 0\r\n\r\n"), | 1085 MockRead("Content-Length: 0\r\n\r\n"), |
1086 MockRead(SYNCHRONOUS, OK), | 1086 MockRead(SYNCHRONOUS, OK), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 rv = callback1.WaitForResult(); | 1130 rv = callback1.WaitForResult(); |
1131 EXPECT_THAT(rv, IsOk()); | 1131 EXPECT_THAT(rv, IsOk()); |
1132 | 1132 |
1133 const HttpResponseInfo* response = trans.GetResponseInfo(); | 1133 const HttpResponseInfo* response = trans.GetResponseInfo(); |
1134 ASSERT_TRUE(response); | 1134 ASSERT_TRUE(response); |
1135 | 1135 |
1136 // Check that the headers got parsed. | 1136 // Check that the headers got parsed. |
1137 EXPECT_TRUE(response->headers); | 1137 EXPECT_TRUE(response->headers); |
1138 EXPECT_EQ(1234, response->headers->GetContentLength()); | 1138 EXPECT_EQ(1234, response->headers->GetContentLength()); |
1139 EXPECT_EQ("HTTP/1.1 404 Not Found", response->headers->GetStatusLine()); | 1139 EXPECT_EQ("HTTP/1.1 404 Not Found", response->headers->GetStatusLine()); |
1140 EXPECT_TRUE(response->proxy_server.IsEmpty()); | 1140 EXPECT_TRUE(response->proxy_server.is_direct()); |
1141 EXPECT_TRUE(headers_handler.observed_before_headers_sent()); | 1141 EXPECT_TRUE(headers_handler.observed_before_headers_sent()); |
1142 EXPECT_FALSE(headers_handler.observed_before_headers_sent_with_proxy()); | 1142 EXPECT_FALSE(headers_handler.observed_before_headers_sent_with_proxy()); |
1143 | 1143 |
1144 std::string server_header; | 1144 std::string server_header; |
1145 size_t iter = 0; | 1145 size_t iter = 0; |
1146 bool has_server_header = response->headers->EnumerateHeader( | 1146 bool has_server_header = response->headers->EnumerateHeader( |
1147 &iter, "Server", &server_header); | 1147 &iter, "Server", &server_header); |
1148 EXPECT_TRUE(has_server_header); | 1148 EXPECT_TRUE(has_server_header); |
1149 EXPECT_EQ("Blah", server_header); | 1149 EXPECT_EQ("Blah", server_header); |
1150 | 1150 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 1187 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
1188 | 1188 |
1189 rv = callback.WaitForResult(); | 1189 rv = callback.WaitForResult(); |
1190 EXPECT_THAT(rv, IsOk()); | 1190 EXPECT_THAT(rv, IsOk()); |
1191 | 1191 |
1192 const HttpResponseInfo* response = trans.GetResponseInfo(); | 1192 const HttpResponseInfo* response = trans.GetResponseInfo(); |
1193 ASSERT_TRUE(response); | 1193 ASSERT_TRUE(response); |
1194 | 1194 |
1195 EXPECT_TRUE(response->headers); | 1195 EXPECT_TRUE(response->headers); |
1196 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1196 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
1197 EXPECT_TRUE(response->proxy_server.IsEmpty()); | 1197 EXPECT_TRUE(response->proxy_server.is_direct()); |
1198 | 1198 |
1199 std::string response_data; | 1199 std::string response_data; |
1200 rv = ReadTransaction(&trans, &response_data); | 1200 rv = ReadTransaction(&trans, &response_data); |
1201 EXPECT_THAT(rv, IsOk()); | 1201 EXPECT_THAT(rv, IsOk()); |
1202 EXPECT_EQ(kExpectedResponseData[i], response_data); | 1202 EXPECT_EQ(kExpectedResponseData[i], response_data); |
1203 } | 1203 } |
1204 } | 1204 } |
1205 | 1205 |
1206 TEST_F(HttpNetworkTransactionTest, Ignores100) { | 1206 TEST_F(HttpNetworkTransactionTest, Ignores100) { |
1207 std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 1207 std::vector<std::unique_ptr<UploadElementReader>> element_readers; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 first_socket_log_id = load_timing_info.socket_log_id; | 1419 first_socket_log_id = load_timing_info.socket_log_id; |
1420 } else { | 1420 } else { |
1421 // The second request should be using a new socket. | 1421 // The second request should be using a new socket. |
1422 EXPECT_NE(first_socket_log_id, load_timing_info.socket_log_id); | 1422 EXPECT_NE(first_socket_log_id, load_timing_info.socket_log_id); |
1423 } | 1423 } |
1424 | 1424 |
1425 const HttpResponseInfo* response = trans.GetResponseInfo(); | 1425 const HttpResponseInfo* response = trans.GetResponseInfo(); |
1426 ASSERT_TRUE(response); | 1426 ASSERT_TRUE(response); |
1427 | 1427 |
1428 EXPECT_TRUE(response->headers); | 1428 EXPECT_TRUE(response->headers); |
| 1429 EXPECT_TRUE(response->proxy_server.is_direct()); |
1429 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1430 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
1430 | 1431 |
1431 std::string response_data; | 1432 std::string response_data; |
1432 rv = ReadTransaction(&trans, &response_data); | 1433 rv = ReadTransaction(&trans, &response_data); |
1433 EXPECT_THAT(rv, IsOk()); | 1434 EXPECT_THAT(rv, IsOk()); |
1434 EXPECT_EQ(kExpectedResponseData[i], response_data); | 1435 EXPECT_EQ(kExpectedResponseData[i], response_data); |
1435 } | 1436 } |
1436 } | 1437 } |
1437 | 1438 |
1438 void HttpNetworkTransactionTest::PreconnectErrorResendRequestTest( | 1439 void HttpNetworkTransactionTest::PreconnectErrorResendRequestTest( |
(...skipping 2752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4191 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 4192 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4192 | 4193 |
4193 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); | 4194 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); |
4194 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4195 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
4195 | 4196 |
4196 rv = callback1.WaitForResult(); | 4197 rv = callback1.WaitForResult(); |
4197 EXPECT_THAT(rv, IsOk()); | 4198 EXPECT_THAT(rv, IsOk()); |
4198 | 4199 |
4199 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 4200 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
4200 ASSERT_TRUE(response1); | 4201 ASSERT_TRUE(response1); |
| 4202 EXPECT_TRUE(response1->proxy_server.is_http()); |
4201 ASSERT_TRUE(response1->headers); | 4203 ASSERT_TRUE(response1->headers); |
4202 EXPECT_EQ(1, response1->headers->GetContentLength()); | 4204 EXPECT_EQ(1, response1->headers->GetContentLength()); |
4203 | 4205 |
4204 LoadTimingInfo load_timing_info1; | 4206 LoadTimingInfo load_timing_info1; |
4205 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); | 4207 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); |
4206 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_SSL_TIMES); | 4208 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_SSL_TIMES); |
4207 | 4209 |
4208 trans1.reset(); | 4210 trans1.reset(); |
4209 | 4211 |
4210 TestCompletionCallback callback2; | 4212 TestCompletionCallback callback2; |
4211 std::unique_ptr<HttpNetworkTransaction> trans2( | 4213 std::unique_ptr<HttpNetworkTransaction> trans2( |
4212 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 4214 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4213 | 4215 |
4214 rv = trans2->Start(&request2, callback2.callback(), log.bound()); | 4216 rv = trans2->Start(&request2, callback2.callback(), log.bound()); |
4215 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4217 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
4216 | 4218 |
4217 rv = callback2.WaitForResult(); | 4219 rv = callback2.WaitForResult(); |
4218 EXPECT_THAT(rv, IsOk()); | 4220 EXPECT_THAT(rv, IsOk()); |
4219 | 4221 |
4220 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 4222 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
4221 ASSERT_TRUE(response2); | 4223 ASSERT_TRUE(response2); |
| 4224 EXPECT_TRUE(response2->proxy_server.is_http()); |
4222 ASSERT_TRUE(response2->headers); | 4225 ASSERT_TRUE(response2->headers); |
4223 EXPECT_EQ(2, response2->headers->GetContentLength()); | 4226 EXPECT_EQ(2, response2->headers->GetContentLength()); |
4224 | 4227 |
4225 LoadTimingInfo load_timing_info2; | 4228 LoadTimingInfo load_timing_info2; |
4226 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); | 4229 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); |
4227 TestLoadTimingReused(load_timing_info2); | 4230 TestLoadTimingReused(load_timing_info2); |
4228 | 4231 |
4229 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); | 4232 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); |
4230 | 4233 |
4231 trans2.reset(); | 4234 trans2.reset(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4375 EXPECT_THAT(rv, IsOk()); | 4378 EXPECT_THAT(rv, IsOk()); |
4376 | 4379 |
4377 LoadTimingInfo load_timing_info; | 4380 LoadTimingInfo load_timing_info; |
4378 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 4381 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
4379 TestLoadTimingNotReused(load_timing_info, | 4382 TestLoadTimingNotReused(load_timing_info, |
4380 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 4383 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
4381 | 4384 |
4382 const HttpResponseInfo* response = trans.GetResponseInfo(); | 4385 const HttpResponseInfo* response = trans.GetResponseInfo(); |
4383 ASSERT_TRUE(response); | 4386 ASSERT_TRUE(response); |
4384 | 4387 |
| 4388 EXPECT_TRUE(response->proxy_server.is_https()); |
4385 EXPECT_TRUE(response->headers->IsKeepAlive()); | 4389 EXPECT_TRUE(response->headers->IsKeepAlive()); |
4386 EXPECT_EQ(200, response->headers->response_code()); | 4390 EXPECT_EQ(200, response->headers->response_code()); |
4387 EXPECT_EQ(100, response->headers->GetContentLength()); | 4391 EXPECT_EQ(100, response->headers->GetContentLength()); |
4388 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 4392 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
4389 | 4393 |
4390 // The password prompt info should not be set. | 4394 // The password prompt info should not be set. |
4391 EXPECT_FALSE(response->auth_challenge); | 4395 EXPECT_FALSE(response->auth_challenge); |
4392 } | 4396 } |
4393 | 4397 |
4394 // Test a SPDY get through an HTTPS Proxy. | 4398 // Test a SPDY get through an HTTPS Proxy. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4433 rv = callback1.WaitForResult(); | 4437 rv = callback1.WaitForResult(); |
4434 EXPECT_THAT(rv, IsOk()); | 4438 EXPECT_THAT(rv, IsOk()); |
4435 | 4439 |
4436 LoadTimingInfo load_timing_info; | 4440 LoadTimingInfo load_timing_info; |
4437 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 4441 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
4438 TestLoadTimingNotReused(load_timing_info, | 4442 TestLoadTimingNotReused(load_timing_info, |
4439 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 4443 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
4440 | 4444 |
4441 const HttpResponseInfo* response = trans.GetResponseInfo(); | 4445 const HttpResponseInfo* response = trans.GetResponseInfo(); |
4442 ASSERT_TRUE(response); | 4446 ASSERT_TRUE(response); |
| 4447 EXPECT_TRUE(response->proxy_server.is_https()); |
4443 ASSERT_TRUE(response->headers); | 4448 ASSERT_TRUE(response->headers); |
4444 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 4449 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
4445 | 4450 |
4446 std::string response_data; | 4451 std::string response_data; |
4447 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); | 4452 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); |
4448 EXPECT_EQ(kUploadData, response_data); | 4453 EXPECT_EQ(kUploadData, response_data); |
4449 } | 4454 } |
4450 | 4455 |
4451 // Verifies that a session which races and wins against the owning transaction | 4456 // Verifies that a session which races and wins against the owning transaction |
4452 // (completing prior to host resolution), doesn't fail the transaction. | 4457 // (completing prior to host resolution), doesn't fail the transaction. |
(...skipping 3097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7550 | 7555 |
7551 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); | 7556 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); |
7552 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 7557 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
7553 | 7558 |
7554 rv = callback.WaitForResult(); | 7559 rv = callback.WaitForResult(); |
7555 EXPECT_THAT(rv, IsOk()); | 7560 EXPECT_THAT(rv, IsOk()); |
7556 const HttpResponseInfo* response = trans.GetResponseInfo(); | 7561 const HttpResponseInfo* response = trans.GetResponseInfo(); |
7557 | 7562 |
7558 ASSERT_TRUE(response); | 7563 ASSERT_TRUE(response); |
7559 | 7564 |
| 7565 EXPECT_TRUE(response->proxy_server.is_https()); |
7560 EXPECT_TRUE(response->headers->IsKeepAlive()); | 7566 EXPECT_TRUE(response->headers->IsKeepAlive()); |
7561 EXPECT_EQ(200, response->headers->response_code()); | 7567 EXPECT_EQ(200, response->headers->response_code()); |
7562 EXPECT_EQ(100, response->headers->GetContentLength()); | 7568 EXPECT_EQ(100, response->headers->GetContentLength()); |
7563 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 7569 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
7564 | 7570 |
7565 LoadTimingInfo load_timing_info; | 7571 LoadTimingInfo load_timing_info; |
7566 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 7572 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
7567 TestLoadTimingNotReusedWithPac(load_timing_info, | 7573 TestLoadTimingNotReusedWithPac(load_timing_info, |
7568 CONNECT_TIMING_HAS_SSL_TIMES); | 7574 CONNECT_TIMING_HAS_SSL_TIMES); |
7569 } | 7575 } |
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8713 | 8719 |
8714 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); | 8720 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); |
8715 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 8721 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
8716 | 8722 |
8717 rv = callback.WaitForResult(); | 8723 rv = callback.WaitForResult(); |
8718 EXPECT_THAT(rv, IsOk()); | 8724 EXPECT_THAT(rv, IsOk()); |
8719 | 8725 |
8720 const HttpResponseInfo* response = trans.GetResponseInfo(); | 8726 const HttpResponseInfo* response = trans.GetResponseInfo(); |
8721 ASSERT_TRUE(response); | 8727 ASSERT_TRUE(response); |
8722 | 8728 |
| 8729 EXPECT_EQ(ProxyServer::SCHEME_SOCKS4, response->proxy_server.scheme()); |
8723 LoadTimingInfo load_timing_info; | 8730 LoadTimingInfo load_timing_info; |
8724 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 8731 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
8725 TestLoadTimingNotReusedWithPac(load_timing_info, | 8732 TestLoadTimingNotReusedWithPac(load_timing_info, |
8726 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 8733 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
8727 | 8734 |
8728 std::string response_text; | 8735 std::string response_text; |
8729 rv = ReadTransaction(&trans, &response_text); | 8736 rv = ReadTransaction(&trans, &response_text); |
8730 EXPECT_THAT(rv, IsOk()); | 8737 EXPECT_THAT(rv, IsOk()); |
8731 EXPECT_EQ("Payload", response_text); | 8738 EXPECT_EQ("Payload", response_text); |
8732 } | 8739 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8780 rv = callback.WaitForResult(); | 8787 rv = callback.WaitForResult(); |
8781 EXPECT_THAT(rv, IsOk()); | 8788 EXPECT_THAT(rv, IsOk()); |
8782 | 8789 |
8783 LoadTimingInfo load_timing_info; | 8790 LoadTimingInfo load_timing_info; |
8784 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 8791 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
8785 TestLoadTimingNotReusedWithPac(load_timing_info, | 8792 TestLoadTimingNotReusedWithPac(load_timing_info, |
8786 CONNECT_TIMING_HAS_SSL_TIMES); | 8793 CONNECT_TIMING_HAS_SSL_TIMES); |
8787 | 8794 |
8788 const HttpResponseInfo* response = trans.GetResponseInfo(); | 8795 const HttpResponseInfo* response = trans.GetResponseInfo(); |
8789 ASSERT_TRUE(response); | 8796 ASSERT_TRUE(response); |
| 8797 EXPECT_EQ(ProxyServer::SCHEME_SOCKS4, response->proxy_server.scheme()); |
8790 | 8798 |
8791 std::string response_text; | 8799 std::string response_text; |
8792 rv = ReadTransaction(&trans, &response_text); | 8800 rv = ReadTransaction(&trans, &response_text); |
8793 EXPECT_THAT(rv, IsOk()); | 8801 EXPECT_THAT(rv, IsOk()); |
8794 EXPECT_EQ("Payload", response_text); | 8802 EXPECT_EQ("Payload", response_text); |
8795 } | 8803 } |
8796 | 8804 |
8797 TEST_F(HttpNetworkTransactionTest, SOCKS4_HTTP_GET_no_PAC) { | 8805 TEST_F(HttpNetworkTransactionTest, SOCKS4_HTTP_GET_no_PAC) { |
8798 HttpRequestInfo request; | 8806 HttpRequestInfo request; |
8799 request.method = "GET"; | 8807 request.method = "GET"; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8904 TestCompletionCallback callback; | 8912 TestCompletionCallback callback; |
8905 | 8913 |
8906 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); | 8914 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); |
8907 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 8915 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
8908 | 8916 |
8909 rv = callback.WaitForResult(); | 8917 rv = callback.WaitForResult(); |
8910 EXPECT_THAT(rv, IsOk()); | 8918 EXPECT_THAT(rv, IsOk()); |
8911 | 8919 |
8912 const HttpResponseInfo* response = trans.GetResponseInfo(); | 8920 const HttpResponseInfo* response = trans.GetResponseInfo(); |
8913 ASSERT_TRUE(response); | 8921 ASSERT_TRUE(response); |
| 8922 EXPECT_EQ(ProxyServer::SCHEME_SOCKS5, response->proxy_server.scheme()); |
8914 | 8923 |
8915 LoadTimingInfo load_timing_info; | 8924 LoadTimingInfo load_timing_info; |
8916 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 8925 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
8917 TestLoadTimingNotReusedWithPac(load_timing_info, | 8926 TestLoadTimingNotReusedWithPac(load_timing_info, |
8918 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 8927 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
8919 | 8928 |
8920 std::string response_text; | 8929 std::string response_text; |
8921 rv = ReadTransaction(&trans, &response_text); | 8930 rv = ReadTransaction(&trans, &response_text); |
8922 EXPECT_THAT(rv, IsOk()); | 8931 EXPECT_THAT(rv, IsOk()); |
8923 EXPECT_EQ("Payload", response_text); | 8932 EXPECT_EQ("Payload", response_text); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8980 TestCompletionCallback callback; | 8989 TestCompletionCallback callback; |
8981 | 8990 |
8982 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); | 8991 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); |
8983 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 8992 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
8984 | 8993 |
8985 rv = callback.WaitForResult(); | 8994 rv = callback.WaitForResult(); |
8986 EXPECT_THAT(rv, IsOk()); | 8995 EXPECT_THAT(rv, IsOk()); |
8987 | 8996 |
8988 const HttpResponseInfo* response = trans.GetResponseInfo(); | 8997 const HttpResponseInfo* response = trans.GetResponseInfo(); |
8989 ASSERT_TRUE(response); | 8998 ASSERT_TRUE(response); |
| 8999 EXPECT_EQ(ProxyServer::SCHEME_SOCKS5, response->proxy_server.scheme()); |
8990 | 9000 |
8991 LoadTimingInfo load_timing_info; | 9001 LoadTimingInfo load_timing_info; |
8992 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 9002 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
8993 TestLoadTimingNotReusedWithPac(load_timing_info, | 9003 TestLoadTimingNotReusedWithPac(load_timing_info, |
8994 CONNECT_TIMING_HAS_SSL_TIMES); | 9004 CONNECT_TIMING_HAS_SSL_TIMES); |
8995 | 9005 |
8996 std::string response_text; | 9006 std::string response_text; |
8997 rv = ReadTransaction(&trans, &response_text); | 9007 rv = ReadTransaction(&trans, &response_text); |
8998 EXPECT_THAT(rv, IsOk()); | 9008 EXPECT_THAT(rv, IsOk()); |
8999 EXPECT_EQ("Payload", response_text); | 9009 EXPECT_EQ("Payload", response_text); |
(...skipping 3431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12431 rv = callback1.WaitForResult(); | 12441 rv = callback1.WaitForResult(); |
12432 EXPECT_THAT(rv, IsOk()); | 12442 EXPECT_THAT(rv, IsOk()); |
12433 | 12443 |
12434 const HttpResponseInfo* response = trans.GetResponseInfo(); | 12444 const HttpResponseInfo* response = trans.GetResponseInfo(); |
12435 ASSERT_TRUE(response); | 12445 ASSERT_TRUE(response); |
12436 | 12446 |
12437 EXPECT_TRUE(response->headers->IsKeepAlive()); | 12447 EXPECT_TRUE(response->headers->IsKeepAlive()); |
12438 EXPECT_EQ(200, response->headers->response_code()); | 12448 EXPECT_EQ(200, response->headers->response_code()); |
12439 EXPECT_EQ(100, response->headers->GetContentLength()); | 12449 EXPECT_EQ(100, response->headers->GetContentLength()); |
12440 EXPECT_TRUE(response->was_fetched_via_proxy); | 12450 EXPECT_TRUE(response->was_fetched_via_proxy); |
12441 EXPECT_TRUE( | 12451 EXPECT_EQ(ProxyServer(ProxyServer::SCHEME_HTTP, |
12442 response->proxy_server.Equals(HostPortPair::FromString("myproxy:70"))); | 12452 HostPortPair::FromString("myproxy:70")), |
| 12453 response->proxy_server); |
12443 EXPECT_TRUE(headers_handler.observed_before_headers_sent()); | 12454 EXPECT_TRUE(headers_handler.observed_before_headers_sent()); |
12444 EXPECT_TRUE(headers_handler.observed_before_headers_sent_with_proxy()); | 12455 EXPECT_TRUE(headers_handler.observed_before_headers_sent_with_proxy()); |
12445 EXPECT_EQ("myproxy:70", headers_handler.observed_proxy_server_uri()); | 12456 EXPECT_EQ("myproxy:70", headers_handler.observed_proxy_server_uri()); |
12446 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 12457 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
12447 | 12458 |
12448 LoadTimingInfo load_timing_info; | 12459 LoadTimingInfo load_timing_info; |
12449 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 12460 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
12450 TestLoadTimingNotReusedWithPac(load_timing_info, | 12461 TestLoadTimingNotReusedWithPac(load_timing_info, |
12451 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 12462 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
12452 } | 12463 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12513 NetLogEventPhase::NONE); | 12524 NetLogEventPhase::NONE); |
12514 | 12525 |
12515 const HttpResponseInfo* response = trans.GetResponseInfo(); | 12526 const HttpResponseInfo* response = trans.GetResponseInfo(); |
12516 ASSERT_TRUE(response); | 12527 ASSERT_TRUE(response); |
12517 | 12528 |
12518 EXPECT_TRUE(response->headers->IsKeepAlive()); | 12529 EXPECT_TRUE(response->headers->IsKeepAlive()); |
12519 EXPECT_EQ(200, response->headers->response_code()); | 12530 EXPECT_EQ(200, response->headers->response_code()); |
12520 EXPECT_EQ(100, response->headers->GetContentLength()); | 12531 EXPECT_EQ(100, response->headers->GetContentLength()); |
12521 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 12532 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
12522 EXPECT_TRUE(response->was_fetched_via_proxy); | 12533 EXPECT_TRUE(response->was_fetched_via_proxy); |
12523 EXPECT_TRUE( | 12534 EXPECT_EQ(ProxyServer(ProxyServer::SCHEME_HTTP, |
12524 response->proxy_server.Equals(HostPortPair::FromString("myproxy:70"))); | 12535 HostPortPair::FromString("myproxy:70")), |
| 12536 response->proxy_server); |
12525 EXPECT_TRUE(headers_handler.observed_before_headers_sent()); | 12537 EXPECT_TRUE(headers_handler.observed_before_headers_sent()); |
12526 EXPECT_TRUE(headers_handler.observed_before_headers_sent_with_proxy()); | 12538 EXPECT_TRUE(headers_handler.observed_before_headers_sent_with_proxy()); |
12527 EXPECT_EQ("myproxy:70", headers_handler.observed_proxy_server_uri()); | 12539 EXPECT_EQ("myproxy:70", headers_handler.observed_proxy_server_uri()); |
12528 | 12540 |
12529 LoadTimingInfo load_timing_info; | 12541 LoadTimingInfo load_timing_info; |
12530 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 12542 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
12531 TestLoadTimingNotReusedWithPac(load_timing_info, | 12543 TestLoadTimingNotReusedWithPac(load_timing_info, |
12532 CONNECT_TIMING_HAS_SSL_TIMES); | 12544 CONNECT_TIMING_HAS_SSL_TIMES); |
12533 } | 12545 } |
12534 | 12546 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12591 NetLogEventPhase::NONE); | 12603 NetLogEventPhase::NONE); |
12592 | 12604 |
12593 const HttpResponseInfo* response = trans.GetResponseInfo(); | 12605 const HttpResponseInfo* response = trans.GetResponseInfo(); |
12594 ASSERT_TRUE(response); | 12606 ASSERT_TRUE(response); |
12595 | 12607 |
12596 EXPECT_TRUE(response->headers->IsKeepAlive()); | 12608 EXPECT_TRUE(response->headers->IsKeepAlive()); |
12597 EXPECT_EQ(200, response->headers->response_code()); | 12609 EXPECT_EQ(200, response->headers->response_code()); |
12598 EXPECT_EQ(100, response->headers->GetContentLength()); | 12610 EXPECT_EQ(100, response->headers->GetContentLength()); |
12599 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 12611 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
12600 EXPECT_TRUE(response->was_fetched_via_proxy); | 12612 EXPECT_TRUE(response->was_fetched_via_proxy); |
12601 EXPECT_TRUE( | 12613 EXPECT_EQ(ProxyServer(ProxyServer::SCHEME_HTTP, |
12602 response->proxy_server.Equals(HostPortPair::FromString("myproxy:70"))); | 12614 HostPortPair::FromString("myproxy:70")), |
| 12615 response->proxy_server); |
12603 | 12616 |
12604 LoadTimingInfo load_timing_info; | 12617 LoadTimingInfo load_timing_info; |
12605 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 12618 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
12606 TestLoadTimingNotReusedWithPac(load_timing_info, | 12619 TestLoadTimingNotReusedWithPac(load_timing_info, |
12607 CONNECT_TIMING_HAS_SSL_TIMES); | 12620 CONNECT_TIMING_HAS_SSL_TIMES); |
12608 } | 12621 } |
12609 | 12622 |
12610 // Test a basic HTTPS GET request through a proxy, but the server hangs up | 12623 // Test a basic HTTPS GET request through a proxy, but the server hangs up |
12611 // while establishing the tunnel. | 12624 // while establishing the tunnel. |
12612 TEST_F(HttpNetworkTransactionTest, ProxyTunnelGetHangup) { | 12625 TEST_F(HttpNetworkTransactionTest, ProxyTunnelGetHangup) { |
(...skipping 3256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15869 base::RunLoop().RunUntilIdle(); | 15882 base::RunLoop().RunUntilIdle(); |
15870 | 15883 |
15871 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 15884 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
15872 HttpRequestHeaders headers; | 15885 HttpRequestHeaders headers; |
15873 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 15886 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
15874 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 15887 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
15875 } | 15888 } |
15876 #endif // !defined(OS_IOS) | 15889 #endif // !defined(OS_IOS) |
15877 | 15890 |
15878 } // namespace net | 15891 } // namespace net |
OLD | NEW |