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 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 | 1065 |
1066 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 1066 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
1067 | 1067 |
1068 const HttpResponseInfo* response = trans.GetResponseInfo(); | 1068 const HttpResponseInfo* response = trans.GetResponseInfo(); |
1069 ASSERT_TRUE(response); | 1069 ASSERT_TRUE(response); |
1070 ASSERT_TRUE(response->headers); | 1070 ASSERT_TRUE(response->headers); |
1071 EXPECT_EQ("HTTP/1.1 302 Redirect", response->headers->GetStatusLine()); | 1071 EXPECT_EQ("HTTP/1.1 302 Redirect", response->headers->GetStatusLine()); |
1072 std::string url; | 1072 std::string url; |
1073 EXPECT_TRUE(response->headers->IsRedirect(&url)); | 1073 EXPECT_TRUE(response->headers->IsRedirect(&url)); |
1074 EXPECT_EQ("http://good.com/", url); | 1074 EXPECT_EQ("http://good.com/", url); |
1075 EXPECT_TRUE(response->proxy_server.IsEmpty()); | 1075 EXPECT_TRUE(response->proxy_server.is_direct()); |
1076 } | 1076 } |
1077 | 1077 |
1078 // Checks that two distinct Location headers result in an error. | 1078 // Checks that two distinct Location headers result in an error. |
1079 TEST_F(HttpNetworkTransactionTest, TwoDistinctLocationHeaders) { | 1079 TEST_F(HttpNetworkTransactionTest, TwoDistinctLocationHeaders) { |
1080 MockRead data_reads[] = { | 1080 MockRead data_reads[] = { |
1081 MockRead("HTTP/1.1 302 Redirect\r\n"), | 1081 MockRead("HTTP/1.1 302 Redirect\r\n"), |
1082 MockRead("Location: http://good.com/\r\n"), | 1082 MockRead("Location: http://good.com/\r\n"), |
1083 MockRead("Location: http://evil.com/\r\n"), | 1083 MockRead("Location: http://evil.com/\r\n"), |
1084 MockRead("Content-Length: 0\r\n\r\n"), | 1084 MockRead("Content-Length: 0\r\n\r\n"), |
1085 MockRead(SYNCHRONOUS, OK), | 1085 MockRead(SYNCHRONOUS, OK), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 rv = callback1.WaitForResult(); | 1129 rv = callback1.WaitForResult(); |
1130 EXPECT_THAT(rv, IsOk()); | 1130 EXPECT_THAT(rv, IsOk()); |
1131 | 1131 |
1132 const HttpResponseInfo* response = trans.GetResponseInfo(); | 1132 const HttpResponseInfo* response = trans.GetResponseInfo(); |
1133 ASSERT_TRUE(response); | 1133 ASSERT_TRUE(response); |
1134 | 1134 |
1135 // Check that the headers got parsed. | 1135 // Check that the headers got parsed. |
1136 EXPECT_TRUE(response->headers); | 1136 EXPECT_TRUE(response->headers); |
1137 EXPECT_EQ(1234, response->headers->GetContentLength()); | 1137 EXPECT_EQ(1234, response->headers->GetContentLength()); |
1138 EXPECT_EQ("HTTP/1.1 404 Not Found", response->headers->GetStatusLine()); | 1138 EXPECT_EQ("HTTP/1.1 404 Not Found", response->headers->GetStatusLine()); |
1139 EXPECT_TRUE(response->proxy_server.IsEmpty()); | 1139 EXPECT_TRUE(response->proxy_server.is_direct()); |
1140 EXPECT_TRUE(headers_handler.observed_before_headers_sent()); | 1140 EXPECT_TRUE(headers_handler.observed_before_headers_sent()); |
1141 EXPECT_FALSE(headers_handler.observed_before_headers_sent_with_proxy()); | 1141 EXPECT_FALSE(headers_handler.observed_before_headers_sent_with_proxy()); |
1142 | 1142 |
1143 std::string server_header; | 1143 std::string server_header; |
1144 size_t iter = 0; | 1144 size_t iter = 0; |
1145 bool has_server_header = response->headers->EnumerateHeader( | 1145 bool has_server_header = response->headers->EnumerateHeader( |
1146 &iter, "Server", &server_header); | 1146 &iter, "Server", &server_header); |
1147 EXPECT_TRUE(has_server_header); | 1147 EXPECT_TRUE(has_server_header); |
1148 EXPECT_EQ("Blah", server_header); | 1148 EXPECT_EQ("Blah", server_header); |
1149 | 1149 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 1186 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
1187 | 1187 |
1188 rv = callback.WaitForResult(); | 1188 rv = callback.WaitForResult(); |
1189 EXPECT_THAT(rv, IsOk()); | 1189 EXPECT_THAT(rv, IsOk()); |
1190 | 1190 |
1191 const HttpResponseInfo* response = trans.GetResponseInfo(); | 1191 const HttpResponseInfo* response = trans.GetResponseInfo(); |
1192 ASSERT_TRUE(response); | 1192 ASSERT_TRUE(response); |
1193 | 1193 |
1194 EXPECT_TRUE(response->headers); | 1194 EXPECT_TRUE(response->headers); |
1195 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1195 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
1196 EXPECT_TRUE(response->proxy_server.IsEmpty()); | 1196 EXPECT_TRUE(response->proxy_server.is_direct()); |
1197 | 1197 |
1198 std::string response_data; | 1198 std::string response_data; |
1199 rv = ReadTransaction(&trans, &response_data); | 1199 rv = ReadTransaction(&trans, &response_data); |
1200 EXPECT_THAT(rv, IsOk()); | 1200 EXPECT_THAT(rv, IsOk()); |
1201 EXPECT_EQ(kExpectedResponseData[i], response_data); | 1201 EXPECT_EQ(kExpectedResponseData[i], response_data); |
1202 } | 1202 } |
1203 } | 1203 } |
1204 | 1204 |
1205 TEST_F(HttpNetworkTransactionTest, Ignores100) { | 1205 TEST_F(HttpNetworkTransactionTest, Ignores100) { |
1206 std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 1206 std::vector<std::unique_ptr<UploadElementReader>> element_readers; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1418 first_socket_log_id = load_timing_info.socket_log_id; | 1418 first_socket_log_id = load_timing_info.socket_log_id; |
1419 } else { | 1419 } else { |
1420 // The second request should be using a new socket. | 1420 // The second request should be using a new socket. |
1421 EXPECT_NE(first_socket_log_id, load_timing_info.socket_log_id); | 1421 EXPECT_NE(first_socket_log_id, load_timing_info.socket_log_id); |
1422 } | 1422 } |
1423 | 1423 |
1424 const HttpResponseInfo* response = trans.GetResponseInfo(); | 1424 const HttpResponseInfo* response = trans.GetResponseInfo(); |
1425 ASSERT_TRUE(response); | 1425 ASSERT_TRUE(response); |
1426 | 1426 |
1427 EXPECT_TRUE(response->headers); | 1427 EXPECT_TRUE(response->headers); |
| 1428 EXPECT_TRUE(response->proxy_server.is_direct()); |
1428 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1429 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
1429 | 1430 |
1430 std::string response_data; | 1431 std::string response_data; |
1431 rv = ReadTransaction(&trans, &response_data); | 1432 rv = ReadTransaction(&trans, &response_data); |
1432 EXPECT_THAT(rv, IsOk()); | 1433 EXPECT_THAT(rv, IsOk()); |
1433 EXPECT_EQ(kExpectedResponseData[i], response_data); | 1434 EXPECT_EQ(kExpectedResponseData[i], response_data); |
1434 } | 1435 } |
1435 } | 1436 } |
1436 | 1437 |
1437 void HttpNetworkTransactionTest::PreconnectErrorResendRequestTest( | 1438 void HttpNetworkTransactionTest::PreconnectErrorResendRequestTest( |
(...skipping 2752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4190 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 4191 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4191 | 4192 |
4192 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); | 4193 int rv = trans1->Start(&request1, callback1.callback(), log.bound()); |
4193 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4194 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
4194 | 4195 |
4195 rv = callback1.WaitForResult(); | 4196 rv = callback1.WaitForResult(); |
4196 EXPECT_THAT(rv, IsOk()); | 4197 EXPECT_THAT(rv, IsOk()); |
4197 | 4198 |
4198 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); | 4199 const HttpResponseInfo* response1 = trans1->GetResponseInfo(); |
4199 ASSERT_TRUE(response1); | 4200 ASSERT_TRUE(response1); |
| 4201 EXPECT_TRUE(response1->proxy_server.is_http()); |
4200 ASSERT_TRUE(response1->headers); | 4202 ASSERT_TRUE(response1->headers); |
4201 EXPECT_EQ(1, response1->headers->GetContentLength()); | 4203 EXPECT_EQ(1, response1->headers->GetContentLength()); |
4202 | 4204 |
4203 LoadTimingInfo load_timing_info1; | 4205 LoadTimingInfo load_timing_info1; |
4204 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); | 4206 EXPECT_TRUE(trans1->GetLoadTimingInfo(&load_timing_info1)); |
4205 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_SSL_TIMES); | 4207 TestLoadTimingNotReused(load_timing_info1, CONNECT_TIMING_HAS_SSL_TIMES); |
4206 | 4208 |
4207 trans1.reset(); | 4209 trans1.reset(); |
4208 | 4210 |
4209 TestCompletionCallback callback2; | 4211 TestCompletionCallback callback2; |
4210 std::unique_ptr<HttpNetworkTransaction> trans2( | 4212 std::unique_ptr<HttpNetworkTransaction> trans2( |
4211 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 4213 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
4212 | 4214 |
4213 rv = trans2->Start(&request2, callback2.callback(), log.bound()); | 4215 rv = trans2->Start(&request2, callback2.callback(), log.bound()); |
4214 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 4216 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
4215 | 4217 |
4216 rv = callback2.WaitForResult(); | 4218 rv = callback2.WaitForResult(); |
4217 EXPECT_THAT(rv, IsOk()); | 4219 EXPECT_THAT(rv, IsOk()); |
4218 | 4220 |
4219 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); | 4221 const HttpResponseInfo* response2 = trans2->GetResponseInfo(); |
4220 ASSERT_TRUE(response2); | 4222 ASSERT_TRUE(response2); |
| 4223 EXPECT_TRUE(response2->proxy_server.is_http()); |
4221 ASSERT_TRUE(response2->headers); | 4224 ASSERT_TRUE(response2->headers); |
4222 EXPECT_EQ(2, response2->headers->GetContentLength()); | 4225 EXPECT_EQ(2, response2->headers->GetContentLength()); |
4223 | 4226 |
4224 LoadTimingInfo load_timing_info2; | 4227 LoadTimingInfo load_timing_info2; |
4225 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); | 4228 EXPECT_TRUE(trans2->GetLoadTimingInfo(&load_timing_info2)); |
4226 TestLoadTimingReused(load_timing_info2); | 4229 TestLoadTimingReused(load_timing_info2); |
4227 | 4230 |
4228 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); | 4231 EXPECT_EQ(load_timing_info1.socket_log_id, load_timing_info2.socket_log_id); |
4229 | 4232 |
4230 trans2.reset(); | 4233 trans2.reset(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4374 EXPECT_THAT(rv, IsOk()); | 4377 EXPECT_THAT(rv, IsOk()); |
4375 | 4378 |
4376 LoadTimingInfo load_timing_info; | 4379 LoadTimingInfo load_timing_info; |
4377 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 4380 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
4378 TestLoadTimingNotReused(load_timing_info, | 4381 TestLoadTimingNotReused(load_timing_info, |
4379 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 4382 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
4380 | 4383 |
4381 const HttpResponseInfo* response = trans.GetResponseInfo(); | 4384 const HttpResponseInfo* response = trans.GetResponseInfo(); |
4382 ASSERT_TRUE(response); | 4385 ASSERT_TRUE(response); |
4383 | 4386 |
| 4387 EXPECT_TRUE(response->proxy_server.is_https()); |
4384 EXPECT_TRUE(response->headers->IsKeepAlive()); | 4388 EXPECT_TRUE(response->headers->IsKeepAlive()); |
4385 EXPECT_EQ(200, response->headers->response_code()); | 4389 EXPECT_EQ(200, response->headers->response_code()); |
4386 EXPECT_EQ(100, response->headers->GetContentLength()); | 4390 EXPECT_EQ(100, response->headers->GetContentLength()); |
4387 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 4391 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
4388 | 4392 |
4389 // The password prompt info should not be set. | 4393 // The password prompt info should not be set. |
4390 EXPECT_FALSE(response->auth_challenge); | 4394 EXPECT_FALSE(response->auth_challenge); |
4391 } | 4395 } |
4392 | 4396 |
4393 // Test a SPDY get through an HTTPS Proxy. | 4397 // Test a SPDY get through an HTTPS Proxy. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4432 rv = callback1.WaitForResult(); | 4436 rv = callback1.WaitForResult(); |
4433 EXPECT_THAT(rv, IsOk()); | 4437 EXPECT_THAT(rv, IsOk()); |
4434 | 4438 |
4435 LoadTimingInfo load_timing_info; | 4439 LoadTimingInfo load_timing_info; |
4436 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 4440 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
4437 TestLoadTimingNotReused(load_timing_info, | 4441 TestLoadTimingNotReused(load_timing_info, |
4438 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 4442 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
4439 | 4443 |
4440 const HttpResponseInfo* response = trans.GetResponseInfo(); | 4444 const HttpResponseInfo* response = trans.GetResponseInfo(); |
4441 ASSERT_TRUE(response); | 4445 ASSERT_TRUE(response); |
| 4446 EXPECT_TRUE(response->proxy_server.is_https()); |
4442 ASSERT_TRUE(response->headers); | 4447 ASSERT_TRUE(response->headers); |
4443 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); | 4448 EXPECT_EQ("HTTP/1.1 200", response->headers->GetStatusLine()); |
4444 | 4449 |
4445 std::string response_data; | 4450 std::string response_data; |
4446 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); | 4451 ASSERT_THAT(ReadTransaction(&trans, &response_data), IsOk()); |
4447 EXPECT_EQ(kUploadData, response_data); | 4452 EXPECT_EQ(kUploadData, response_data); |
4448 } | 4453 } |
4449 | 4454 |
4450 // Verifies that a session which races and wins against the owning transaction | 4455 // Verifies that a session which races and wins against the owning transaction |
4451 // (completing prior to host resolution), doesn't fail the transaction. | 4456 // (completing prior to host resolution), doesn't fail the transaction. |
(...skipping 3097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7549 | 7554 |
7550 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); | 7555 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); |
7551 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 7556 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
7552 | 7557 |
7553 rv = callback.WaitForResult(); | 7558 rv = callback.WaitForResult(); |
7554 EXPECT_THAT(rv, IsOk()); | 7559 EXPECT_THAT(rv, IsOk()); |
7555 const HttpResponseInfo* response = trans.GetResponseInfo(); | 7560 const HttpResponseInfo* response = trans.GetResponseInfo(); |
7556 | 7561 |
7557 ASSERT_TRUE(response); | 7562 ASSERT_TRUE(response); |
7558 | 7563 |
| 7564 EXPECT_TRUE(response->proxy_server.is_https()); |
7559 EXPECT_TRUE(response->headers->IsKeepAlive()); | 7565 EXPECT_TRUE(response->headers->IsKeepAlive()); |
7560 EXPECT_EQ(200, response->headers->response_code()); | 7566 EXPECT_EQ(200, response->headers->response_code()); |
7561 EXPECT_EQ(100, response->headers->GetContentLength()); | 7567 EXPECT_EQ(100, response->headers->GetContentLength()); |
7562 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 7568 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
7563 | 7569 |
7564 LoadTimingInfo load_timing_info; | 7570 LoadTimingInfo load_timing_info; |
7565 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 7571 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
7566 TestLoadTimingNotReusedWithPac(load_timing_info, | 7572 TestLoadTimingNotReusedWithPac(load_timing_info, |
7567 CONNECT_TIMING_HAS_SSL_TIMES); | 7573 CONNECT_TIMING_HAS_SSL_TIMES); |
7568 } | 7574 } |
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8712 | 8718 |
8713 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); | 8719 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); |
8714 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 8720 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
8715 | 8721 |
8716 rv = callback.WaitForResult(); | 8722 rv = callback.WaitForResult(); |
8717 EXPECT_THAT(rv, IsOk()); | 8723 EXPECT_THAT(rv, IsOk()); |
8718 | 8724 |
8719 const HttpResponseInfo* response = trans.GetResponseInfo(); | 8725 const HttpResponseInfo* response = trans.GetResponseInfo(); |
8720 ASSERT_TRUE(response); | 8726 ASSERT_TRUE(response); |
8721 | 8727 |
| 8728 EXPECT_TRUE(response->proxy_server.is_socks()); |
8722 LoadTimingInfo load_timing_info; | 8729 LoadTimingInfo load_timing_info; |
8723 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 8730 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
8724 TestLoadTimingNotReusedWithPac(load_timing_info, | 8731 TestLoadTimingNotReusedWithPac(load_timing_info, |
8725 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 8732 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
8726 | 8733 |
8727 std::string response_text; | 8734 std::string response_text; |
8728 rv = ReadTransaction(&trans, &response_text); | 8735 rv = ReadTransaction(&trans, &response_text); |
8729 EXPECT_THAT(rv, IsOk()); | 8736 EXPECT_THAT(rv, IsOk()); |
8730 EXPECT_EQ("Payload", response_text); | 8737 EXPECT_EQ("Payload", response_text); |
8731 } | 8738 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8779 rv = callback.WaitForResult(); | 8786 rv = callback.WaitForResult(); |
8780 EXPECT_THAT(rv, IsOk()); | 8787 EXPECT_THAT(rv, IsOk()); |
8781 | 8788 |
8782 LoadTimingInfo load_timing_info; | 8789 LoadTimingInfo load_timing_info; |
8783 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 8790 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
8784 TestLoadTimingNotReusedWithPac(load_timing_info, | 8791 TestLoadTimingNotReusedWithPac(load_timing_info, |
8785 CONNECT_TIMING_HAS_SSL_TIMES); | 8792 CONNECT_TIMING_HAS_SSL_TIMES); |
8786 | 8793 |
8787 const HttpResponseInfo* response = trans.GetResponseInfo(); | 8794 const HttpResponseInfo* response = trans.GetResponseInfo(); |
8788 ASSERT_TRUE(response); | 8795 ASSERT_TRUE(response); |
| 8796 EXPECT_TRUE(response->proxy_server.is_socks()); |
8789 | 8797 |
8790 std::string response_text; | 8798 std::string response_text; |
8791 rv = ReadTransaction(&trans, &response_text); | 8799 rv = ReadTransaction(&trans, &response_text); |
8792 EXPECT_THAT(rv, IsOk()); | 8800 EXPECT_THAT(rv, IsOk()); |
8793 EXPECT_EQ("Payload", response_text); | 8801 EXPECT_EQ("Payload", response_text); |
8794 } | 8802 } |
8795 | 8803 |
8796 TEST_F(HttpNetworkTransactionTest, SOCKS4_HTTP_GET_no_PAC) { | 8804 TEST_F(HttpNetworkTransactionTest, SOCKS4_HTTP_GET_no_PAC) { |
8797 HttpRequestInfo request; | 8805 HttpRequestInfo request; |
8798 request.method = "GET"; | 8806 request.method = "GET"; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8903 TestCompletionCallback callback; | 8911 TestCompletionCallback callback; |
8904 | 8912 |
8905 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); | 8913 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); |
8906 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 8914 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
8907 | 8915 |
8908 rv = callback.WaitForResult(); | 8916 rv = callback.WaitForResult(); |
8909 EXPECT_THAT(rv, IsOk()); | 8917 EXPECT_THAT(rv, IsOk()); |
8910 | 8918 |
8911 const HttpResponseInfo* response = trans.GetResponseInfo(); | 8919 const HttpResponseInfo* response = trans.GetResponseInfo(); |
8912 ASSERT_TRUE(response); | 8920 ASSERT_TRUE(response); |
| 8921 EXPECT_TRUE(response->proxy_server.is_socks()); |
8913 | 8922 |
8914 LoadTimingInfo load_timing_info; | 8923 LoadTimingInfo load_timing_info; |
8915 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 8924 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
8916 TestLoadTimingNotReusedWithPac(load_timing_info, | 8925 TestLoadTimingNotReusedWithPac(load_timing_info, |
8917 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 8926 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
8918 | 8927 |
8919 std::string response_text; | 8928 std::string response_text; |
8920 rv = ReadTransaction(&trans, &response_text); | 8929 rv = ReadTransaction(&trans, &response_text); |
8921 EXPECT_THAT(rv, IsOk()); | 8930 EXPECT_THAT(rv, IsOk()); |
8922 EXPECT_EQ("Payload", response_text); | 8931 EXPECT_EQ("Payload", response_text); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8979 TestCompletionCallback callback; | 8988 TestCompletionCallback callback; |
8980 | 8989 |
8981 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); | 8990 int rv = trans.Start(&request, callback.callback(), NetLogWithSource()); |
8982 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 8991 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
8983 | 8992 |
8984 rv = callback.WaitForResult(); | 8993 rv = callback.WaitForResult(); |
8985 EXPECT_THAT(rv, IsOk()); | 8994 EXPECT_THAT(rv, IsOk()); |
8986 | 8995 |
8987 const HttpResponseInfo* response = trans.GetResponseInfo(); | 8996 const HttpResponseInfo* response = trans.GetResponseInfo(); |
8988 ASSERT_TRUE(response); | 8997 ASSERT_TRUE(response); |
| 8998 EXPECT_TRUE(response->proxy_server.is_socks()); |
8989 | 8999 |
8990 LoadTimingInfo load_timing_info; | 9000 LoadTimingInfo load_timing_info; |
8991 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 9001 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
8992 TestLoadTimingNotReusedWithPac(load_timing_info, | 9002 TestLoadTimingNotReusedWithPac(load_timing_info, |
8993 CONNECT_TIMING_HAS_SSL_TIMES); | 9003 CONNECT_TIMING_HAS_SSL_TIMES); |
8994 | 9004 |
8995 std::string response_text; | 9005 std::string response_text; |
8996 rv = ReadTransaction(&trans, &response_text); | 9006 rv = ReadTransaction(&trans, &response_text); |
8997 EXPECT_THAT(rv, IsOk()); | 9007 EXPECT_THAT(rv, IsOk()); |
8998 EXPECT_EQ("Payload", response_text); | 9008 EXPECT_EQ("Payload", response_text); |
(...skipping 3114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12113 rv = callback1.WaitForResult(); | 12123 rv = callback1.WaitForResult(); |
12114 EXPECT_THAT(rv, IsOk()); | 12124 EXPECT_THAT(rv, IsOk()); |
12115 | 12125 |
12116 const HttpResponseInfo* response = trans.GetResponseInfo(); | 12126 const HttpResponseInfo* response = trans.GetResponseInfo(); |
12117 ASSERT_TRUE(response); | 12127 ASSERT_TRUE(response); |
12118 | 12128 |
12119 EXPECT_TRUE(response->headers->IsKeepAlive()); | 12129 EXPECT_TRUE(response->headers->IsKeepAlive()); |
12120 EXPECT_EQ(200, response->headers->response_code()); | 12130 EXPECT_EQ(200, response->headers->response_code()); |
12121 EXPECT_EQ(100, response->headers->GetContentLength()); | 12131 EXPECT_EQ(100, response->headers->GetContentLength()); |
12122 EXPECT_TRUE(response->was_fetched_via_proxy); | 12132 EXPECT_TRUE(response->was_fetched_via_proxy); |
12123 EXPECT_TRUE( | 12133 EXPECT_EQ(ProxyServer(ProxyServer::SCHEME_HTTP, |
12124 response->proxy_server.Equals(HostPortPair::FromString("myproxy:70"))); | 12134 HostPortPair::FromString("myproxy:70")), |
| 12135 response->proxy_server); |
12125 EXPECT_TRUE(headers_handler.observed_before_headers_sent()); | 12136 EXPECT_TRUE(headers_handler.observed_before_headers_sent()); |
12126 EXPECT_TRUE(headers_handler.observed_before_headers_sent_with_proxy()); | 12137 EXPECT_TRUE(headers_handler.observed_before_headers_sent_with_proxy()); |
12127 EXPECT_EQ("myproxy:70", headers_handler.observed_proxy_server_uri()); | 12138 EXPECT_EQ("myproxy:70", headers_handler.observed_proxy_server_uri()); |
12128 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 12139 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
12129 | 12140 |
12130 LoadTimingInfo load_timing_info; | 12141 LoadTimingInfo load_timing_info; |
12131 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 12142 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
12132 TestLoadTimingNotReusedWithPac(load_timing_info, | 12143 TestLoadTimingNotReusedWithPac(load_timing_info, |
12133 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); | 12144 CONNECT_TIMING_HAS_CONNECT_TIMES_ONLY); |
12134 } | 12145 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12195 NetLogEventPhase::NONE); | 12206 NetLogEventPhase::NONE); |
12196 | 12207 |
12197 const HttpResponseInfo* response = trans.GetResponseInfo(); | 12208 const HttpResponseInfo* response = trans.GetResponseInfo(); |
12198 ASSERT_TRUE(response); | 12209 ASSERT_TRUE(response); |
12199 | 12210 |
12200 EXPECT_TRUE(response->headers->IsKeepAlive()); | 12211 EXPECT_TRUE(response->headers->IsKeepAlive()); |
12201 EXPECT_EQ(200, response->headers->response_code()); | 12212 EXPECT_EQ(200, response->headers->response_code()); |
12202 EXPECT_EQ(100, response->headers->GetContentLength()); | 12213 EXPECT_EQ(100, response->headers->GetContentLength()); |
12203 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 12214 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
12204 EXPECT_TRUE(response->was_fetched_via_proxy); | 12215 EXPECT_TRUE(response->was_fetched_via_proxy); |
12205 EXPECT_TRUE( | 12216 EXPECT_EQ(ProxyServer(ProxyServer::SCHEME_HTTP, |
12206 response->proxy_server.Equals(HostPortPair::FromString("myproxy:70"))); | 12217 HostPortPair::FromString("myproxy:70")), |
| 12218 response->proxy_server); |
12207 EXPECT_TRUE(headers_handler.observed_before_headers_sent()); | 12219 EXPECT_TRUE(headers_handler.observed_before_headers_sent()); |
12208 EXPECT_TRUE(headers_handler.observed_before_headers_sent_with_proxy()); | 12220 EXPECT_TRUE(headers_handler.observed_before_headers_sent_with_proxy()); |
12209 EXPECT_EQ("myproxy:70", headers_handler.observed_proxy_server_uri()); | 12221 EXPECT_EQ("myproxy:70", headers_handler.observed_proxy_server_uri()); |
12210 | 12222 |
12211 LoadTimingInfo load_timing_info; | 12223 LoadTimingInfo load_timing_info; |
12212 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 12224 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
12213 TestLoadTimingNotReusedWithPac(load_timing_info, | 12225 TestLoadTimingNotReusedWithPac(load_timing_info, |
12214 CONNECT_TIMING_HAS_SSL_TIMES); | 12226 CONNECT_TIMING_HAS_SSL_TIMES); |
12215 } | 12227 } |
12216 | 12228 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12273 NetLogEventPhase::NONE); | 12285 NetLogEventPhase::NONE); |
12274 | 12286 |
12275 const HttpResponseInfo* response = trans.GetResponseInfo(); | 12287 const HttpResponseInfo* response = trans.GetResponseInfo(); |
12276 ASSERT_TRUE(response); | 12288 ASSERT_TRUE(response); |
12277 | 12289 |
12278 EXPECT_TRUE(response->headers->IsKeepAlive()); | 12290 EXPECT_TRUE(response->headers->IsKeepAlive()); |
12279 EXPECT_EQ(200, response->headers->response_code()); | 12291 EXPECT_EQ(200, response->headers->response_code()); |
12280 EXPECT_EQ(100, response->headers->GetContentLength()); | 12292 EXPECT_EQ(100, response->headers->GetContentLength()); |
12281 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 12293 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
12282 EXPECT_TRUE(response->was_fetched_via_proxy); | 12294 EXPECT_TRUE(response->was_fetched_via_proxy); |
12283 EXPECT_TRUE( | 12295 EXPECT_EQ(ProxyServer(ProxyServer::SCHEME_HTTP, |
12284 response->proxy_server.Equals(HostPortPair::FromString("myproxy:70"))); | 12296 HostPortPair::FromString("myproxy:70")), |
| 12297 response->proxy_server); |
12285 | 12298 |
12286 LoadTimingInfo load_timing_info; | 12299 LoadTimingInfo load_timing_info; |
12287 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); | 12300 EXPECT_TRUE(trans.GetLoadTimingInfo(&load_timing_info)); |
12288 TestLoadTimingNotReusedWithPac(load_timing_info, | 12301 TestLoadTimingNotReusedWithPac(load_timing_info, |
12289 CONNECT_TIMING_HAS_SSL_TIMES); | 12302 CONNECT_TIMING_HAS_SSL_TIMES); |
12290 } | 12303 } |
12291 | 12304 |
12292 // Test a basic HTTPS GET request through a proxy, but the server hangs up | 12305 // Test a basic HTTPS GET request through a proxy, but the server hangs up |
12293 // while establishing the tunnel. | 12306 // while establishing the tunnel. |
12294 TEST_F(HttpNetworkTransactionTest, ProxyTunnelGetHangup) { | 12307 TEST_F(HttpNetworkTransactionTest, ProxyTunnelGetHangup) { |
(...skipping 3256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15551 base::RunLoop().RunUntilIdle(); | 15564 base::RunLoop().RunUntilIdle(); |
15552 | 15565 |
15553 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 15566 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
15554 HttpRequestHeaders headers; | 15567 HttpRequestHeaders headers; |
15555 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 15568 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
15556 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 15569 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
15557 } | 15570 } |
15558 #endif // !defined(OS_IOS) | 15571 #endif // !defined(OS_IOS) |
15559 | 15572 |
15560 } // namespace net | 15573 } // namespace net |
OLD | NEW |