| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 request.load_flags = 0; | 191 request.load_flags = 0; |
| 192 | 192 |
| 193 SessionDependencies session_deps; | 193 SessionDependencies session_deps; |
| 194 scoped_ptr<HttpTransaction> trans( | 194 scoped_ptr<HttpTransaction> trans( |
| 195 new HttpNetworkTransaction(CreateSession(&session_deps))); | 195 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 196 | 196 |
| 197 for (size_t i = 0; i < data_count; ++i) { | 197 for (size_t i = 0; i < data_count; ++i) { |
| 198 session_deps.socket_factory.AddSocketDataProvider(data[i]); | 198 session_deps.socket_factory.AddSocketDataProvider(data[i]); |
| 199 } | 199 } |
| 200 | 200 |
| 201 TestOldCompletionCallback callback; | 201 TestCompletionCallback callback; |
| 202 | 202 |
| 203 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 203 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
| 204 EXPECT_TRUE(log.bound().IsLoggingAllEvents()); | 204 EXPECT_TRUE(log.bound().IsLoggingAllEvents()); |
| 205 int rv = trans->Start(&request, &callback, log.bound()); | 205 int rv = trans->Start(&request, callback.callback(), log.bound()); |
| 206 EXPECT_EQ(ERR_IO_PENDING, rv); | 206 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 207 | 207 |
| 208 out.rv = callback.WaitForResult(); | 208 out.rv = callback.WaitForResult(); |
| 209 if (out.rv != OK) | 209 if (out.rv != OK) |
| 210 return out; | 210 return out; |
| 211 | 211 |
| 212 const HttpResponseInfo* response = trans->GetResponseInfo(); | 212 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 213 // Can't use ASSERT_* inside helper functions like this, so | 213 // Can't use ASSERT_* inside helper functions like this, so |
| 214 // return an error. | 214 // return an error. |
| 215 if (response == NULL || response->headers == NULL) { | 215 if (response == NULL || response->headers == NULL) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 CertVerifier* cert_verifier); | 309 CertVerifier* cert_verifier); |
| 310 | 310 |
| 311 const std::string last_group_name_received() const { | 311 const std::string last_group_name_received() const { |
| 312 return last_group_name_; | 312 return last_group_name_; |
| 313 } | 313 } |
| 314 | 314 |
| 315 virtual int RequestSocket(const std::string& group_name, | 315 virtual int RequestSocket(const std::string& group_name, |
| 316 const void* socket_params, | 316 const void* socket_params, |
| 317 RequestPriority priority, | 317 RequestPriority priority, |
| 318 ClientSocketHandle* handle, | 318 ClientSocketHandle* handle, |
| 319 OldCompletionCallback* callback, | 319 const CompletionCallback& callback, |
| 320 const BoundNetLog& net_log) { | 320 const BoundNetLog& net_log) { |
| 321 last_group_name_ = group_name; | 321 last_group_name_ = group_name; |
| 322 return ERR_IO_PENDING; | 322 return ERR_IO_PENDING; |
| 323 } | 323 } |
| 324 virtual void CancelRequest(const std::string& group_name, | 324 virtual void CancelRequest(const std::string& group_name, |
| 325 ClientSocketHandle* handle) {} | 325 ClientSocketHandle* handle) {} |
| 326 virtual void ReleaseSocket(const std::string& group_name, | 326 virtual void ReleaseSocket(const std::string& group_name, |
| 327 StreamSocket* socket, | 327 StreamSocket* socket, |
| 328 int id) {} | 328 int id) {} |
| 329 virtual void CloseIdleSockets() {} | 329 virtual void CloseIdleSockets() {} |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 request.url = GURL("http://redirect.com/"); | 713 request.url = GURL("http://redirect.com/"); |
| 714 request.load_flags = 0; | 714 request.load_flags = 0; |
| 715 | 715 |
| 716 SessionDependencies session_deps; | 716 SessionDependencies session_deps; |
| 717 scoped_ptr<HttpTransaction> trans( | 717 scoped_ptr<HttpTransaction> trans( |
| 718 new HttpNetworkTransaction(CreateSession(&session_deps))); | 718 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 719 | 719 |
| 720 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 720 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 721 session_deps.socket_factory.AddSocketDataProvider(&data); | 721 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 722 | 722 |
| 723 TestOldCompletionCallback callback; | 723 TestCompletionCallback callback; |
| 724 | 724 |
| 725 int rv = trans->Start(&request, &callback, BoundNetLog()); | 725 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 726 EXPECT_EQ(ERR_IO_PENDING, rv); | 726 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 727 | 727 |
| 728 EXPECT_EQ(OK, callback.WaitForResult()); | 728 EXPECT_EQ(OK, callback.WaitForResult()); |
| 729 | 729 |
| 730 const HttpResponseInfo* response = trans->GetResponseInfo(); | 730 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 731 ASSERT_TRUE(response != NULL && response->headers != NULL); | 731 ASSERT_TRUE(response != NULL && response->headers != NULL); |
| 732 EXPECT_EQ("HTTP/1.1 302 Redirect", response->headers->GetStatusLine()); | 732 EXPECT_EQ("HTTP/1.1 302 Redirect", response->headers->GetStatusLine()); |
| 733 std::string url; | 733 std::string url; |
| 734 EXPECT_TRUE(response->headers->IsRedirect(&url)); | 734 EXPECT_TRUE(response->headers->IsRedirect(&url)); |
| 735 EXPECT_EQ("http://good.com/", url); | 735 EXPECT_EQ("http://good.com/", url); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 MockRead("Content-Length: 1234\r\n\r\n"), | 787 MockRead("Content-Length: 1234\r\n\r\n"), |
| 788 | 788 |
| 789 // No response body because the test stops reading here. | 789 // No response body because the test stops reading here. |
| 790 MockRead(false, ERR_UNEXPECTED), // Should not be reached. | 790 MockRead(false, ERR_UNEXPECTED), // Should not be reached. |
| 791 }; | 791 }; |
| 792 | 792 |
| 793 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 793 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 794 data_writes1, arraysize(data_writes1)); | 794 data_writes1, arraysize(data_writes1)); |
| 795 session_deps.socket_factory.AddSocketDataProvider(&data1); | 795 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 796 | 796 |
| 797 TestOldCompletionCallback callback1; | 797 TestCompletionCallback callback1; |
| 798 | 798 |
| 799 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 799 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 800 EXPECT_EQ(ERR_IO_PENDING, rv); | 800 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 801 | 801 |
| 802 rv = callback1.WaitForResult(); | 802 rv = callback1.WaitForResult(); |
| 803 EXPECT_EQ(OK, rv); | 803 EXPECT_EQ(OK, rv); |
| 804 | 804 |
| 805 const HttpResponseInfo* response = trans->GetResponseInfo(); | 805 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 806 ASSERT_TRUE(response != NULL); | 806 ASSERT_TRUE(response != NULL); |
| 807 | 807 |
| 808 // Check that the headers got parsed. | 808 // Check that the headers got parsed. |
| 809 EXPECT_TRUE(response->headers != NULL); | 809 EXPECT_TRUE(response->headers != NULL); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 }; | 844 }; |
| 845 | 845 |
| 846 for (int i = 0; i < 2; ++i) { | 846 for (int i = 0; i < 2; ++i) { |
| 847 HttpRequestInfo request; | 847 HttpRequestInfo request; |
| 848 request.method = "GET"; | 848 request.method = "GET"; |
| 849 request.url = GURL("http://www.google.com/"); | 849 request.url = GURL("http://www.google.com/"); |
| 850 request.load_flags = 0; | 850 request.load_flags = 0; |
| 851 | 851 |
| 852 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 852 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 853 | 853 |
| 854 TestOldCompletionCallback callback; | 854 TestCompletionCallback callback; |
| 855 | 855 |
| 856 int rv = trans->Start(&request, &callback, BoundNetLog()); | 856 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 857 EXPECT_EQ(ERR_IO_PENDING, rv); | 857 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 858 | 858 |
| 859 rv = callback.WaitForResult(); | 859 rv = callback.WaitForResult(); |
| 860 EXPECT_EQ(OK, rv); | 860 EXPECT_EQ(OK, rv); |
| 861 | 861 |
| 862 const HttpResponseInfo* response = trans->GetResponseInfo(); | 862 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 863 ASSERT_TRUE(response != NULL); | 863 ASSERT_TRUE(response != NULL); |
| 864 | 864 |
| 865 EXPECT_TRUE(response->headers != NULL); | 865 EXPECT_TRUE(response->headers != NULL); |
| 866 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 866 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 886 | 886 |
| 887 MockRead data_reads[] = { | 887 MockRead data_reads[] = { |
| 888 MockRead("HTTP/1.0 100 Continue\r\n\r\n"), | 888 MockRead("HTTP/1.0 100 Continue\r\n\r\n"), |
| 889 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | 889 MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
| 890 MockRead("hello world"), | 890 MockRead("hello world"), |
| 891 MockRead(false, OK), | 891 MockRead(false, OK), |
| 892 }; | 892 }; |
| 893 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 893 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 894 session_deps.socket_factory.AddSocketDataProvider(&data); | 894 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 895 | 895 |
| 896 TestOldCompletionCallback callback; | 896 TestCompletionCallback callback; |
| 897 | 897 |
| 898 int rv = trans->Start(&request, &callback, BoundNetLog()); | 898 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 899 EXPECT_EQ(ERR_IO_PENDING, rv); | 899 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 900 | 900 |
| 901 rv = callback.WaitForResult(); | 901 rv = callback.WaitForResult(); |
| 902 EXPECT_EQ(OK, rv); | 902 EXPECT_EQ(OK, rv); |
| 903 | 903 |
| 904 const HttpResponseInfo* response = trans->GetResponseInfo(); | 904 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 905 ASSERT_TRUE(response != NULL); | 905 ASSERT_TRUE(response != NULL); |
| 906 | 906 |
| 907 EXPECT_TRUE(response->headers != NULL); | 907 EXPECT_TRUE(response->headers != NULL); |
| 908 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 908 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 928 | 928 |
| 929 MockRead data_reads[] = { | 929 MockRead data_reads[] = { |
| 930 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n" | 930 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n" |
| 931 "HTTP/1.1 200 OK\r\n\r\n"), | 931 "HTTP/1.1 200 OK\r\n\r\n"), |
| 932 MockRead("hello world"), | 932 MockRead("hello world"), |
| 933 MockRead(false, OK), | 933 MockRead(false, OK), |
| 934 }; | 934 }; |
| 935 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 935 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 936 session_deps.socket_factory.AddSocketDataProvider(&data); | 936 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 937 | 937 |
| 938 TestOldCompletionCallback callback; | 938 TestCompletionCallback callback; |
| 939 | 939 |
| 940 int rv = trans->Start(&request, &callback, BoundNetLog()); | 940 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 941 EXPECT_EQ(ERR_IO_PENDING, rv); | 941 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 942 | 942 |
| 943 rv = callback.WaitForResult(); | 943 rv = callback.WaitForResult(); |
| 944 EXPECT_EQ(OK, rv); | 944 EXPECT_EQ(OK, rv); |
| 945 | 945 |
| 946 const HttpResponseInfo* response = trans->GetResponseInfo(); | 946 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 947 ASSERT_TRUE(response != NULL); | 947 ASSERT_TRUE(response != NULL); |
| 948 | 948 |
| 949 EXPECT_TRUE(response->headers != NULL); | 949 EXPECT_TRUE(response->headers != NULL); |
| 950 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 950 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 965 scoped_ptr<HttpTransaction> trans( | 965 scoped_ptr<HttpTransaction> trans( |
| 966 new HttpNetworkTransaction(CreateSession(&session_deps))); | 966 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 967 | 967 |
| 968 MockRead data_reads[] = { | 968 MockRead data_reads[] = { |
| 969 MockRead(false, "HTTP/1.0 100 Continue\r\n"), | 969 MockRead(false, "HTTP/1.0 100 Continue\r\n"), |
| 970 MockRead(true, 0), | 970 MockRead(true, 0), |
| 971 }; | 971 }; |
| 972 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 972 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 973 session_deps.socket_factory.AddSocketDataProvider(&data); | 973 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 974 | 974 |
| 975 TestOldCompletionCallback callback; | 975 TestCompletionCallback callback; |
| 976 | 976 |
| 977 int rv = trans->Start(&request, &callback, BoundNetLog()); | 977 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 978 EXPECT_EQ(ERR_IO_PENDING, rv); | 978 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 979 | 979 |
| 980 rv = callback.WaitForResult(); | 980 rv = callback.WaitForResult(); |
| 981 EXPECT_EQ(OK, rv); | 981 EXPECT_EQ(OK, rv); |
| 982 | 982 |
| 983 std::string response_data; | 983 std::string response_data; |
| 984 rv = ReadTransaction(trans.get(), &response_data); | 984 rv = ReadTransaction(trans.get(), &response_data); |
| 985 EXPECT_EQ(OK, rv); | 985 EXPECT_EQ(OK, rv); |
| 986 EXPECT_EQ("", response_data); | 986 EXPECT_EQ("", response_data); |
| 987 } | 987 } |
| 988 | 988 |
| 989 TEST_F(HttpNetworkTransactionTest, EmptyResponse) { | 989 TEST_F(HttpNetworkTransactionTest, EmptyResponse) { |
| 990 HttpRequestInfo request; | 990 HttpRequestInfo request; |
| 991 request.method = "POST"; | 991 request.method = "POST"; |
| 992 request.url = GURL("http://www.foo.com/"); | 992 request.url = GURL("http://www.foo.com/"); |
| 993 request.load_flags = 0; | 993 request.load_flags = 0; |
| 994 | 994 |
| 995 SessionDependencies session_deps; | 995 SessionDependencies session_deps; |
| 996 scoped_ptr<HttpTransaction> trans( | 996 scoped_ptr<HttpTransaction> trans( |
| 997 new HttpNetworkTransaction(CreateSession(&session_deps))); | 997 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 998 | 998 |
| 999 MockRead data_reads[] = { | 999 MockRead data_reads[] = { |
| 1000 MockRead(true, 0), | 1000 MockRead(true, 0), |
| 1001 }; | 1001 }; |
| 1002 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 1002 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 1003 session_deps.socket_factory.AddSocketDataProvider(&data); | 1003 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 1004 | 1004 |
| 1005 TestOldCompletionCallback callback; | 1005 TestCompletionCallback callback; |
| 1006 | 1006 |
| 1007 int rv = trans->Start(&request, &callback, BoundNetLog()); | 1007 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1008 EXPECT_EQ(ERR_IO_PENDING, rv); | 1008 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1009 | 1009 |
| 1010 rv = callback.WaitForResult(); | 1010 rv = callback.WaitForResult(); |
| 1011 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); | 1011 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); |
| 1012 } | 1012 } |
| 1013 | 1013 |
| 1014 void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest( | 1014 void HttpNetworkTransactionTest::KeepAliveConnectionResendRequestTest( |
| 1015 const MockWrite* write_failure, | 1015 const MockWrite* write_failure, |
| 1016 const MockRead* read_failure) { | 1016 const MockRead* read_failure) { |
| 1017 HttpRequestInfo request; | 1017 HttpRequestInfo request; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 MockRead(true, OK), | 1057 MockRead(true, OK), |
| 1058 }; | 1058 }; |
| 1059 StaticSocketDataProvider data2(data2_reads, arraysize(data2_reads), NULL, 0); | 1059 StaticSocketDataProvider data2(data2_reads, arraysize(data2_reads), NULL, 0); |
| 1060 session_deps.socket_factory.AddSocketDataProvider(&data2); | 1060 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 1061 | 1061 |
| 1062 const char* kExpectedResponseData[] = { | 1062 const char* kExpectedResponseData[] = { |
| 1063 "hello", "world" | 1063 "hello", "world" |
| 1064 }; | 1064 }; |
| 1065 | 1065 |
| 1066 for (int i = 0; i < 2; ++i) { | 1066 for (int i = 0; i < 2; ++i) { |
| 1067 TestOldCompletionCallback callback; | 1067 TestCompletionCallback callback; |
| 1068 | 1068 |
| 1069 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1069 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1070 | 1070 |
| 1071 int rv = trans->Start(&request, &callback, BoundNetLog()); | 1071 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1072 EXPECT_EQ(ERR_IO_PENDING, rv); | 1072 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1073 | 1073 |
| 1074 rv = callback.WaitForResult(); | 1074 rv = callback.WaitForResult(); |
| 1075 EXPECT_EQ(OK, rv); | 1075 EXPECT_EQ(OK, rv); |
| 1076 | 1076 |
| 1077 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1077 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1078 ASSERT_TRUE(response != NULL); | 1078 ASSERT_TRUE(response != NULL); |
| 1079 | 1079 |
| 1080 EXPECT_TRUE(response->headers != NULL); | 1080 EXPECT_TRUE(response->headers != NULL); |
| 1081 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1081 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 | 1114 |
| 1115 MockRead data_reads[] = { | 1115 MockRead data_reads[] = { |
| 1116 MockRead(true, ERR_CONNECTION_RESET), | 1116 MockRead(true, ERR_CONNECTION_RESET), |
| 1117 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used | 1117 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used |
| 1118 MockRead("hello world"), | 1118 MockRead("hello world"), |
| 1119 MockRead(false, OK), | 1119 MockRead(false, OK), |
| 1120 }; | 1120 }; |
| 1121 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 1121 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 1122 session_deps.socket_factory.AddSocketDataProvider(&data); | 1122 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 1123 | 1123 |
| 1124 TestOldCompletionCallback callback; | 1124 TestCompletionCallback callback; |
| 1125 | 1125 |
| 1126 int rv = trans->Start(&request, &callback, BoundNetLog()); | 1126 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1127 EXPECT_EQ(ERR_IO_PENDING, rv); | 1127 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1128 | 1128 |
| 1129 rv = callback.WaitForResult(); | 1129 rv = callback.WaitForResult(); |
| 1130 EXPECT_EQ(ERR_CONNECTION_RESET, rv); | 1130 EXPECT_EQ(ERR_CONNECTION_RESET, rv); |
| 1131 | 1131 |
| 1132 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1132 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1133 EXPECT_TRUE(response == NULL); | 1133 EXPECT_TRUE(response == NULL); |
| 1134 } | 1134 } |
| 1135 | 1135 |
| 1136 // What do various browsers do when the server closes a non-keepalive | 1136 // What do various browsers do when the server closes a non-keepalive |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 MockRead data2_reads[] = { | 1191 MockRead data2_reads[] = { |
| 1192 MockRead(false, ERR_UNEXPECTED), // Should not be reached. | 1192 MockRead(false, ERR_UNEXPECTED), // Should not be reached. |
| 1193 }; | 1193 }; |
| 1194 StaticSocketDataProvider data2(data2_reads, arraysize(data2_reads), NULL, 0); | 1194 StaticSocketDataProvider data2(data2_reads, arraysize(data2_reads), NULL, 0); |
| 1195 session_deps.socket_factory.AddSocketDataProvider(&data2); | 1195 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 1196 | 1196 |
| 1197 const int kNumUnreadBodies = arraysize(data1_reads) - 2; | 1197 const int kNumUnreadBodies = arraysize(data1_reads) - 2; |
| 1198 std::string response_lines[kNumUnreadBodies]; | 1198 std::string response_lines[kNumUnreadBodies]; |
| 1199 | 1199 |
| 1200 for (size_t i = 0; i < arraysize(data1_reads) - 2; ++i) { | 1200 for (size_t i = 0; i < arraysize(data1_reads) - 2; ++i) { |
| 1201 TestOldCompletionCallback callback; | 1201 TestCompletionCallback callback; |
| 1202 | 1202 |
| 1203 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1203 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1204 | 1204 |
| 1205 int rv = trans->Start(&request, &callback, BoundNetLog()); | 1205 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1206 EXPECT_EQ(ERR_IO_PENDING, rv); | 1206 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1207 | 1207 |
| 1208 rv = callback.WaitForResult(); | 1208 rv = callback.WaitForResult(); |
| 1209 EXPECT_EQ(OK, rv); | 1209 EXPECT_EQ(OK, rv); |
| 1210 | 1210 |
| 1211 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1211 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1212 ASSERT_TRUE(response != NULL); | 1212 ASSERT_TRUE(response != NULL); |
| 1213 | 1213 |
| 1214 ASSERT_TRUE(response->headers != NULL); | 1214 ASSERT_TRUE(response->headers != NULL); |
| 1215 response_lines[i] = response->headers->GetStatusLine(); | 1215 response_lines[i] = response->headers->GetStatusLine(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1226 "HTTP/1.1 301 Moved Permanently", | 1226 "HTTP/1.1 301 Moved Permanently", |
| 1227 "HTTP/1.1 301 Moved Permanently", | 1227 "HTTP/1.1 301 Moved Permanently", |
| 1228 }; | 1228 }; |
| 1229 | 1229 |
| 1230 COMPILE_ASSERT(kNumUnreadBodies == arraysize(kStatusLines), | 1230 COMPILE_ASSERT(kNumUnreadBodies == arraysize(kStatusLines), |
| 1231 forgot_to_update_kStatusLines); | 1231 forgot_to_update_kStatusLines); |
| 1232 | 1232 |
| 1233 for (int i = 0; i < kNumUnreadBodies; ++i) | 1233 for (int i = 0; i < kNumUnreadBodies; ++i) |
| 1234 EXPECT_EQ(kStatusLines[i], response_lines[i]); | 1234 EXPECT_EQ(kStatusLines[i], response_lines[i]); |
| 1235 | 1235 |
| 1236 TestOldCompletionCallback callback; | 1236 TestCompletionCallback callback; |
| 1237 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1237 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1238 int rv = trans->Start(&request, &callback, BoundNetLog()); | 1238 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1239 EXPECT_EQ(ERR_IO_PENDING, rv); | 1239 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1240 rv = callback.WaitForResult(); | 1240 rv = callback.WaitForResult(); |
| 1241 EXPECT_EQ(OK, rv); | 1241 EXPECT_EQ(OK, rv); |
| 1242 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1242 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1243 ASSERT_TRUE(response != NULL); | 1243 ASSERT_TRUE(response != NULL); |
| 1244 ASSERT_TRUE(response->headers != NULL); | 1244 ASSERT_TRUE(response->headers != NULL); |
| 1245 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 1245 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 1246 std::string response_data; | 1246 std::string response_data; |
| 1247 rv = ReadTransaction(trans.get(), &response_data); | 1247 rv = ReadTransaction(trans.get(), &response_data); |
| 1248 EXPECT_EQ(OK, rv); | 1248 EXPECT_EQ(OK, rv); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 MockRead(false, OK), | 1297 MockRead(false, OK), |
| 1298 }; | 1298 }; |
| 1299 | 1299 |
| 1300 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1300 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1301 data_writes1, arraysize(data_writes1)); | 1301 data_writes1, arraysize(data_writes1)); |
| 1302 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1302 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 1303 data_writes2, arraysize(data_writes2)); | 1303 data_writes2, arraysize(data_writes2)); |
| 1304 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1304 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 1305 session_deps.socket_factory.AddSocketDataProvider(&data2); | 1305 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 1306 | 1306 |
| 1307 TestOldCompletionCallback callback1; | 1307 TestCompletionCallback callback1; |
| 1308 | 1308 |
| 1309 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 1309 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 1310 EXPECT_EQ(ERR_IO_PENDING, rv); | 1310 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1311 | 1311 |
| 1312 rv = callback1.WaitForResult(); | 1312 rv = callback1.WaitForResult(); |
| 1313 EXPECT_EQ(OK, rv); | 1313 EXPECT_EQ(OK, rv); |
| 1314 | 1314 |
| 1315 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1315 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1316 ASSERT_TRUE(response != NULL); | 1316 ASSERT_TRUE(response != NULL); |
| 1317 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1317 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 1318 | 1318 |
| 1319 TestOldCompletionCallback callback2; | 1319 TestCompletionCallback callback2; |
| 1320 | 1320 |
| 1321 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | 1321 rv = trans->RestartWithAuth( |
| 1322 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 1322 EXPECT_EQ(ERR_IO_PENDING, rv); | 1323 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1323 | 1324 |
| 1324 rv = callback2.WaitForResult(); | 1325 rv = callback2.WaitForResult(); |
| 1325 EXPECT_EQ(OK, rv); | 1326 EXPECT_EQ(OK, rv); |
| 1326 | 1327 |
| 1327 response = trans->GetResponseInfo(); | 1328 response = trans->GetResponseInfo(); |
| 1328 ASSERT_TRUE(response != NULL); | 1329 ASSERT_TRUE(response != NULL); |
| 1329 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1330 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 1330 EXPECT_EQ(100, response->headers->GetContentLength()); | 1331 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 1331 } | 1332 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1351 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 1352 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 1352 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 1353 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 1353 // Large content-length -- won't matter, as connection will be reset. | 1354 // Large content-length -- won't matter, as connection will be reset. |
| 1354 MockRead("Content-Length: 10000\r\n\r\n"), | 1355 MockRead("Content-Length: 10000\r\n\r\n"), |
| 1355 MockRead(false, ERR_FAILED), | 1356 MockRead(false, ERR_FAILED), |
| 1356 }; | 1357 }; |
| 1357 | 1358 |
| 1358 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 1359 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 1359 data_writes, arraysize(data_writes)); | 1360 data_writes, arraysize(data_writes)); |
| 1360 session_deps.socket_factory.AddSocketDataProvider(&data); | 1361 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 1361 TestOldCompletionCallback callback; | 1362 TestCompletionCallback callback; |
| 1362 | 1363 |
| 1363 int rv = trans->Start(&request, &callback, BoundNetLog()); | 1364 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1364 EXPECT_EQ(ERR_IO_PENDING, rv); | 1365 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1365 | 1366 |
| 1366 rv = callback.WaitForResult(); | 1367 rv = callback.WaitForResult(); |
| 1367 EXPECT_EQ(0, rv); | 1368 EXPECT_EQ(0, rv); |
| 1368 | 1369 |
| 1369 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1370 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1370 ASSERT_TRUE(response != NULL); | 1371 ASSERT_TRUE(response != NULL); |
| 1371 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1372 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 1372 } | 1373 } |
| 1373 | 1374 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 MockRead(false, ERR_FAILED), | 1416 MockRead(false, ERR_FAILED), |
| 1416 }; | 1417 }; |
| 1417 | 1418 |
| 1418 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1419 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1419 data_writes1, arraysize(data_writes1)); | 1420 data_writes1, arraysize(data_writes1)); |
| 1420 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1421 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 1421 NULL, 0); | 1422 NULL, 0); |
| 1422 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1423 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 1423 session_deps.socket_factory.AddSocketDataProvider(&data2); | 1424 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 1424 | 1425 |
| 1425 TestOldCompletionCallback callback1; | 1426 TestCompletionCallback callback1; |
| 1426 | 1427 |
| 1427 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1428 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1428 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 1429 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 1429 EXPECT_EQ(ERR_IO_PENDING, rv); | 1430 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1430 | 1431 |
| 1431 rv = callback1.WaitForResult(); | 1432 rv = callback1.WaitForResult(); |
| 1432 EXPECT_EQ(OK, rv); | 1433 EXPECT_EQ(OK, rv); |
| 1433 | 1434 |
| 1434 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1435 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1435 ASSERT_TRUE(response != NULL); | 1436 ASSERT_TRUE(response != NULL); |
| 1436 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1437 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 1437 | 1438 |
| 1438 TestOldCompletionCallback callback2; | 1439 TestCompletionCallback callback2; |
| 1439 | 1440 |
| 1440 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | 1441 rv = trans->RestartWithAuth( |
| 1442 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 1441 EXPECT_EQ(ERR_IO_PENDING, rv); | 1443 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1442 | 1444 |
| 1443 rv = callback2.WaitForResult(); | 1445 rv = callback2.WaitForResult(); |
| 1444 EXPECT_EQ(OK, rv); | 1446 EXPECT_EQ(OK, rv); |
| 1445 | 1447 |
| 1446 response = trans->GetResponseInfo(); | 1448 response = trans->GetResponseInfo(); |
| 1447 ASSERT_TRUE(response != NULL); | 1449 ASSERT_TRUE(response != NULL); |
| 1448 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1450 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 1449 EXPECT_EQ(5, response->headers->GetContentLength()); | 1451 EXPECT_EQ(5, response->headers->GetContentLength()); |
| 1450 } | 1452 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1490 MockRead(false, ERR_FAILED), | 1492 MockRead(false, ERR_FAILED), |
| 1491 }; | 1493 }; |
| 1492 | 1494 |
| 1493 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1495 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1494 data_writes1, arraysize(data_writes1)); | 1496 data_writes1, arraysize(data_writes1)); |
| 1495 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1497 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 1496 NULL, 0); | 1498 NULL, 0); |
| 1497 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1499 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 1498 session_deps.socket_factory.AddSocketDataProvider(&data2); | 1500 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 1499 | 1501 |
| 1500 TestOldCompletionCallback callback1; | 1502 TestCompletionCallback callback1; |
| 1501 | 1503 |
| 1502 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1504 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1503 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 1505 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 1504 EXPECT_EQ(ERR_IO_PENDING, rv); | 1506 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1505 | 1507 |
| 1506 rv = callback1.WaitForResult(); | 1508 rv = callback1.WaitForResult(); |
| 1507 EXPECT_EQ(OK, rv); | 1509 EXPECT_EQ(OK, rv); |
| 1508 | 1510 |
| 1509 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1511 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1510 ASSERT_TRUE(response != NULL); | 1512 ASSERT_TRUE(response != NULL); |
| 1511 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1513 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 1512 | 1514 |
| 1513 TestOldCompletionCallback callback2; | 1515 TestCompletionCallback callback2; |
| 1514 | 1516 |
| 1515 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | 1517 rv = trans->RestartWithAuth( |
| 1518 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 1516 EXPECT_EQ(ERR_IO_PENDING, rv); | 1519 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1517 | 1520 |
| 1518 rv = callback2.WaitForResult(); | 1521 rv = callback2.WaitForResult(); |
| 1519 EXPECT_EQ(OK, rv); | 1522 EXPECT_EQ(OK, rv); |
| 1520 | 1523 |
| 1521 response = trans->GetResponseInfo(); | 1524 response = trans->GetResponseInfo(); |
| 1522 ASSERT_TRUE(response != NULL); | 1525 ASSERT_TRUE(response != NULL); |
| 1523 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1526 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 1524 EXPECT_EQ(5, response->headers->GetContentLength()); | 1527 EXPECT_EQ(5, response->headers->GetContentLength()); |
| 1525 } | 1528 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 MockRead(false, ERR_FAILED), | 1576 MockRead(false, ERR_FAILED), |
| 1574 }; | 1577 }; |
| 1575 | 1578 |
| 1576 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1579 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1577 data_writes1, arraysize(data_writes1)); | 1580 data_writes1, arraysize(data_writes1)); |
| 1578 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1581 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 1579 NULL, 0); | 1582 NULL, 0); |
| 1580 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1583 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 1581 session_deps.socket_factory.AddSocketDataProvider(&data2); | 1584 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 1582 | 1585 |
| 1583 TestOldCompletionCallback callback1; | 1586 TestCompletionCallback callback1; |
| 1584 | 1587 |
| 1585 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1588 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1586 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 1589 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 1587 EXPECT_EQ(ERR_IO_PENDING, rv); | 1590 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1588 | 1591 |
| 1589 rv = callback1.WaitForResult(); | 1592 rv = callback1.WaitForResult(); |
| 1590 EXPECT_EQ(OK, rv); | 1593 EXPECT_EQ(OK, rv); |
| 1591 | 1594 |
| 1592 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1595 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1593 ASSERT_TRUE(response != NULL); | 1596 ASSERT_TRUE(response != NULL); |
| 1594 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1597 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 1595 | 1598 |
| 1596 TestOldCompletionCallback callback2; | 1599 TestCompletionCallback callback2; |
| 1597 | 1600 |
| 1598 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | 1601 rv = trans->RestartWithAuth( |
| 1602 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 1599 EXPECT_EQ(ERR_IO_PENDING, rv); | 1603 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1600 | 1604 |
| 1601 rv = callback2.WaitForResult(); | 1605 rv = callback2.WaitForResult(); |
| 1602 EXPECT_EQ(OK, rv); | 1606 EXPECT_EQ(OK, rv); |
| 1603 | 1607 |
| 1604 response = trans->GetResponseInfo(); | 1608 response = trans->GetResponseInfo(); |
| 1605 ASSERT_TRUE(response != NULL); | 1609 ASSERT_TRUE(response != NULL); |
| 1606 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1610 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 1607 EXPECT_EQ(5, response->headers->GetContentLength()); | 1611 EXPECT_EQ(5, response->headers->GetContentLength()); |
| 1608 } | 1612 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 MockRead("hello"), | 1662 MockRead("hello"), |
| 1659 }; | 1663 }; |
| 1660 | 1664 |
| 1661 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1665 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1662 data_writes1, arraysize(data_writes1)); | 1666 data_writes1, arraysize(data_writes1)); |
| 1663 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1667 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 1664 data_writes2, arraysize(data_writes2)); | 1668 data_writes2, arraysize(data_writes2)); |
| 1665 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1669 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 1666 session_deps.socket_factory.AddSocketDataProvider(&data2); | 1670 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 1667 | 1671 |
| 1668 TestOldCompletionCallback callback1; | 1672 TestCompletionCallback callback1; |
| 1669 | 1673 |
| 1670 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1674 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1671 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 1675 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 1672 EXPECT_EQ(ERR_IO_PENDING, rv); | 1676 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1673 | 1677 |
| 1674 rv = callback1.WaitForResult(); | 1678 rv = callback1.WaitForResult(); |
| 1675 EXPECT_EQ(OK, rv); | 1679 EXPECT_EQ(OK, rv); |
| 1676 | 1680 |
| 1677 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1681 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1678 ASSERT_TRUE(response != NULL); | 1682 ASSERT_TRUE(response != NULL); |
| 1679 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1683 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 1680 | 1684 |
| 1681 TestOldCompletionCallback callback2; | 1685 TestCompletionCallback callback2; |
| 1682 | 1686 |
| 1683 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | 1687 rv = trans->RestartWithAuth( |
| 1688 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 1684 EXPECT_EQ(ERR_IO_PENDING, rv); | 1689 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1685 | 1690 |
| 1686 rv = callback2.WaitForResult(); | 1691 rv = callback2.WaitForResult(); |
| 1687 EXPECT_EQ(OK, rv); | 1692 EXPECT_EQ(OK, rv); |
| 1688 | 1693 |
| 1689 response = trans->GetResponseInfo(); | 1694 response = trans->GetResponseInfo(); |
| 1690 ASSERT_TRUE(response != NULL); | 1695 ASSERT_TRUE(response != NULL); |
| 1691 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1696 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 1692 EXPECT_EQ(5, response->headers->GetContentLength()); | 1697 EXPECT_EQ(5, response->headers->GetContentLength()); |
| 1693 } | 1698 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1740 MockRead("Content-Length: 5\r\n\r\n"), | 1745 MockRead("Content-Length: 5\r\n\r\n"), |
| 1741 MockRead(false, "hello"), | 1746 MockRead(false, "hello"), |
| 1742 }; | 1747 }; |
| 1743 | 1748 |
| 1744 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1749 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1745 data_writes1, arraysize(data_writes1)); | 1750 data_writes1, arraysize(data_writes1)); |
| 1746 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1751 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 1747 SSLSocketDataProvider ssl(true, OK); | 1752 SSLSocketDataProvider ssl(true, OK); |
| 1748 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 1753 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 1749 | 1754 |
| 1750 TestOldCompletionCallback callback1; | 1755 TestCompletionCallback callback1; |
| 1751 | 1756 |
| 1752 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1757 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1753 | 1758 |
| 1754 int rv = trans->Start(&request, &callback1, log.bound()); | 1759 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 1755 EXPECT_EQ(ERR_IO_PENDING, rv); | 1760 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1756 | 1761 |
| 1757 rv = callback1.WaitForResult(); | 1762 rv = callback1.WaitForResult(); |
| 1758 EXPECT_EQ(OK, rv); | 1763 EXPECT_EQ(OK, rv); |
| 1759 net::CapturingNetLog::EntryList entries; | 1764 net::CapturingNetLog::EntryList entries; |
| 1760 log.GetEntries(&entries); | 1765 log.GetEntries(&entries); |
| 1761 size_t pos = ExpectLogContainsSomewhere( | 1766 size_t pos = ExpectLogContainsSomewhere( |
| 1762 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 1767 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 1763 NetLog::PHASE_NONE); | 1768 NetLog::PHASE_NONE); |
| 1764 ExpectLogContainsSomewhere( | 1769 ExpectLogContainsSomewhere( |
| 1765 entries, pos, | 1770 entries, pos, |
| 1766 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 1771 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 1767 NetLog::PHASE_NONE); | 1772 NetLog::PHASE_NONE); |
| 1768 | 1773 |
| 1769 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1774 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1770 ASSERT_TRUE(response != NULL); | 1775 ASSERT_TRUE(response != NULL); |
| 1771 ASSERT_FALSE(response->headers == NULL); | 1776 ASSERT_FALSE(response->headers == NULL); |
| 1772 EXPECT_EQ(407, response->headers->response_code()); | 1777 EXPECT_EQ(407, response->headers->response_code()); |
| 1773 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 1778 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 1774 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 1779 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 1775 | 1780 |
| 1776 TestOldCompletionCallback callback2; | 1781 TestCompletionCallback callback2; |
| 1777 | 1782 |
| 1778 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | 1783 rv = trans->RestartWithAuth( |
| 1784 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 1779 EXPECT_EQ(ERR_IO_PENDING, rv); | 1785 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1780 | 1786 |
| 1781 rv = callback2.WaitForResult(); | 1787 rv = callback2.WaitForResult(); |
| 1782 EXPECT_EQ(OK, rv); | 1788 EXPECT_EQ(OK, rv); |
| 1783 | 1789 |
| 1784 response = trans->GetResponseInfo(); | 1790 response = trans->GetResponseInfo(); |
| 1785 ASSERT_TRUE(response != NULL); | 1791 ASSERT_TRUE(response != NULL); |
| 1786 | 1792 |
| 1787 EXPECT_TRUE(response->headers->IsKeepAlive()); | 1793 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 1788 EXPECT_EQ(200, response->headers->response_code()); | 1794 EXPECT_EQ(200, response->headers->response_code()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1842 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 1848 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 1843 MockRead("Content-Length: 10\r\n\r\n"), | 1849 MockRead("Content-Length: 10\r\n\r\n"), |
| 1844 // No response body because the test stops reading here. | 1850 // No response body because the test stops reading here. |
| 1845 MockRead(false, ERR_UNEXPECTED), // Should not be reached. | 1851 MockRead(false, ERR_UNEXPECTED), // Should not be reached. |
| 1846 }; | 1852 }; |
| 1847 | 1853 |
| 1848 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1854 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1849 data_writes1, arraysize(data_writes1)); | 1855 data_writes1, arraysize(data_writes1)); |
| 1850 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1856 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 1851 | 1857 |
| 1852 TestOldCompletionCallback callback1; | 1858 TestCompletionCallback callback1; |
| 1853 | 1859 |
| 1854 int rv = trans->Start(&request, &callback1, log.bound()); | 1860 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 1855 EXPECT_EQ(ERR_IO_PENDING, rv); | 1861 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1856 | 1862 |
| 1857 rv = callback1.WaitForResult(); | 1863 rv = callback1.WaitForResult(); |
| 1858 EXPECT_EQ(OK, rv); | 1864 EXPECT_EQ(OK, rv); |
| 1859 net::CapturingNetLog::EntryList entries; | 1865 net::CapturingNetLog::EntryList entries; |
| 1860 log.GetEntries(&entries); | 1866 log.GetEntries(&entries); |
| 1861 size_t pos = ExpectLogContainsSomewhere( | 1867 size_t pos = ExpectLogContainsSomewhere( |
| 1862 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 1868 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 1863 NetLog::PHASE_NONE); | 1869 NetLog::PHASE_NONE); |
| 1864 ExpectLogContainsSomewhere( | 1870 ExpectLogContainsSomewhere( |
| 1865 entries, pos, | 1871 entries, pos, |
| 1866 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 1872 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 1867 NetLog::PHASE_NONE); | 1873 NetLog::PHASE_NONE); |
| 1868 | 1874 |
| 1869 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1875 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1870 ASSERT_TRUE(response != NULL); | 1876 ASSERT_TRUE(response != NULL); |
| 1871 ASSERT_FALSE(response->headers == NULL); | 1877 ASSERT_FALSE(response->headers == NULL); |
| 1872 EXPECT_TRUE(response->headers->IsKeepAlive()); | 1878 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 1873 EXPECT_EQ(407, response->headers->response_code()); | 1879 EXPECT_EQ(407, response->headers->response_code()); |
| 1874 EXPECT_EQ(10, response->headers->GetContentLength()); | 1880 EXPECT_EQ(10, response->headers->GetContentLength()); |
| 1875 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 1881 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 1876 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 1882 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 1877 | 1883 |
| 1878 TestOldCompletionCallback callback2; | 1884 TestCompletionCallback callback2; |
| 1879 | 1885 |
| 1880 // Wrong password (should be "bar"). | 1886 // Wrong password (should be "bar"). |
| 1881 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBaz), &callback2); | 1887 rv = trans->RestartWithAuth( |
| 1888 AuthCredentials(kFoo, kBaz), callback2.callback()); |
| 1882 EXPECT_EQ(ERR_IO_PENDING, rv); | 1889 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1883 | 1890 |
| 1884 rv = callback2.WaitForResult(); | 1891 rv = callback2.WaitForResult(); |
| 1885 EXPECT_EQ(OK, rv); | 1892 EXPECT_EQ(OK, rv); |
| 1886 | 1893 |
| 1887 response = trans->GetResponseInfo(); | 1894 response = trans->GetResponseInfo(); |
| 1888 ASSERT_TRUE(response != NULL); | 1895 ASSERT_TRUE(response != NULL); |
| 1889 ASSERT_FALSE(response->headers == NULL); | 1896 ASSERT_FALSE(response->headers == NULL); |
| 1890 EXPECT_TRUE(response->headers->IsKeepAlive()); | 1897 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 1891 EXPECT_EQ(407, response->headers->response_code()); | 1898 EXPECT_EQ(407, response->headers->response_code()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1925 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), | 1932 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), |
| 1926 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 1933 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 1927 MockRead("Content-Length: 10\r\n\r\n"), | 1934 MockRead("Content-Length: 10\r\n\r\n"), |
| 1928 MockRead(false, ERR_UNEXPECTED), // Should not be reached. | 1935 MockRead(false, ERR_UNEXPECTED), // Should not be reached. |
| 1929 }; | 1936 }; |
| 1930 | 1937 |
| 1931 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 1938 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 1932 data_writes, arraysize(data_writes)); | 1939 data_writes, arraysize(data_writes)); |
| 1933 session_deps.socket_factory.AddSocketDataProvider(&data); | 1940 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 1934 | 1941 |
| 1935 TestOldCompletionCallback callback; | 1942 TestCompletionCallback callback; |
| 1936 | 1943 |
| 1937 int rv = trans->Start(&request, &callback, BoundNetLog()); | 1944 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1938 EXPECT_EQ(ERR_IO_PENDING, rv); | 1945 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1939 | 1946 |
| 1940 rv = callback.WaitForResult(); | 1947 rv = callback.WaitForResult(); |
| 1941 EXPECT_EQ(OK, rv); | 1948 EXPECT_EQ(OK, rv); |
| 1942 | 1949 |
| 1943 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1950 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1944 ASSERT_TRUE(response != NULL); | 1951 ASSERT_TRUE(response != NULL); |
| 1945 | 1952 |
| 1946 EXPECT_TRUE(response->headers->IsKeepAlive()); | 1953 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 1947 EXPECT_EQ(407, response->headers->response_code()); | 1954 EXPECT_EQ(407, response->headers->response_code()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1980 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 1987 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 1981 // Large content-length -- won't matter, as connection will be reset. | 1988 // Large content-length -- won't matter, as connection will be reset. |
| 1982 MockRead("Content-Length: 10000\r\n\r\n"), | 1989 MockRead("Content-Length: 10000\r\n\r\n"), |
| 1983 MockRead(false, ERR_FAILED), | 1990 MockRead(false, ERR_FAILED), |
| 1984 }; | 1991 }; |
| 1985 | 1992 |
| 1986 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1993 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1987 data_writes1, arraysize(data_writes1)); | 1994 data_writes1, arraysize(data_writes1)); |
| 1988 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1995 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 1989 | 1996 |
| 1990 TestOldCompletionCallback callback; | 1997 TestCompletionCallback callback; |
| 1991 | 1998 |
| 1992 int rv = trans->Start(&request, &callback, BoundNetLog()); | 1999 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1993 EXPECT_EQ(ERR_IO_PENDING, rv); | 2000 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1994 | 2001 |
| 1995 rv = callback.WaitForResult(); | 2002 rv = callback.WaitForResult(); |
| 1996 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); | 2003 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); |
| 1997 } | 2004 } |
| 1998 | 2005 |
| 1999 // Tests when an HTTPS server (non-proxy) returns a 407 (proxy-authentication) | 2006 // Tests when an HTTPS server (non-proxy) returns a 407 (proxy-authentication) |
| 2000 // through a non-authenticating proxy. The request should fail with | 2007 // through a non-authenticating proxy. The request should fail with |
| 2001 // ERR_UNEXPECTED_PROXY_AUTH. | 2008 // ERR_UNEXPECTED_PROXY_AUTH. |
| 2002 // Note that it is impossible to detect if an HTTP server returns a 407 through | 2009 // Note that it is impossible to detect if an HTTP server returns a 407 through |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2032 MockRead("\r\n"), | 2039 MockRead("\r\n"), |
| 2033 MockRead(false, OK), | 2040 MockRead(false, OK), |
| 2034 }; | 2041 }; |
| 2035 | 2042 |
| 2036 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2043 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 2037 data_writes1, arraysize(data_writes1)); | 2044 data_writes1, arraysize(data_writes1)); |
| 2038 session_deps.socket_factory.AddSocketDataProvider(&data1); | 2045 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 2039 SSLSocketDataProvider ssl(true, OK); | 2046 SSLSocketDataProvider ssl(true, OK); |
| 2040 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2047 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 2041 | 2048 |
| 2042 TestOldCompletionCallback callback1; | 2049 TestCompletionCallback callback1; |
| 2043 | 2050 |
| 2044 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2051 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2045 | 2052 |
| 2046 int rv = trans->Start(&request, &callback1, log.bound()); | 2053 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2047 EXPECT_EQ(ERR_IO_PENDING, rv); | 2054 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2048 | 2055 |
| 2049 rv = callback1.WaitForResult(); | 2056 rv = callback1.WaitForResult(); |
| 2050 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); | 2057 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); |
| 2051 net::CapturingNetLog::EntryList entries; | 2058 net::CapturingNetLog::EntryList entries; |
| 2052 log.GetEntries(&entries); | 2059 log.GetEntries(&entries); |
| 2053 size_t pos = ExpectLogContainsSomewhere( | 2060 size_t pos = ExpectLogContainsSomewhere( |
| 2054 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 2061 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 2055 NetLog::PHASE_NONE); | 2062 NetLog::PHASE_NONE); |
| 2056 ExpectLogContainsSomewhere( | 2063 ExpectLogContainsSomewhere( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2085 MockRead("Content-Length: 100\r\n\r\n"), | 2092 MockRead("Content-Length: 100\r\n\r\n"), |
| 2086 MockRead(false, OK), | 2093 MockRead(false, OK), |
| 2087 }; | 2094 }; |
| 2088 | 2095 |
| 2089 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2096 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 2090 data_writes1, arraysize(data_writes1)); | 2097 data_writes1, arraysize(data_writes1)); |
| 2091 session_deps.socket_factory.AddSocketDataProvider(&data1); | 2098 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 2092 SSLSocketDataProvider ssl(true, OK); | 2099 SSLSocketDataProvider ssl(true, OK); |
| 2093 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2100 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 2094 | 2101 |
| 2095 TestOldCompletionCallback callback1; | 2102 TestCompletionCallback callback1; |
| 2096 | 2103 |
| 2097 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2104 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2098 | 2105 |
| 2099 int rv = trans->Start(&request, &callback1, log.bound()); | 2106 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2100 EXPECT_EQ(ERR_IO_PENDING, rv); | 2107 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2101 | 2108 |
| 2102 rv = callback1.WaitForResult(); | 2109 rv = callback1.WaitForResult(); |
| 2103 EXPECT_EQ(OK, rv); | 2110 EXPECT_EQ(OK, rv); |
| 2104 | 2111 |
| 2105 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2112 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2106 ASSERT_TRUE(response != NULL); | 2113 ASSERT_TRUE(response != NULL); |
| 2107 | 2114 |
| 2108 EXPECT_TRUE(response->headers->IsKeepAlive()); | 2115 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 2109 EXPECT_EQ(200, response->headers->response_code()); | 2116 EXPECT_EQ(200, response->headers->response_code()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2147 spdy_reads, arraysize(spdy_reads), | 2154 spdy_reads, arraysize(spdy_reads), |
| 2148 spdy_writes, arraysize(spdy_writes))); | 2155 spdy_writes, arraysize(spdy_writes))); |
| 2149 session_deps.socket_factory.AddSocketDataProvider(spdy_data); | 2156 session_deps.socket_factory.AddSocketDataProvider(spdy_data); |
| 2150 | 2157 |
| 2151 SSLSocketDataProvider ssl(true, OK); | 2158 SSLSocketDataProvider ssl(true, OK); |
| 2152 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 2159 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
| 2153 ssl.next_proto = "spdy/2"; | 2160 ssl.next_proto = "spdy/2"; |
| 2154 ssl.was_npn_negotiated = true; | 2161 ssl.was_npn_negotiated = true; |
| 2155 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2162 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 2156 | 2163 |
| 2157 TestOldCompletionCallback callback1; | 2164 TestCompletionCallback callback1; |
| 2158 | 2165 |
| 2159 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2166 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2160 | 2167 |
| 2161 int rv = trans->Start(&request, &callback1, log.bound()); | 2168 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2162 EXPECT_EQ(ERR_IO_PENDING, rv); | 2169 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2163 | 2170 |
| 2164 rv = callback1.WaitForResult(); | 2171 rv = callback1.WaitForResult(); |
| 2165 EXPECT_EQ(OK, rv); | 2172 EXPECT_EQ(OK, rv); |
| 2166 | 2173 |
| 2167 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2174 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2168 ASSERT_TRUE(response != NULL); | 2175 ASSERT_TRUE(response != NULL); |
| 2169 ASSERT_TRUE(response->headers != NULL); | 2176 ASSERT_TRUE(response->headers != NULL); |
| 2170 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2177 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 2171 | 2178 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2233 new OrderedSocketData(spdy_reads, arraysize(spdy_reads), | 2240 new OrderedSocketData(spdy_reads, arraysize(spdy_reads), |
| 2234 spdy_writes, arraysize(spdy_writes))); | 2241 spdy_writes, arraysize(spdy_writes))); |
| 2235 session_deps.socket_factory.AddSocketDataProvider(data); | 2242 session_deps.socket_factory.AddSocketDataProvider(data); |
| 2236 | 2243 |
| 2237 SSLSocketDataProvider ssl(true, OK); | 2244 SSLSocketDataProvider ssl(true, OK); |
| 2238 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 2245 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
| 2239 ssl.next_proto = "spdy/2"; | 2246 ssl.next_proto = "spdy/2"; |
| 2240 ssl.was_npn_negotiated = true; | 2247 ssl.was_npn_negotiated = true; |
| 2241 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2248 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 2242 | 2249 |
| 2243 TestOldCompletionCallback callback1; | 2250 TestCompletionCallback callback1; |
| 2244 | 2251 |
| 2245 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2252 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2246 | 2253 |
| 2247 int rv = trans->Start(&request, &callback1, log.bound()); | 2254 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2248 EXPECT_EQ(ERR_IO_PENDING, rv); | 2255 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2249 | 2256 |
| 2250 rv = callback1.WaitForResult(); | 2257 rv = callback1.WaitForResult(); |
| 2251 EXPECT_EQ(OK, rv); | 2258 EXPECT_EQ(OK, rv); |
| 2252 | 2259 |
| 2253 const HttpResponseInfo* const response = trans->GetResponseInfo(); | 2260 const HttpResponseInfo* const response = trans->GetResponseInfo(); |
| 2254 | 2261 |
| 2255 ASSERT_TRUE(response != NULL); | 2262 ASSERT_TRUE(response != NULL); |
| 2256 ASSERT_TRUE(response->headers != NULL); | 2263 ASSERT_TRUE(response->headers != NULL); |
| 2257 EXPECT_EQ(407, response->headers->response_code()); | 2264 EXPECT_EQ(407, response->headers->response_code()); |
| 2258 EXPECT_TRUE(response->was_fetched_via_spdy); | 2265 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 2259 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2266 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 2260 | 2267 |
| 2261 TestOldCompletionCallback callback2; | 2268 TestCompletionCallback callback2; |
| 2262 | 2269 |
| 2263 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | 2270 rv = trans->RestartWithAuth( |
| 2271 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 2264 EXPECT_EQ(ERR_IO_PENDING, rv); | 2272 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2265 | 2273 |
| 2266 rv = callback2.WaitForResult(); | 2274 rv = callback2.WaitForResult(); |
| 2267 EXPECT_EQ(OK, rv); | 2275 EXPECT_EQ(OK, rv); |
| 2268 | 2276 |
| 2269 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); | 2277 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); |
| 2270 | 2278 |
| 2271 ASSERT_TRUE(response_restart != NULL); | 2279 ASSERT_TRUE(response_restart != NULL); |
| 2272 ASSERT_TRUE(response_restart->headers != NULL); | 2280 ASSERT_TRUE(response_restart->headers != NULL); |
| 2273 EXPECT_EQ(200, response_restart->headers->response_code()); | 2281 EXPECT_EQ(200, response_restart->headers->response_code()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2329 | 2337 |
| 2330 SSLSocketDataProvider ssl(true, OK); | 2338 SSLSocketDataProvider ssl(true, OK); |
| 2331 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 2339 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
| 2332 ssl.next_proto = "spdy/2"; | 2340 ssl.next_proto = "spdy/2"; |
| 2333 ssl.was_npn_negotiated = true; | 2341 ssl.was_npn_negotiated = true; |
| 2334 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2342 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 2335 SSLSocketDataProvider ssl2(true, OK); | 2343 SSLSocketDataProvider ssl2(true, OK); |
| 2336 ssl2.was_npn_negotiated = false; | 2344 ssl2.was_npn_negotiated = false; |
| 2337 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); | 2345 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); |
| 2338 | 2346 |
| 2339 TestOldCompletionCallback callback1; | 2347 TestCompletionCallback callback1; |
| 2340 | 2348 |
| 2341 int rv = trans->Start(&request, &callback1, log.bound()); | 2349 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2342 EXPECT_EQ(ERR_IO_PENDING, rv); | 2350 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2343 | 2351 |
| 2344 rv = callback1.WaitForResult(); | 2352 rv = callback1.WaitForResult(); |
| 2345 EXPECT_EQ(OK, rv); | 2353 EXPECT_EQ(OK, rv); |
| 2346 | 2354 |
| 2347 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2355 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2348 ASSERT_TRUE(response != NULL); | 2356 ASSERT_TRUE(response != NULL); |
| 2349 ASSERT_TRUE(response->headers != NULL); | 2357 ASSERT_TRUE(response->headers != NULL); |
| 2350 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2358 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 2351 | 2359 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2404 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 2412 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
| 2405 ssl.next_proto = "spdy/2"; | 2413 ssl.next_proto = "spdy/2"; |
| 2406 ssl.was_npn_negotiated = true; | 2414 ssl.was_npn_negotiated = true; |
| 2407 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2415 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 2408 SSLSocketDataProvider ssl2(true, OK); | 2416 SSLSocketDataProvider ssl2(true, OK); |
| 2409 ssl2.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 2417 ssl2.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
| 2410 ssl2.next_proto = "spdy/2"; | 2418 ssl2.next_proto = "spdy/2"; |
| 2411 ssl2.was_npn_negotiated = true; | 2419 ssl2.was_npn_negotiated = true; |
| 2412 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); | 2420 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); |
| 2413 | 2421 |
| 2414 TestOldCompletionCallback callback1; | 2422 TestCompletionCallback callback1; |
| 2415 | 2423 |
| 2416 int rv = trans->Start(&request, &callback1, log.bound()); | 2424 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2417 EXPECT_EQ(ERR_IO_PENDING, rv); | 2425 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2418 | 2426 |
| 2419 rv = callback1.WaitForResult(); | 2427 rv = callback1.WaitForResult(); |
| 2420 EXPECT_EQ(OK, rv); | 2428 EXPECT_EQ(OK, rv); |
| 2421 | 2429 |
| 2422 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2430 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2423 ASSERT_TRUE(response != NULL); | 2431 ASSERT_TRUE(response != NULL); |
| 2424 ASSERT_TRUE(response->headers != NULL); | 2432 ASSERT_TRUE(response->headers != NULL); |
| 2425 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2433 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 2426 | 2434 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2471 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 2479 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
| 2472 ssl.next_proto = "spdy/2"; | 2480 ssl.next_proto = "spdy/2"; |
| 2473 ssl.was_npn_negotiated = true; | 2481 ssl.was_npn_negotiated = true; |
| 2474 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2482 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 2475 SSLSocketDataProvider ssl2(true, OK); | 2483 SSLSocketDataProvider ssl2(true, OK); |
| 2476 ssl2.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 2484 ssl2.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
| 2477 ssl2.next_proto = "spdy/2"; | 2485 ssl2.next_proto = "spdy/2"; |
| 2478 ssl2.was_npn_negotiated = true; | 2486 ssl2.was_npn_negotiated = true; |
| 2479 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); | 2487 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); |
| 2480 | 2488 |
| 2481 TestOldCompletionCallback callback1; | 2489 TestCompletionCallback callback1; |
| 2482 | 2490 |
| 2483 int rv = trans->Start(&request, &callback1, log.bound()); | 2491 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2484 EXPECT_EQ(ERR_IO_PENDING, rv); | 2492 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2485 | 2493 |
| 2486 rv = callback1.WaitForResult(); | 2494 rv = callback1.WaitForResult(); |
| 2487 EXPECT_EQ(OK, rv); | 2495 EXPECT_EQ(OK, rv); |
| 2488 | 2496 |
| 2489 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2497 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2490 ASSERT_TRUE(response != NULL); | 2498 ASSERT_TRUE(response != NULL); |
| 2491 EXPECT_EQ(500, response->headers->response_code()); | 2499 EXPECT_EQ(500, response->headers->response_code()); |
| 2492 } | 2500 } |
| 2493 | 2501 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2534 MockRead("Content-Length: 100\r\n\r\n"), | 2542 MockRead("Content-Length: 100\r\n\r\n"), |
| 2535 MockRead(false, OK), | 2543 MockRead(false, OK), |
| 2536 }; | 2544 }; |
| 2537 | 2545 |
| 2538 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2546 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 2539 data_writes1, arraysize(data_writes1)); | 2547 data_writes1, arraysize(data_writes1)); |
| 2540 session_deps.socket_factory.AddSocketDataProvider(&data1); | 2548 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 2541 SSLSocketDataProvider ssl(true, OK); | 2549 SSLSocketDataProvider ssl(true, OK); |
| 2542 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2550 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 2543 | 2551 |
| 2544 TestOldCompletionCallback callback1; | 2552 TestCompletionCallback callback1; |
| 2545 | 2553 |
| 2546 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2554 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2547 | 2555 |
| 2548 int rv = trans->Start(&request, &callback1, log.bound()); | 2556 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2549 EXPECT_EQ(ERR_IO_PENDING, rv); | 2557 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2550 | 2558 |
| 2551 rv = callback1.WaitForResult(); | 2559 rv = callback1.WaitForResult(); |
| 2552 EXPECT_EQ(OK, rv); | 2560 EXPECT_EQ(OK, rv); |
| 2553 | 2561 |
| 2554 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2562 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2555 ASSERT_TRUE(response != NULL); | 2563 ASSERT_TRUE(response != NULL); |
| 2556 ASSERT_FALSE(response->headers == NULL); | 2564 ASSERT_FALSE(response->headers == NULL); |
| 2557 EXPECT_EQ(407, response->headers->response_code()); | 2565 EXPECT_EQ(407, response->headers->response_code()); |
| 2558 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2566 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 2559 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2567 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 2560 | 2568 |
| 2561 TestOldCompletionCallback callback2; | 2569 TestCompletionCallback callback2; |
| 2562 | 2570 |
| 2563 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | 2571 rv = trans->RestartWithAuth( |
| 2572 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 2564 EXPECT_EQ(ERR_IO_PENDING, rv); | 2573 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2565 | 2574 |
| 2566 rv = callback2.WaitForResult(); | 2575 rv = callback2.WaitForResult(); |
| 2567 EXPECT_EQ(OK, rv); | 2576 EXPECT_EQ(OK, rv); |
| 2568 | 2577 |
| 2569 response = trans->GetResponseInfo(); | 2578 response = trans->GetResponseInfo(); |
| 2570 ASSERT_TRUE(response != NULL); | 2579 ASSERT_TRUE(response != NULL); |
| 2571 | 2580 |
| 2572 EXPECT_TRUE(response->headers->IsKeepAlive()); | 2581 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 2573 EXPECT_EQ(200, response->headers->response_code()); | 2582 EXPECT_EQ(200, response->headers->response_code()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2601 status, | 2610 status, |
| 2602 MockRead("Content-Length: 10\r\n\r\n"), | 2611 MockRead("Content-Length: 10\r\n\r\n"), |
| 2603 // No response body because the test stops reading here. | 2612 // No response body because the test stops reading here. |
| 2604 MockRead(false, ERR_UNEXPECTED), // Should not be reached. | 2613 MockRead(false, ERR_UNEXPECTED), // Should not be reached. |
| 2605 }; | 2614 }; |
| 2606 | 2615 |
| 2607 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 2616 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 2608 data_writes, arraysize(data_writes)); | 2617 data_writes, arraysize(data_writes)); |
| 2609 session_deps.socket_factory.AddSocketDataProvider(&data); | 2618 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 2610 | 2619 |
| 2611 TestOldCompletionCallback callback; | 2620 TestCompletionCallback callback; |
| 2612 | 2621 |
| 2613 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2622 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2614 | 2623 |
| 2615 int rv = trans->Start(&request, &callback, BoundNetLog()); | 2624 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 2616 EXPECT_EQ(ERR_IO_PENDING, rv); | 2625 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2617 | 2626 |
| 2618 rv = callback.WaitForResult(); | 2627 rv = callback.WaitForResult(); |
| 2619 EXPECT_EQ(expected_status, rv); | 2628 EXPECT_EQ(expected_status, rv); |
| 2620 } | 2629 } |
| 2621 | 2630 |
| 2622 void HttpNetworkTransactionTest::ConnectStatusHelper(const MockRead& status) { | 2631 void HttpNetworkTransactionTest::ConnectStatusHelper(const MockRead& status) { |
| 2623 ConnectStatusHelperWithExpectedStatus( | 2632 ConnectStatusHelperWithExpectedStatus( |
| 2624 status, ERR_TUNNEL_CONNECTION_FAILED); | 2633 status, ERR_TUNNEL_CONNECTION_FAILED); |
| 2625 } | 2634 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2865 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2874 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 2866 data_writes1, arraysize(data_writes1)); | 2875 data_writes1, arraysize(data_writes1)); |
| 2867 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 2876 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 2868 data_writes2, arraysize(data_writes2)); | 2877 data_writes2, arraysize(data_writes2)); |
| 2869 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), | 2878 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), |
| 2870 data_writes3, arraysize(data_writes3)); | 2879 data_writes3, arraysize(data_writes3)); |
| 2871 session_deps.socket_factory.AddSocketDataProvider(&data1); | 2880 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 2872 session_deps.socket_factory.AddSocketDataProvider(&data2); | 2881 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 2873 session_deps.socket_factory.AddSocketDataProvider(&data3); | 2882 session_deps.socket_factory.AddSocketDataProvider(&data3); |
| 2874 | 2883 |
| 2875 TestOldCompletionCallback callback1; | 2884 TestCompletionCallback callback1; |
| 2876 | 2885 |
| 2877 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 2886 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 2878 EXPECT_EQ(ERR_IO_PENDING, rv); | 2887 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2879 | 2888 |
| 2880 rv = callback1.WaitForResult(); | 2889 rv = callback1.WaitForResult(); |
| 2881 EXPECT_EQ(OK, rv); | 2890 EXPECT_EQ(OK, rv); |
| 2882 | 2891 |
| 2883 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2892 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2884 ASSERT_TRUE(response != NULL); | 2893 ASSERT_TRUE(response != NULL); |
| 2885 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2894 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 2886 | 2895 |
| 2887 TestOldCompletionCallback callback2; | 2896 TestCompletionCallback callback2; |
| 2888 | 2897 |
| 2889 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | 2898 rv = trans->RestartWithAuth( |
| 2899 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 2890 EXPECT_EQ(ERR_IO_PENDING, rv); | 2900 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2891 | 2901 |
| 2892 rv = callback2.WaitForResult(); | 2902 rv = callback2.WaitForResult(); |
| 2893 EXPECT_EQ(OK, rv); | 2903 EXPECT_EQ(OK, rv); |
| 2894 | 2904 |
| 2895 response = trans->GetResponseInfo(); | 2905 response = trans->GetResponseInfo(); |
| 2896 ASSERT_TRUE(response != NULL); | 2906 ASSERT_TRUE(response != NULL); |
| 2897 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 2907 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 2898 | 2908 |
| 2899 TestOldCompletionCallback callback3; | 2909 TestCompletionCallback callback3; |
| 2900 | 2910 |
| 2901 rv = trans->RestartWithAuth(AuthCredentials(kFoo2, kBar2), &callback3); | 2911 rv = trans->RestartWithAuth( |
| 2912 AuthCredentials(kFoo2, kBar2), callback3.callback()); |
| 2902 EXPECT_EQ(ERR_IO_PENDING, rv); | 2913 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2903 | 2914 |
| 2904 rv = callback3.WaitForResult(); | 2915 rv = callback3.WaitForResult(); |
| 2905 EXPECT_EQ(OK, rv); | 2916 EXPECT_EQ(OK, rv); |
| 2906 | 2917 |
| 2907 response = trans->GetResponseInfo(); | 2918 response = trans->GetResponseInfo(); |
| 2908 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2919 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 2909 EXPECT_EQ(100, response->headers->GetContentLength()); | 2920 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 2910 } | 2921 } |
| 2911 | 2922 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2994 MockRead(false, OK), | 3005 MockRead(false, OK), |
| 2995 }; | 3006 }; |
| 2996 | 3007 |
| 2997 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3008 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 2998 data_writes1, arraysize(data_writes1)); | 3009 data_writes1, arraysize(data_writes1)); |
| 2999 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 3010 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 3000 data_writes2, arraysize(data_writes2)); | 3011 data_writes2, arraysize(data_writes2)); |
| 3001 session_deps.socket_factory.AddSocketDataProvider(&data1); | 3012 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 3002 session_deps.socket_factory.AddSocketDataProvider(&data2); | 3013 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 3003 | 3014 |
| 3004 TestOldCompletionCallback callback1; | 3015 TestCompletionCallback callback1; |
| 3005 | 3016 |
| 3006 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 3017 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 3007 | 3018 |
| 3008 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 3019 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 3009 EXPECT_EQ(ERR_IO_PENDING, rv); | 3020 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3010 | 3021 |
| 3011 rv = callback1.WaitForResult(); | 3022 rv = callback1.WaitForResult(); |
| 3012 EXPECT_EQ(OK, rv); | 3023 EXPECT_EQ(OK, rv); |
| 3013 | 3024 |
| 3014 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3025 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 3015 | 3026 |
| 3016 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3027 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3017 ASSERT_FALSE(response == NULL); | 3028 ASSERT_FALSE(response == NULL); |
| 3018 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); | 3029 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); |
| 3019 | 3030 |
| 3020 TestOldCompletionCallback callback2; | 3031 TestCompletionCallback callback2; |
| 3021 | 3032 |
| 3022 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kTestingNTLM), | 3033 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kTestingNTLM), |
| 3023 &callback2); | 3034 callback2.callback()); |
| 3024 EXPECT_EQ(ERR_IO_PENDING, rv); | 3035 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3025 | 3036 |
| 3026 rv = callback2.WaitForResult(); | 3037 rv = callback2.WaitForResult(); |
| 3027 EXPECT_EQ(OK, rv); | 3038 EXPECT_EQ(OK, rv); |
| 3028 | 3039 |
| 3029 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 3040 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 3030 | 3041 |
| 3031 response = trans->GetResponseInfo(); | 3042 response = trans->GetResponseInfo(); |
| 3032 ASSERT_TRUE(response != NULL); | 3043 ASSERT_TRUE(response != NULL); |
| 3033 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3044 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 3034 | 3045 |
| 3035 TestOldCompletionCallback callback3; | 3046 TestCompletionCallback callback3; |
| 3036 | 3047 |
| 3037 rv = trans->RestartWithAuth(AuthCredentials(), &callback3); | 3048 rv = trans->RestartWithAuth(AuthCredentials(), callback3.callback()); |
| 3038 EXPECT_EQ(ERR_IO_PENDING, rv); | 3049 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3039 | 3050 |
| 3040 rv = callback3.WaitForResult(); | 3051 rv = callback3.WaitForResult(); |
| 3041 EXPECT_EQ(OK, rv); | 3052 EXPECT_EQ(OK, rv); |
| 3042 | 3053 |
| 3043 response = trans->GetResponseInfo(); | 3054 response = trans->GetResponseInfo(); |
| 3044 ASSERT_TRUE(response != NULL); | 3055 ASSERT_TRUE(response != NULL); |
| 3045 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3056 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 3046 EXPECT_EQ(13, response->headers->GetContentLength()); | 3057 EXPECT_EQ(13, response->headers->GetContentLength()); |
| 3047 } | 3058 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3174 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3185 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 3175 data_writes1, arraysize(data_writes1)); | 3186 data_writes1, arraysize(data_writes1)); |
| 3176 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 3187 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 3177 data_writes2, arraysize(data_writes2)); | 3188 data_writes2, arraysize(data_writes2)); |
| 3178 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), | 3189 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), |
| 3179 data_writes3, arraysize(data_writes3)); | 3190 data_writes3, arraysize(data_writes3)); |
| 3180 session_deps.socket_factory.AddSocketDataProvider(&data1); | 3191 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 3181 session_deps.socket_factory.AddSocketDataProvider(&data2); | 3192 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 3182 session_deps.socket_factory.AddSocketDataProvider(&data3); | 3193 session_deps.socket_factory.AddSocketDataProvider(&data3); |
| 3183 | 3194 |
| 3184 TestOldCompletionCallback callback1; | 3195 TestCompletionCallback callback1; |
| 3185 | 3196 |
| 3186 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 3197 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 3187 | 3198 |
| 3188 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 3199 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 3189 EXPECT_EQ(ERR_IO_PENDING, rv); | 3200 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3190 | 3201 |
| 3191 rv = callback1.WaitForResult(); | 3202 rv = callback1.WaitForResult(); |
| 3192 EXPECT_EQ(OK, rv); | 3203 EXPECT_EQ(OK, rv); |
| 3193 | 3204 |
| 3194 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3205 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 3195 | 3206 |
| 3196 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3207 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3197 ASSERT_TRUE(response != NULL); | 3208 ASSERT_TRUE(response != NULL); |
| 3198 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); | 3209 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); |
| 3199 | 3210 |
| 3200 TestOldCompletionCallback callback2; | 3211 TestCompletionCallback callback2; |
| 3201 | 3212 |
| 3202 // Enter the wrong password. | 3213 // Enter the wrong password. |
| 3203 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kWrongPassword), | 3214 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kWrongPassword), |
| 3204 &callback2); | 3215 callback2.callback()); |
| 3205 EXPECT_EQ(ERR_IO_PENDING, rv); | 3216 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3206 | 3217 |
| 3207 rv = callback2.WaitForResult(); | 3218 rv = callback2.WaitForResult(); |
| 3208 EXPECT_EQ(OK, rv); | 3219 EXPECT_EQ(OK, rv); |
| 3209 | 3220 |
| 3210 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 3221 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 3211 TestOldCompletionCallback callback3; | 3222 TestCompletionCallback callback3; |
| 3212 rv = trans->RestartWithAuth(AuthCredentials(), &callback3); | 3223 rv = trans->RestartWithAuth(AuthCredentials(), callback3.callback()); |
| 3213 EXPECT_EQ(ERR_IO_PENDING, rv); | 3224 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3214 rv = callback3.WaitForResult(); | 3225 rv = callback3.WaitForResult(); |
| 3215 EXPECT_EQ(OK, rv); | 3226 EXPECT_EQ(OK, rv); |
| 3216 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3227 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 3217 | 3228 |
| 3218 response = trans->GetResponseInfo(); | 3229 response = trans->GetResponseInfo(); |
| 3219 ASSERT_FALSE(response == NULL); | 3230 ASSERT_FALSE(response == NULL); |
| 3220 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); | 3231 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); |
| 3221 | 3232 |
| 3222 TestOldCompletionCallback callback4; | 3233 TestCompletionCallback callback4; |
| 3223 | 3234 |
| 3224 // Now enter the right password. | 3235 // Now enter the right password. |
| 3225 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kTestingNTLM), | 3236 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kTestingNTLM), |
| 3226 &callback4); | 3237 callback4.callback()); |
| 3227 EXPECT_EQ(ERR_IO_PENDING, rv); | 3238 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3228 | 3239 |
| 3229 rv = callback4.WaitForResult(); | 3240 rv = callback4.WaitForResult(); |
| 3230 EXPECT_EQ(OK, rv); | 3241 EXPECT_EQ(OK, rv); |
| 3231 | 3242 |
| 3232 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 3243 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 3233 | 3244 |
| 3234 TestOldCompletionCallback callback5; | 3245 TestCompletionCallback callback5; |
| 3235 | 3246 |
| 3236 // One more roundtrip | 3247 // One more roundtrip |
| 3237 rv = trans->RestartWithAuth(AuthCredentials(), &callback5); | 3248 rv = trans->RestartWithAuth(AuthCredentials(), callback5.callback()); |
| 3238 EXPECT_EQ(ERR_IO_PENDING, rv); | 3249 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3239 | 3250 |
| 3240 rv = callback5.WaitForResult(); | 3251 rv = callback5.WaitForResult(); |
| 3241 EXPECT_EQ(OK, rv); | 3252 EXPECT_EQ(OK, rv); |
| 3242 | 3253 |
| 3243 response = trans->GetResponseInfo(); | 3254 response = trans->GetResponseInfo(); |
| 3244 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3255 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 3245 EXPECT_EQ(13, response->headers->GetContentLength()); | 3256 EXPECT_EQ(13, response->headers->GetContentLength()); |
| 3246 } | 3257 } |
| 3247 #endif // NTLM_PORTABLE | 3258 #endif // NTLM_PORTABLE |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3265 | 3276 |
| 3266 MockRead data_reads[] = { | 3277 MockRead data_reads[] = { |
| 3267 MockRead("HTTP/1.0 200 OK\r\n"), | 3278 MockRead("HTTP/1.0 200 OK\r\n"), |
| 3268 MockRead(true, large_headers_string.data(), large_headers_string.size()), | 3279 MockRead(true, large_headers_string.data(), large_headers_string.size()), |
| 3269 MockRead("\r\nBODY"), | 3280 MockRead("\r\nBODY"), |
| 3270 MockRead(false, OK), | 3281 MockRead(false, OK), |
| 3271 }; | 3282 }; |
| 3272 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 3283 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 3273 session_deps.socket_factory.AddSocketDataProvider(&data); | 3284 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 3274 | 3285 |
| 3275 TestOldCompletionCallback callback; | 3286 TestCompletionCallback callback; |
| 3276 | 3287 |
| 3277 int rv = trans->Start(&request, &callback, BoundNetLog()); | 3288 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 3278 EXPECT_EQ(ERR_IO_PENDING, rv); | 3289 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3279 | 3290 |
| 3280 rv = callback.WaitForResult(); | 3291 rv = callback.WaitForResult(); |
| 3281 EXPECT_EQ(ERR_RESPONSE_HEADERS_TOO_BIG, rv); | 3292 EXPECT_EQ(ERR_RESPONSE_HEADERS_TOO_BIG, rv); |
| 3282 | 3293 |
| 3283 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3294 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3284 EXPECT_TRUE(response == NULL); | 3295 EXPECT_TRUE(response == NULL); |
| 3285 } | 3296 } |
| 3286 | 3297 |
| 3287 // Make sure that we don't try to reuse a TCPClientSocket when failing to | 3298 // Make sure that we don't try to reuse a TCPClientSocket when failing to |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3313 MockRead data_reads1[] = { | 3324 MockRead data_reads1[] = { |
| 3314 MockRead("HTTP/1.1 404 Not Found\r\n"), | 3325 MockRead("HTTP/1.1 404 Not Found\r\n"), |
| 3315 MockRead("Content-Length: 10\r\n\r\n"), | 3326 MockRead("Content-Length: 10\r\n\r\n"), |
| 3316 MockRead(false, ERR_UNEXPECTED), // Should not be reached. | 3327 MockRead(false, ERR_UNEXPECTED), // Should not be reached. |
| 3317 }; | 3328 }; |
| 3318 | 3329 |
| 3319 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3330 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 3320 data_writes1, arraysize(data_writes1)); | 3331 data_writes1, arraysize(data_writes1)); |
| 3321 session_deps.socket_factory.AddSocketDataProvider(&data1); | 3332 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 3322 | 3333 |
| 3323 TestOldCompletionCallback callback1; | 3334 TestCompletionCallback callback1; |
| 3324 | 3335 |
| 3325 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 3336 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 3326 EXPECT_EQ(ERR_IO_PENDING, rv); | 3337 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3327 | 3338 |
| 3328 rv = callback1.WaitForResult(); | 3339 rv = callback1.WaitForResult(); |
| 3329 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); | 3340 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); |
| 3330 | 3341 |
| 3331 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3342 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3332 EXPECT_TRUE(response == NULL); | 3343 EXPECT_TRUE(response == NULL); |
| 3333 | 3344 |
| 3334 // Empty the current queue. This is necessary because idle sockets are | 3345 // Empty the current queue. This is necessary because idle sockets are |
| 3335 // added to the connection pool asynchronously with a PostTask. | 3346 // added to the connection pool asynchronously with a PostTask. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3362 // The rest of the response body is received in two parts. | 3373 // The rest of the response body is received in two parts. |
| 3363 MockRead("lo"), | 3374 MockRead("lo"), |
| 3364 MockRead(" world"), | 3375 MockRead(" world"), |
| 3365 MockRead("junk"), // Should not be read!! | 3376 MockRead("junk"), // Should not be read!! |
| 3366 MockRead(false, OK), | 3377 MockRead(false, OK), |
| 3367 }; | 3378 }; |
| 3368 | 3379 |
| 3369 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 3380 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 3370 session_deps.socket_factory.AddSocketDataProvider(&data); | 3381 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 3371 | 3382 |
| 3372 TestOldCompletionCallback callback; | 3383 TestCompletionCallback callback; |
| 3373 | 3384 |
| 3374 int rv = trans->Start(&request, &callback, BoundNetLog()); | 3385 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 3375 EXPECT_EQ(ERR_IO_PENDING, rv); | 3386 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3376 | 3387 |
| 3377 rv = callback.WaitForResult(); | 3388 rv = callback.WaitForResult(); |
| 3378 EXPECT_EQ(OK, rv); | 3389 EXPECT_EQ(OK, rv); |
| 3379 | 3390 |
| 3380 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3391 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3381 ASSERT_TRUE(response != NULL); | 3392 ASSERT_TRUE(response != NULL); |
| 3382 | 3393 |
| 3383 EXPECT_TRUE(response->headers != NULL); | 3394 EXPECT_TRUE(response->headers != NULL); |
| 3384 std::string status_line = response->headers->GetStatusLine(); | 3395 std::string status_line = response->headers->GetStatusLine(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3421 MockRead(false, OK), | 3432 MockRead(false, OK), |
| 3422 }; | 3433 }; |
| 3423 | 3434 |
| 3424 SSLSocketDataProvider ssl(true, OK); | 3435 SSLSocketDataProvider ssl(true, OK); |
| 3425 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 3436 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 3426 | 3437 |
| 3427 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 3438 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 3428 data_writes, arraysize(data_writes)); | 3439 data_writes, arraysize(data_writes)); |
| 3429 session_deps.socket_factory.AddSocketDataProvider(&data); | 3440 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 3430 | 3441 |
| 3431 TestOldCompletionCallback callback; | 3442 TestCompletionCallback callback; |
| 3432 | 3443 |
| 3433 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3444 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 3434 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 3445 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 3435 | 3446 |
| 3436 int rv = trans->Start(&request, &callback, BoundNetLog()); | 3447 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 3437 | 3448 |
| 3438 EXPECT_EQ(ERR_IO_PENDING, rv); | 3449 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3439 EXPECT_EQ(OK, callback.WaitForResult()); | 3450 EXPECT_EQ(OK, callback.WaitForResult()); |
| 3440 | 3451 |
| 3441 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3452 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3442 ASSERT_TRUE(response != NULL); | 3453 ASSERT_TRUE(response != NULL); |
| 3443 ASSERT_TRUE(response->headers != NULL); | 3454 ASSERT_TRUE(response->headers != NULL); |
| 3444 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 3455 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 3445 | 3456 |
| 3446 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount()); | 3457 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3489 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 3500 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 3490 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); | 3501 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); |
| 3491 | 3502 |
| 3492 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 3503 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 3493 data_writes, arraysize(data_writes)); | 3504 data_writes, arraysize(data_writes)); |
| 3494 StaticSocketDataProvider data2(data_reads, arraysize(data_reads), | 3505 StaticSocketDataProvider data2(data_reads, arraysize(data_reads), |
| 3495 data_writes, arraysize(data_writes)); | 3506 data_writes, arraysize(data_writes)); |
| 3496 session_deps.socket_factory.AddSocketDataProvider(&data); | 3507 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 3497 session_deps.socket_factory.AddSocketDataProvider(&data2); | 3508 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 3498 | 3509 |
| 3499 TestOldCompletionCallback callback; | 3510 TestCompletionCallback callback; |
| 3500 | 3511 |
| 3501 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3512 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 3502 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 3513 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 3503 | 3514 |
| 3504 int rv = trans->Start(&request, &callback, BoundNetLog()); | 3515 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 3505 | 3516 |
| 3506 EXPECT_EQ(ERR_IO_PENDING, rv); | 3517 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3507 EXPECT_EQ(OK, callback.WaitForResult()); | 3518 EXPECT_EQ(OK, callback.WaitForResult()); |
| 3508 | 3519 |
| 3509 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3520 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3510 ASSERT_TRUE(response != NULL); | 3521 ASSERT_TRUE(response != NULL); |
| 3511 ASSERT_TRUE(response->headers != NULL); | 3522 ASSERT_TRUE(response->headers != NULL); |
| 3512 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 3523 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 3513 | 3524 |
| 3514 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount()); | 3525 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount()); |
| 3515 | 3526 |
| 3516 std::string response_data; | 3527 std::string response_data; |
| 3517 rv = ReadTransaction(trans.get(), &response_data); | 3528 rv = ReadTransaction(trans.get(), &response_data); |
| 3518 EXPECT_EQ(OK, rv); | 3529 EXPECT_EQ(OK, rv); |
| 3519 EXPECT_EQ("hello world", response_data); | 3530 EXPECT_EQ("hello world", response_data); |
| 3520 | 3531 |
| 3521 // Empty the current queue. This is necessary because idle sockets are | 3532 // Empty the current queue. This is necessary because idle sockets are |
| 3522 // added to the connection pool asynchronously with a PostTask. | 3533 // added to the connection pool asynchronously with a PostTask. |
| 3523 MessageLoop::current()->RunAllPending(); | 3534 MessageLoop::current()->RunAllPending(); |
| 3524 | 3535 |
| 3525 // We now check to make sure the socket was added back to the pool. | 3536 // We now check to make sure the socket was added back to the pool. |
| 3526 EXPECT_EQ(1, session->GetSSLSocketPool()->IdleSocketCount()); | 3537 EXPECT_EQ(1, session->GetSSLSocketPool()->IdleSocketCount()); |
| 3527 | 3538 |
| 3528 // Now start the second transaction, which should reuse the previous socket. | 3539 // Now start the second transaction, which should reuse the previous socket. |
| 3529 | 3540 |
| 3530 trans.reset(new HttpNetworkTransaction(session)); | 3541 trans.reset(new HttpNetworkTransaction(session)); |
| 3531 | 3542 |
| 3532 rv = trans->Start(&request, &callback, BoundNetLog()); | 3543 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 3533 | 3544 |
| 3534 EXPECT_EQ(ERR_IO_PENDING, rv); | 3545 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3535 EXPECT_EQ(OK, callback.WaitForResult()); | 3546 EXPECT_EQ(OK, callback.WaitForResult()); |
| 3536 | 3547 |
| 3537 response = trans->GetResponseInfo(); | 3548 response = trans->GetResponseInfo(); |
| 3538 ASSERT_TRUE(response != NULL); | 3549 ASSERT_TRUE(response != NULL); |
| 3539 ASSERT_TRUE(response->headers != NULL); | 3550 ASSERT_TRUE(response->headers != NULL); |
| 3540 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 3551 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 3541 | 3552 |
| 3542 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount()); | 3553 EXPECT_EQ(0, session->GetTransportSocketPool()->IdleSocketCount()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3573 MockRead("HTTP/1.1 204 No Content\r\n" | 3584 MockRead("HTTP/1.1 204 No Content\r\n" |
| 3574 "Content-Length: 0\r\n" | 3585 "Content-Length: 0\r\n" |
| 3575 "Content-Type: text/html\r\n\r\n"), | 3586 "Content-Type: text/html\r\n\r\n"), |
| 3576 MockRead("junk"), // Should not be read!! | 3587 MockRead("junk"), // Should not be read!! |
| 3577 MockRead(false, OK), | 3588 MockRead(false, OK), |
| 3578 }; | 3589 }; |
| 3579 | 3590 |
| 3580 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 3591 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 3581 session_deps.socket_factory.AddSocketDataProvider(&data); | 3592 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 3582 | 3593 |
| 3583 TestOldCompletionCallback callback; | 3594 TestCompletionCallback callback; |
| 3584 | 3595 |
| 3585 int rv = trans->Start(&request, &callback, BoundNetLog()); | 3596 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 3586 EXPECT_EQ(ERR_IO_PENDING, rv); | 3597 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3587 | 3598 |
| 3588 rv = callback.WaitForResult(); | 3599 rv = callback.WaitForResult(); |
| 3589 EXPECT_EQ(OK, rv); | 3600 EXPECT_EQ(OK, rv); |
| 3590 | 3601 |
| 3591 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3602 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3592 ASSERT_TRUE(response != NULL); | 3603 ASSERT_TRUE(response != NULL); |
| 3593 | 3604 |
| 3594 EXPECT_TRUE(response->headers != NULL); | 3605 EXPECT_TRUE(response->headers != NULL); |
| 3595 std::string status_line = response->headers->GetStatusLine(); | 3606 std::string status_line = response->headers->GetStatusLine(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3669 session_deps.socket_factory.AddSocketDataProvider(&data2); | 3680 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 3670 | 3681 |
| 3671 const char* kExpectedResponseData[] = { | 3682 const char* kExpectedResponseData[] = { |
| 3672 "hello world", "welcome" | 3683 "hello world", "welcome" |
| 3673 }; | 3684 }; |
| 3674 | 3685 |
| 3675 for (int i = 0; i < 2; ++i) { | 3686 for (int i = 0; i < 2; ++i) { |
| 3676 scoped_ptr<HttpTransaction> trans( | 3687 scoped_ptr<HttpTransaction> trans( |
| 3677 new HttpNetworkTransaction(session)); | 3688 new HttpNetworkTransaction(session)); |
| 3678 | 3689 |
| 3679 TestOldCompletionCallback callback; | 3690 TestCompletionCallback callback; |
| 3680 | 3691 |
| 3681 int rv = trans->Start(&request[i], &callback, BoundNetLog()); | 3692 int rv = trans->Start(&request[i], callback.callback(), BoundNetLog()); |
| 3682 EXPECT_EQ(ERR_IO_PENDING, rv); | 3693 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3683 | 3694 |
| 3684 rv = callback.WaitForResult(); | 3695 rv = callback.WaitForResult(); |
| 3685 EXPECT_EQ(OK, rv); | 3696 EXPECT_EQ(OK, rv); |
| 3686 | 3697 |
| 3687 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3698 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3688 ASSERT_TRUE(response != NULL); | 3699 ASSERT_TRUE(response != NULL); |
| 3689 | 3700 |
| 3690 EXPECT_TRUE(response->headers != NULL); | 3701 EXPECT_TRUE(response->headers != NULL); |
| 3691 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 3702 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3744 MockRead(false, OK), | 3755 MockRead(false, OK), |
| 3745 }; | 3756 }; |
| 3746 | 3757 |
| 3747 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3758 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 3748 data_writes1, arraysize(data_writes1)); | 3759 data_writes1, arraysize(data_writes1)); |
| 3749 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 3760 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 3750 data_writes2, arraysize(data_writes2)); | 3761 data_writes2, arraysize(data_writes2)); |
| 3751 session_deps.socket_factory.AddSocketDataProvider(&data1); | 3762 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 3752 session_deps.socket_factory.AddSocketDataProvider(&data2); | 3763 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 3753 | 3764 |
| 3754 TestOldCompletionCallback callback1; | 3765 TestCompletionCallback callback1; |
| 3755 | 3766 |
| 3756 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 3767 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 3757 EXPECT_EQ(ERR_IO_PENDING, rv); | 3768 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3758 | 3769 |
| 3759 rv = callback1.WaitForResult(); | 3770 rv = callback1.WaitForResult(); |
| 3760 EXPECT_EQ(OK, rv); | 3771 EXPECT_EQ(OK, rv); |
| 3761 | 3772 |
| 3762 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 3773 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 3763 TestOldCompletionCallback callback2; | 3774 TestCompletionCallback callback2; |
| 3764 rv = trans->RestartWithAuth(AuthCredentials(), &callback2); | 3775 rv = trans->RestartWithAuth(AuthCredentials(), callback2.callback()); |
| 3765 EXPECT_EQ(ERR_IO_PENDING, rv); | 3776 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3766 rv = callback2.WaitForResult(); | 3777 rv = callback2.WaitForResult(); |
| 3767 EXPECT_EQ(OK, rv); | 3778 EXPECT_EQ(OK, rv); |
| 3768 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3779 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 3769 | 3780 |
| 3770 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3781 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3771 ASSERT_TRUE(response != NULL); | 3782 ASSERT_TRUE(response != NULL); |
| 3772 | 3783 |
| 3773 // There is no challenge info, since the identity in URL worked. | 3784 // There is no challenge info, since the identity in URL worked. |
| 3774 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3785 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3842 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3853 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 3843 data_writes1, arraysize(data_writes1)); | 3854 data_writes1, arraysize(data_writes1)); |
| 3844 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 3855 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 3845 data_writes2, arraysize(data_writes2)); | 3856 data_writes2, arraysize(data_writes2)); |
| 3846 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), | 3857 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), |
| 3847 data_writes3, arraysize(data_writes3)); | 3858 data_writes3, arraysize(data_writes3)); |
| 3848 session_deps.socket_factory.AddSocketDataProvider(&data1); | 3859 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 3849 session_deps.socket_factory.AddSocketDataProvider(&data2); | 3860 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 3850 session_deps.socket_factory.AddSocketDataProvider(&data3); | 3861 session_deps.socket_factory.AddSocketDataProvider(&data3); |
| 3851 | 3862 |
| 3852 TestOldCompletionCallback callback1; | 3863 TestCompletionCallback callback1; |
| 3853 | 3864 |
| 3854 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 3865 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 3855 EXPECT_EQ(ERR_IO_PENDING, rv); | 3866 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3856 | 3867 |
| 3857 rv = callback1.WaitForResult(); | 3868 rv = callback1.WaitForResult(); |
| 3858 EXPECT_EQ(OK, rv); | 3869 EXPECT_EQ(OK, rv); |
| 3859 | 3870 |
| 3860 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 3871 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 3861 TestOldCompletionCallback callback2; | 3872 TestCompletionCallback callback2; |
| 3862 rv = trans->RestartWithAuth(AuthCredentials(), &callback2); | 3873 rv = trans->RestartWithAuth(AuthCredentials(), callback2.callback()); |
| 3863 EXPECT_EQ(ERR_IO_PENDING, rv); | 3874 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3864 rv = callback2.WaitForResult(); | 3875 rv = callback2.WaitForResult(); |
| 3865 EXPECT_EQ(OK, rv); | 3876 EXPECT_EQ(OK, rv); |
| 3866 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3877 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 3867 | 3878 |
| 3868 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3879 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3869 ASSERT_TRUE(response != NULL); | 3880 ASSERT_TRUE(response != NULL); |
| 3870 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 3881 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 3871 | 3882 |
| 3872 TestOldCompletionCallback callback3; | 3883 TestCompletionCallback callback3; |
| 3873 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback3); | 3884 rv = trans->RestartWithAuth( |
| 3885 AuthCredentials(kFoo, kBar), callback3.callback()); |
| 3874 EXPECT_EQ(ERR_IO_PENDING, rv); | 3886 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3875 rv = callback3.WaitForResult(); | 3887 rv = callback3.WaitForResult(); |
| 3876 EXPECT_EQ(OK, rv); | 3888 EXPECT_EQ(OK, rv); |
| 3877 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3889 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 3878 | 3890 |
| 3879 response = trans->GetResponseInfo(); | 3891 response = trans->GetResponseInfo(); |
| 3880 ASSERT_TRUE(response != NULL); | 3892 ASSERT_TRUE(response != NULL); |
| 3881 | 3893 |
| 3882 // There is no challenge info, since the identity worked. | 3894 // There is no challenge info, since the identity worked. |
| 3883 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3895 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3930 MockRead(false, OK), | 3942 MockRead(false, OK), |
| 3931 }; | 3943 }; |
| 3932 | 3944 |
| 3933 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3945 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 3934 data_writes1, arraysize(data_writes1)); | 3946 data_writes1, arraysize(data_writes1)); |
| 3935 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 3947 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 3936 data_writes2, arraysize(data_writes2)); | 3948 data_writes2, arraysize(data_writes2)); |
| 3937 session_deps.socket_factory.AddSocketDataProvider(&data1); | 3949 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 3938 session_deps.socket_factory.AddSocketDataProvider(&data2); | 3950 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 3939 | 3951 |
| 3940 TestOldCompletionCallback callback1; | 3952 TestCompletionCallback callback1; |
| 3941 | 3953 |
| 3942 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 3954 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 3943 EXPECT_EQ(ERR_IO_PENDING, rv); | 3955 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3944 | 3956 |
| 3945 rv = callback1.WaitForResult(); | 3957 rv = callback1.WaitForResult(); |
| 3946 EXPECT_EQ(OK, rv); | 3958 EXPECT_EQ(OK, rv); |
| 3947 | 3959 |
| 3948 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3960 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3949 ASSERT_TRUE(response != NULL); | 3961 ASSERT_TRUE(response != NULL); |
| 3950 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 3962 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 3951 | 3963 |
| 3952 TestOldCompletionCallback callback2; | 3964 TestCompletionCallback callback2; |
| 3953 | 3965 |
| 3954 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | 3966 rv = trans->RestartWithAuth( |
| 3967 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 3955 EXPECT_EQ(ERR_IO_PENDING, rv); | 3968 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3956 | 3969 |
| 3957 rv = callback2.WaitForResult(); | 3970 rv = callback2.WaitForResult(); |
| 3958 EXPECT_EQ(OK, rv); | 3971 EXPECT_EQ(OK, rv); |
| 3959 | 3972 |
| 3960 response = trans->GetResponseInfo(); | 3973 response = trans->GetResponseInfo(); |
| 3961 ASSERT_TRUE(response != NULL); | 3974 ASSERT_TRUE(response != NULL); |
| 3962 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3975 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 3963 EXPECT_EQ(100, response->headers->GetContentLength()); | 3976 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 3964 } | 3977 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4008 MockRead(false, OK), | 4021 MockRead(false, OK), |
| 4009 }; | 4022 }; |
| 4010 | 4023 |
| 4011 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 4024 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 4012 data_writes1, arraysize(data_writes1)); | 4025 data_writes1, arraysize(data_writes1)); |
| 4013 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 4026 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 4014 data_writes2, arraysize(data_writes2)); | 4027 data_writes2, arraysize(data_writes2)); |
| 4015 session_deps.socket_factory.AddSocketDataProvider(&data1); | 4028 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 4016 session_deps.socket_factory.AddSocketDataProvider(&data2); | 4029 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 4017 | 4030 |
| 4018 TestOldCompletionCallback callback1; | 4031 TestCompletionCallback callback1; |
| 4019 | 4032 |
| 4020 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 4033 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 4021 EXPECT_EQ(ERR_IO_PENDING, rv); | 4034 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4022 | 4035 |
| 4023 rv = callback1.WaitForResult(); | 4036 rv = callback1.WaitForResult(); |
| 4024 EXPECT_EQ(OK, rv); | 4037 EXPECT_EQ(OK, rv); |
| 4025 | 4038 |
| 4026 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4039 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4027 ASSERT_TRUE(response != NULL); | 4040 ASSERT_TRUE(response != NULL); |
| 4028 ASSERT_TRUE(response->auth_challenge.get()); | 4041 ASSERT_TRUE(response->auth_challenge.get()); |
| 4029 EXPECT_FALSE(response->auth_challenge->is_proxy); | 4042 EXPECT_FALSE(response->auth_challenge->is_proxy); |
| 4030 EXPECT_EQ("www.google.com:80", | 4043 EXPECT_EQ("www.google.com:80", |
| 4031 response->auth_challenge->challenger.ToString()); | 4044 response->auth_challenge->challenger.ToString()); |
| 4032 EXPECT_EQ("MyRealm2", response->auth_challenge->realm); | 4045 EXPECT_EQ("MyRealm2", response->auth_challenge->realm); |
| 4033 EXPECT_EQ("basic", response->auth_challenge->scheme); | 4046 EXPECT_EQ("basic", response->auth_challenge->scheme); |
| 4034 | 4047 |
| 4035 TestOldCompletionCallback callback2; | 4048 TestCompletionCallback callback2; |
| 4036 | 4049 |
| 4037 rv = trans->RestartWithAuth(AuthCredentials(kFoo2, kBar2), &callback2); | 4050 rv = trans->RestartWithAuth( |
| 4051 AuthCredentials(kFoo2, kBar2), callback2.callback()); |
| 4038 EXPECT_EQ(ERR_IO_PENDING, rv); | 4052 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4039 | 4053 |
| 4040 rv = callback2.WaitForResult(); | 4054 rv = callback2.WaitForResult(); |
| 4041 EXPECT_EQ(OK, rv); | 4055 EXPECT_EQ(OK, rv); |
| 4042 | 4056 |
| 4043 response = trans->GetResponseInfo(); | 4057 response = trans->GetResponseInfo(); |
| 4044 ASSERT_TRUE(response != NULL); | 4058 ASSERT_TRUE(response != NULL); |
| 4045 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4059 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 4046 EXPECT_EQ(100, response->headers->GetContentLength()); | 4060 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 4047 } | 4061 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4071 MockRead data_reads1[] = { | 4085 MockRead data_reads1[] = { |
| 4072 MockRead("HTTP/1.0 200 OK\r\n"), | 4086 MockRead("HTTP/1.0 200 OK\r\n"), |
| 4073 MockRead("Content-Length: 100\r\n\r\n"), | 4087 MockRead("Content-Length: 100\r\n\r\n"), |
| 4074 MockRead(false, OK), | 4088 MockRead(false, OK), |
| 4075 }; | 4089 }; |
| 4076 | 4090 |
| 4077 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 4091 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 4078 data_writes1, arraysize(data_writes1)); | 4092 data_writes1, arraysize(data_writes1)); |
| 4079 session_deps.socket_factory.AddSocketDataProvider(&data1); | 4093 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 4080 | 4094 |
| 4081 TestOldCompletionCallback callback1; | 4095 TestCompletionCallback callback1; |
| 4082 | 4096 |
| 4083 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 4097 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 4084 EXPECT_EQ(ERR_IO_PENDING, rv); | 4098 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4085 | 4099 |
| 4086 rv = callback1.WaitForResult(); | 4100 rv = callback1.WaitForResult(); |
| 4087 EXPECT_EQ(OK, rv); | 4101 EXPECT_EQ(OK, rv); |
| 4088 | 4102 |
| 4089 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4103 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4090 ASSERT_TRUE(response != NULL); | 4104 ASSERT_TRUE(response != NULL); |
| 4091 | 4105 |
| 4092 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4106 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 4093 EXPECT_EQ(100, response->headers->GetContentLength()); | 4107 EXPECT_EQ(100, response->headers->GetContentLength()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4133 MockRead(false, OK), | 4147 MockRead(false, OK), |
| 4134 }; | 4148 }; |
| 4135 | 4149 |
| 4136 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 4150 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 4137 data_writes1, arraysize(data_writes1)); | 4151 data_writes1, arraysize(data_writes1)); |
| 4138 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 4152 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 4139 data_writes2, arraysize(data_writes2)); | 4153 data_writes2, arraysize(data_writes2)); |
| 4140 session_deps.socket_factory.AddSocketDataProvider(&data1); | 4154 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 4141 session_deps.socket_factory.AddSocketDataProvider(&data2); | 4155 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 4142 | 4156 |
| 4143 TestOldCompletionCallback callback1; | 4157 TestCompletionCallback callback1; |
| 4144 | 4158 |
| 4145 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 4159 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 4146 EXPECT_EQ(ERR_IO_PENDING, rv); | 4160 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4147 | 4161 |
| 4148 rv = callback1.WaitForResult(); | 4162 rv = callback1.WaitForResult(); |
| 4149 EXPECT_EQ(OK, rv); | 4163 EXPECT_EQ(OK, rv); |
| 4150 | 4164 |
| 4151 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 4165 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 4152 TestOldCompletionCallback callback2; | 4166 TestCompletionCallback callback2; |
| 4153 rv = trans->RestartWithAuth(AuthCredentials(), &callback2); | 4167 rv = trans->RestartWithAuth(AuthCredentials(), callback2.callback()); |
| 4154 EXPECT_EQ(ERR_IO_PENDING, rv); | 4168 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4155 rv = callback2.WaitForResult(); | 4169 rv = callback2.WaitForResult(); |
| 4156 EXPECT_EQ(OK, rv); | 4170 EXPECT_EQ(OK, rv); |
| 4157 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 4171 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 4158 | 4172 |
| 4159 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4173 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4160 ASSERT_TRUE(response != NULL); | 4174 ASSERT_TRUE(response != NULL); |
| 4161 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4175 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 4162 EXPECT_EQ(100, response->headers->GetContentLength()); | 4176 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 4163 } | 4177 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4222 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 4236 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 4223 data_writes1, arraysize(data_writes1)); | 4237 data_writes1, arraysize(data_writes1)); |
| 4224 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 4238 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 4225 data_writes2, arraysize(data_writes2)); | 4239 data_writes2, arraysize(data_writes2)); |
| 4226 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), | 4240 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), |
| 4227 data_writes3, arraysize(data_writes3)); | 4241 data_writes3, arraysize(data_writes3)); |
| 4228 session_deps.socket_factory.AddSocketDataProvider(&data1); | 4242 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 4229 session_deps.socket_factory.AddSocketDataProvider(&data2); | 4243 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 4230 session_deps.socket_factory.AddSocketDataProvider(&data3); | 4244 session_deps.socket_factory.AddSocketDataProvider(&data3); |
| 4231 | 4245 |
| 4232 TestOldCompletionCallback callback1; | 4246 TestCompletionCallback callback1; |
| 4233 | 4247 |
| 4234 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 4248 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 4235 EXPECT_EQ(ERR_IO_PENDING, rv); | 4249 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4236 | 4250 |
| 4237 rv = callback1.WaitForResult(); | 4251 rv = callback1.WaitForResult(); |
| 4238 EXPECT_EQ(OK, rv); | 4252 EXPECT_EQ(OK, rv); |
| 4239 | 4253 |
| 4240 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 4254 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 4241 TestOldCompletionCallback callback2; | 4255 TestCompletionCallback callback2; |
| 4242 rv = trans->RestartWithAuth(AuthCredentials(), &callback2); | 4256 rv = trans->RestartWithAuth(AuthCredentials(), callback2.callback()); |
| 4243 EXPECT_EQ(ERR_IO_PENDING, rv); | 4257 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4244 rv = callback2.WaitForResult(); | 4258 rv = callback2.WaitForResult(); |
| 4245 EXPECT_EQ(OK, rv); | 4259 EXPECT_EQ(OK, rv); |
| 4246 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 4260 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 4247 | 4261 |
| 4248 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4262 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4249 ASSERT_TRUE(response != NULL); | 4263 ASSERT_TRUE(response != NULL); |
| 4250 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 4264 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 4251 | 4265 |
| 4252 TestOldCompletionCallback callback3; | 4266 TestCompletionCallback callback3; |
| 4253 | 4267 |
| 4254 rv = trans->RestartWithAuth(AuthCredentials(kFoo3, kBar3), &callback3); | 4268 rv = trans->RestartWithAuth( |
| 4269 AuthCredentials(kFoo3, kBar3), callback3.callback()); |
| 4255 EXPECT_EQ(ERR_IO_PENDING, rv); | 4270 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4256 | 4271 |
| 4257 rv = callback3.WaitForResult(); | 4272 rv = callback3.WaitForResult(); |
| 4258 EXPECT_EQ(OK, rv); | 4273 EXPECT_EQ(OK, rv); |
| 4259 | 4274 |
| 4260 response = trans->GetResponseInfo(); | 4275 response = trans->GetResponseInfo(); |
| 4261 ASSERT_TRUE(response != NULL); | 4276 ASSERT_TRUE(response != NULL); |
| 4262 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4277 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 4263 EXPECT_EQ(100, response->headers->GetContentLength()); | 4278 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 4264 } | 4279 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4315 MockRead(false, OK), | 4330 MockRead(false, OK), |
| 4316 }; | 4331 }; |
| 4317 | 4332 |
| 4318 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 4333 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 4319 data_writes1, arraysize(data_writes1)); | 4334 data_writes1, arraysize(data_writes1)); |
| 4320 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 4335 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 4321 data_writes2, arraysize(data_writes2)); | 4336 data_writes2, arraysize(data_writes2)); |
| 4322 session_deps.socket_factory.AddSocketDataProvider(&data1); | 4337 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 4323 session_deps.socket_factory.AddSocketDataProvider(&data2); | 4338 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 4324 | 4339 |
| 4325 TestOldCompletionCallback callback1; | 4340 TestCompletionCallback callback1; |
| 4326 | 4341 |
| 4327 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 4342 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 4328 EXPECT_EQ(ERR_IO_PENDING, rv); | 4343 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4329 | 4344 |
| 4330 rv = callback1.WaitForResult(); | 4345 rv = callback1.WaitForResult(); |
| 4331 EXPECT_EQ(OK, rv); | 4346 EXPECT_EQ(OK, rv); |
| 4332 | 4347 |
| 4333 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4348 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4334 ASSERT_TRUE(response != NULL); | 4349 ASSERT_TRUE(response != NULL); |
| 4335 EXPECT_TRUE(CheckDigestServerAuth(response->auth_challenge.get())); | 4350 EXPECT_TRUE(CheckDigestServerAuth(response->auth_challenge.get())); |
| 4336 | 4351 |
| 4337 TestOldCompletionCallback callback2; | 4352 TestCompletionCallback callback2; |
| 4338 | 4353 |
| 4339 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | 4354 rv = trans->RestartWithAuth( |
| 4355 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 4340 EXPECT_EQ(ERR_IO_PENDING, rv); | 4356 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4341 | 4357 |
| 4342 rv = callback2.WaitForResult(); | 4358 rv = callback2.WaitForResult(); |
| 4343 EXPECT_EQ(OK, rv); | 4359 EXPECT_EQ(OK, rv); |
| 4344 | 4360 |
| 4345 response = trans->GetResponseInfo(); | 4361 response = trans->GetResponseInfo(); |
| 4346 ASSERT_TRUE(response != NULL); | 4362 ASSERT_TRUE(response != NULL); |
| 4347 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4363 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 4348 } | 4364 } |
| 4349 | 4365 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 4376 MockRead data_reads1[] = { | 4392 MockRead data_reads1[] = { |
| 4377 MockRead("HTTP/1.0 200 OK\r\n"), | 4393 MockRead("HTTP/1.0 200 OK\r\n"), |
| 4378 MockRead("Content-Length: 100\r\n\r\n"), | 4394 MockRead("Content-Length: 100\r\n\r\n"), |
| 4379 MockRead(false, OK), | 4395 MockRead(false, OK), |
| 4380 }; | 4396 }; |
| 4381 | 4397 |
| 4382 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 4398 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 4383 data_writes1, arraysize(data_writes1)); | 4399 data_writes1, arraysize(data_writes1)); |
| 4384 session_deps.socket_factory.AddSocketDataProvider(&data1); | 4400 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 4385 | 4401 |
| 4386 TestOldCompletionCallback callback1; | 4402 TestCompletionCallback callback1; |
| 4387 | 4403 |
| 4388 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 4404 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 4389 EXPECT_EQ(ERR_IO_PENDING, rv); | 4405 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4390 | 4406 |
| 4391 rv = callback1.WaitForResult(); | 4407 rv = callback1.WaitForResult(); |
| 4392 EXPECT_EQ(OK, rv); | 4408 EXPECT_EQ(OK, rv); |
| 4393 | 4409 |
| 4394 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4410 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4395 ASSERT_TRUE(response != NULL); | 4411 ASSERT_TRUE(response != NULL); |
| 4396 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4412 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 4397 } | 4413 } |
| 4398 } | 4414 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4468 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 4484 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 4469 data_writes, arraysize(data_writes)); | 4485 data_writes, arraysize(data_writes)); |
| 4470 SSLSocketDataProvider ssl_bad(true, ERR_CERT_AUTHORITY_INVALID); | 4486 SSLSocketDataProvider ssl_bad(true, ERR_CERT_AUTHORITY_INVALID); |
| 4471 SSLSocketDataProvider ssl(true, OK); | 4487 SSLSocketDataProvider ssl(true, OK); |
| 4472 | 4488 |
| 4473 session_deps.socket_factory.AddSocketDataProvider(&ssl_bad_certificate); | 4489 session_deps.socket_factory.AddSocketDataProvider(&ssl_bad_certificate); |
| 4474 session_deps.socket_factory.AddSocketDataProvider(&data); | 4490 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 4475 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_bad); | 4491 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_bad); |
| 4476 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 4492 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 4477 | 4493 |
| 4478 TestOldCompletionCallback callback; | 4494 TestCompletionCallback callback; |
| 4479 | 4495 |
| 4480 int rv = trans->Start(&request, &callback, BoundNetLog()); | 4496 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4481 EXPECT_EQ(ERR_IO_PENDING, rv); | 4497 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4482 | 4498 |
| 4483 rv = callback.WaitForResult(); | 4499 rv = callback.WaitForResult(); |
| 4484 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); | 4500 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); |
| 4485 | 4501 |
| 4486 rv = trans->RestartIgnoringLastError(&callback); | 4502 rv = trans->RestartIgnoringLastError(callback.callback()); |
| 4487 EXPECT_EQ(ERR_IO_PENDING, rv); | 4503 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4488 | 4504 |
| 4489 rv = callback.WaitForResult(); | 4505 rv = callback.WaitForResult(); |
| 4490 EXPECT_EQ(OK, rv); | 4506 EXPECT_EQ(OK, rv); |
| 4491 | 4507 |
| 4492 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4508 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4493 | 4509 |
| 4494 ASSERT_TRUE(response != NULL); | 4510 ASSERT_TRUE(response != NULL); |
| 4495 EXPECT_EQ(100, response->headers->GetContentLength()); | 4511 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 4496 } | 4512 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4539 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 4555 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 4540 data_writes, arraysize(data_writes)); | 4556 data_writes, arraysize(data_writes)); |
| 4541 SSLSocketDataProvider ssl_bad(true, ERR_CERT_AUTHORITY_INVALID); | 4557 SSLSocketDataProvider ssl_bad(true, ERR_CERT_AUTHORITY_INVALID); |
| 4542 SSLSocketDataProvider ssl(true, OK); | 4558 SSLSocketDataProvider ssl(true, OK); |
| 4543 | 4559 |
| 4544 session_deps.socket_factory.AddSocketDataProvider(&ssl_bad_certificate); | 4560 session_deps.socket_factory.AddSocketDataProvider(&ssl_bad_certificate); |
| 4545 session_deps.socket_factory.AddSocketDataProvider(&data); | 4561 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 4546 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_bad); | 4562 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_bad); |
| 4547 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 4563 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 4548 | 4564 |
| 4549 TestOldCompletionCallback callback; | 4565 TestCompletionCallback callback; |
| 4550 | 4566 |
| 4551 for (int i = 0; i < 2; i++) { | 4567 for (int i = 0; i < 2; i++) { |
| 4552 session_deps.socket_factory.ResetNextMockIndexes(); | 4568 session_deps.socket_factory.ResetNextMockIndexes(); |
| 4553 | 4569 |
| 4554 scoped_ptr<HttpTransaction> trans( | 4570 scoped_ptr<HttpTransaction> trans( |
| 4555 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4571 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4556 | 4572 |
| 4557 int rv = trans->Start(&request, &callback, BoundNetLog()); | 4573 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4558 EXPECT_EQ(ERR_IO_PENDING, rv); | 4574 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4559 | 4575 |
| 4560 rv = callback.WaitForResult(); | 4576 rv = callback.WaitForResult(); |
| 4561 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); | 4577 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); |
| 4562 | 4578 |
| 4563 rv = trans->RestartIgnoringLastError(&callback); | 4579 rv = trans->RestartIgnoringLastError(callback.callback()); |
| 4564 EXPECT_EQ(ERR_IO_PENDING, rv); | 4580 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4565 | 4581 |
| 4566 rv = callback.WaitForResult(); | 4582 rv = callback.WaitForResult(); |
| 4567 EXPECT_EQ(OK, rv); | 4583 EXPECT_EQ(OK, rv); |
| 4568 | 4584 |
| 4569 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4585 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4570 | 4586 |
| 4571 ASSERT_TRUE(response != NULL); | 4587 ASSERT_TRUE(response != NULL); |
| 4572 EXPECT_EQ(100, response->headers->GetContentLength()); | 4588 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 4573 } | 4589 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 4603 | 4619 |
| 4604 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 4620 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 4605 data_writes, arraysize(data_writes)); | 4621 data_writes, arraysize(data_writes)); |
| 4606 SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy | 4622 SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy |
| 4607 SSLSocketDataProvider tunnel_ssl(true, OK); // SSL through the tunnel | 4623 SSLSocketDataProvider tunnel_ssl(true, OK); // SSL through the tunnel |
| 4608 | 4624 |
| 4609 session_deps.socket_factory.AddSocketDataProvider(&data); | 4625 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 4610 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); | 4626 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); |
| 4611 session_deps.socket_factory.AddSSLSocketDataProvider(&tunnel_ssl); | 4627 session_deps.socket_factory.AddSSLSocketDataProvider(&tunnel_ssl); |
| 4612 | 4628 |
| 4613 TestOldCompletionCallback callback; | 4629 TestCompletionCallback callback; |
| 4614 | 4630 |
| 4615 scoped_ptr<HttpTransaction> trans( | 4631 scoped_ptr<HttpTransaction> trans( |
| 4616 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4632 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4617 | 4633 |
| 4618 int rv = trans->Start(&request, &callback, BoundNetLog()); | 4634 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4619 EXPECT_EQ(ERR_IO_PENDING, rv); | 4635 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4620 | 4636 |
| 4621 rv = callback.WaitForResult(); | 4637 rv = callback.WaitForResult(); |
| 4622 EXPECT_EQ(OK, rv); | 4638 EXPECT_EQ(OK, rv); |
| 4623 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4639 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4624 | 4640 |
| 4625 ASSERT_TRUE(response != NULL); | 4641 ASSERT_TRUE(response != NULL); |
| 4626 | 4642 |
| 4627 EXPECT_TRUE(response->headers->IsKeepAlive()); | 4643 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 4628 EXPECT_EQ(200, response->headers->response_code()); | 4644 EXPECT_EQ(200, response->headers->response_code()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4653 MockRead(false, OK), | 4669 MockRead(false, OK), |
| 4654 }; | 4670 }; |
| 4655 | 4671 |
| 4656 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 4672 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 4657 data_writes, arraysize(data_writes)); | 4673 data_writes, arraysize(data_writes)); |
| 4658 SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy | 4674 SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy |
| 4659 | 4675 |
| 4660 session_deps.socket_factory.AddSocketDataProvider(&data); | 4676 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 4661 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); | 4677 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); |
| 4662 | 4678 |
| 4663 TestOldCompletionCallback callback; | 4679 TestCompletionCallback callback; |
| 4664 | 4680 |
| 4665 scoped_ptr<HttpTransaction> trans( | 4681 scoped_ptr<HttpTransaction> trans( |
| 4666 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4682 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4667 | 4683 |
| 4668 int rv = trans->Start(&request, &callback, BoundNetLog()); | 4684 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4669 EXPECT_EQ(ERR_IO_PENDING, rv); | 4685 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4670 | 4686 |
| 4671 rv = callback.WaitForResult(); | 4687 rv = callback.WaitForResult(); |
| 4672 EXPECT_EQ(OK, rv); | 4688 EXPECT_EQ(OK, rv); |
| 4673 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4689 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4674 | 4690 |
| 4675 ASSERT_TRUE(response != NULL); | 4691 ASSERT_TRUE(response != NULL); |
| 4676 | 4692 |
| 4677 EXPECT_EQ(302, response->headers->response_code()); | 4693 EXPECT_EQ(302, response->headers->response_code()); |
| 4678 std::string url; | 4694 std::string url; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4714 data_reads, arraysize(data_reads), | 4730 data_reads, arraysize(data_reads), |
| 4715 data_writes, arraysize(data_writes))); | 4731 data_writes, arraysize(data_writes))); |
| 4716 SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy | 4732 SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy |
| 4717 proxy_ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 4733 proxy_ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
| 4718 proxy_ssl.next_proto = "spdy/2"; | 4734 proxy_ssl.next_proto = "spdy/2"; |
| 4719 proxy_ssl.was_npn_negotiated = true; | 4735 proxy_ssl.was_npn_negotiated = true; |
| 4720 | 4736 |
| 4721 session_deps.socket_factory.AddSocketDataProvider(data.get()); | 4737 session_deps.socket_factory.AddSocketDataProvider(data.get()); |
| 4722 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); | 4738 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); |
| 4723 | 4739 |
| 4724 TestOldCompletionCallback callback; | 4740 TestCompletionCallback callback; |
| 4725 | 4741 |
| 4726 scoped_ptr<HttpTransaction> trans( | 4742 scoped_ptr<HttpTransaction> trans( |
| 4727 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4743 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4728 | 4744 |
| 4729 int rv = trans->Start(&request, &callback, BoundNetLog()); | 4745 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4730 EXPECT_EQ(ERR_IO_PENDING, rv); | 4746 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4731 | 4747 |
| 4732 rv = callback.WaitForResult(); | 4748 rv = callback.WaitForResult(); |
| 4733 EXPECT_EQ(OK, rv); | 4749 EXPECT_EQ(OK, rv); |
| 4734 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4750 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4735 | 4751 |
| 4736 ASSERT_TRUE(response != NULL); | 4752 ASSERT_TRUE(response != NULL); |
| 4737 | 4753 |
| 4738 EXPECT_EQ(302, response->headers->response_code()); | 4754 EXPECT_EQ(302, response->headers->response_code()); |
| 4739 std::string url; | 4755 std::string url; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4764 MockRead(false, OK), | 4780 MockRead(false, OK), |
| 4765 }; | 4781 }; |
| 4766 | 4782 |
| 4767 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 4783 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 4768 data_writes, arraysize(data_writes)); | 4784 data_writes, arraysize(data_writes)); |
| 4769 SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy | 4785 SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy |
| 4770 | 4786 |
| 4771 session_deps.socket_factory.AddSocketDataProvider(&data); | 4787 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 4772 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); | 4788 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); |
| 4773 | 4789 |
| 4774 TestOldCompletionCallback callback; | 4790 TestCompletionCallback callback; |
| 4775 | 4791 |
| 4776 scoped_ptr<HttpTransaction> trans( | 4792 scoped_ptr<HttpTransaction> trans( |
| 4777 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4793 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4778 | 4794 |
| 4779 int rv = trans->Start(&request, &callback, BoundNetLog()); | 4795 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4780 EXPECT_EQ(ERR_IO_PENDING, rv); | 4796 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4781 | 4797 |
| 4782 rv = callback.WaitForResult(); | 4798 rv = callback.WaitForResult(); |
| 4783 EXPECT_EQ(OK, rv); | 4799 EXPECT_EQ(OK, rv); |
| 4784 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4800 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4785 | 4801 |
| 4786 ASSERT_TRUE(response != NULL); | 4802 ASSERT_TRUE(response != NULL); |
| 4787 | 4803 |
| 4788 EXPECT_EQ(404, response->headers->response_code()); | 4804 EXPECT_EQ(404, response->headers->response_code()); |
| 4789 EXPECT_EQ(23, response->headers->GetContentLength()); | 4805 EXPECT_EQ(23, response->headers->GetContentLength()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4833 data_reads, arraysize(data_reads), | 4849 data_reads, arraysize(data_reads), |
| 4834 data_writes, arraysize(data_writes))); | 4850 data_writes, arraysize(data_writes))); |
| 4835 SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy | 4851 SSLSocketDataProvider proxy_ssl(true, OK); // SSL to the proxy |
| 4836 proxy_ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 4852 proxy_ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
| 4837 proxy_ssl.next_proto = "spdy/2"; | 4853 proxy_ssl.next_proto = "spdy/2"; |
| 4838 proxy_ssl.was_npn_negotiated = true; | 4854 proxy_ssl.was_npn_negotiated = true; |
| 4839 | 4855 |
| 4840 session_deps.socket_factory.AddSocketDataProvider(data.get()); | 4856 session_deps.socket_factory.AddSocketDataProvider(data.get()); |
| 4841 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); | 4857 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); |
| 4842 | 4858 |
| 4843 TestOldCompletionCallback callback; | 4859 TestCompletionCallback callback; |
| 4844 | 4860 |
| 4845 scoped_ptr<HttpTransaction> trans( | 4861 scoped_ptr<HttpTransaction> trans( |
| 4846 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4862 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4847 | 4863 |
| 4848 int rv = trans->Start(&request, &callback, BoundNetLog()); | 4864 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4849 EXPECT_EQ(ERR_IO_PENDING, rv); | 4865 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4850 | 4866 |
| 4851 rv = callback.WaitForResult(); | 4867 rv = callback.WaitForResult(); |
| 4852 EXPECT_EQ(OK, rv); | 4868 EXPECT_EQ(OK, rv); |
| 4853 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4869 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4854 | 4870 |
| 4855 ASSERT_TRUE(response != NULL); | 4871 ASSERT_TRUE(response != NULL); |
| 4856 | 4872 |
| 4857 EXPECT_EQ(404, response->headers->response_code()); | 4873 EXPECT_EQ(404, response->headers->response_code()); |
| 4858 EXPECT_FALSE(response->ssl_info.is_valid()); | 4874 EXPECT_FALSE(response->ssl_info.is_valid()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4914 // SSL to the proxy, then CONNECT request, then SSL with bad certificate | 4930 // SSL to the proxy, then CONNECT request, then SSL with bad certificate |
| 4915 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 4931 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 4916 session_deps.socket_factory.AddSocketDataProvider(&ssl_bad_certificate); | 4932 session_deps.socket_factory.AddSocketDataProvider(&ssl_bad_certificate); |
| 4917 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_bad); | 4933 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_bad); |
| 4918 | 4934 |
| 4919 // SSL to the proxy, then CONNECT request, then valid SSL certificate | 4935 // SSL to the proxy, then CONNECT request, then valid SSL certificate |
| 4920 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 4936 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 4921 session_deps.socket_factory.AddSocketDataProvider(&data); | 4937 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 4922 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 4938 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 4923 | 4939 |
| 4924 TestOldCompletionCallback callback; | 4940 TestCompletionCallback callback; |
| 4925 | 4941 |
| 4926 scoped_ptr<HttpTransaction> trans( | 4942 scoped_ptr<HttpTransaction> trans( |
| 4927 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4943 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4928 | 4944 |
| 4929 int rv = trans->Start(&request, &callback, BoundNetLog()); | 4945 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4930 EXPECT_EQ(ERR_IO_PENDING, rv); | 4946 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4931 | 4947 |
| 4932 rv = callback.WaitForResult(); | 4948 rv = callback.WaitForResult(); |
| 4933 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); | 4949 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); |
| 4934 | 4950 |
| 4935 rv = trans->RestartIgnoringLastError(&callback); | 4951 rv = trans->RestartIgnoringLastError(callback.callback()); |
| 4936 EXPECT_EQ(ERR_IO_PENDING, rv); | 4952 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4937 | 4953 |
| 4938 rv = callback.WaitForResult(); | 4954 rv = callback.WaitForResult(); |
| 4939 EXPECT_EQ(OK, rv); | 4955 EXPECT_EQ(OK, rv); |
| 4940 | 4956 |
| 4941 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4957 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4942 | 4958 |
| 4943 ASSERT_TRUE(response != NULL); | 4959 ASSERT_TRUE(response != NULL); |
| 4944 EXPECT_EQ(100, response->headers->GetContentLength()); | 4960 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 4945 } | 4961 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4967 MockRead("HTTP/1.0 200 OK\r\n"), | 4983 MockRead("HTTP/1.0 200 OK\r\n"), |
| 4968 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 4984 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 4969 MockRead("Content-Length: 100\r\n\r\n"), | 4985 MockRead("Content-Length: 100\r\n\r\n"), |
| 4970 MockRead(false, OK), | 4986 MockRead(false, OK), |
| 4971 }; | 4987 }; |
| 4972 | 4988 |
| 4973 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 4989 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 4974 data_writes, arraysize(data_writes)); | 4990 data_writes, arraysize(data_writes)); |
| 4975 session_deps.socket_factory.AddSocketDataProvider(&data); | 4991 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 4976 | 4992 |
| 4977 TestOldCompletionCallback callback; | 4993 TestCompletionCallback callback; |
| 4978 | 4994 |
| 4979 int rv = trans->Start(&request, &callback, BoundNetLog()); | 4995 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4980 EXPECT_EQ(ERR_IO_PENDING, rv); | 4996 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4981 | 4997 |
| 4982 rv = callback.WaitForResult(); | 4998 rv = callback.WaitForResult(); |
| 4983 EXPECT_EQ(OK, rv); | 4999 EXPECT_EQ(OK, rv); |
| 4984 } | 5000 } |
| 4985 | 5001 |
| 4986 TEST_F(HttpNetworkTransactionTest, BuildRequest_UserAgentOverTunnel) { | 5002 TEST_F(HttpNetworkTransactionTest, BuildRequest_UserAgentOverTunnel) { |
| 4987 HttpRequestInfo request; | 5003 HttpRequestInfo request; |
| 4988 request.method = "GET"; | 5004 request.method = "GET"; |
| 4989 request.url = GURL("https://www.google.com/"); | 5005 request.url = GURL("https://www.google.com/"); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5005 // interested in the rest). | 5021 // interested in the rest). |
| 5006 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), | 5022 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), |
| 5007 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 5023 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 5008 MockRead("Proxy-Connection: close\r\n\r\n"), | 5024 MockRead("Proxy-Connection: close\r\n\r\n"), |
| 5009 }; | 5025 }; |
| 5010 | 5026 |
| 5011 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5027 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5012 data_writes, arraysize(data_writes)); | 5028 data_writes, arraysize(data_writes)); |
| 5013 session_deps.socket_factory.AddSocketDataProvider(&data); | 5029 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5014 | 5030 |
| 5015 TestOldCompletionCallback callback; | 5031 TestCompletionCallback callback; |
| 5016 | 5032 |
| 5017 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5033 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5018 EXPECT_EQ(ERR_IO_PENDING, rv); | 5034 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5019 | 5035 |
| 5020 rv = callback.WaitForResult(); | 5036 rv = callback.WaitForResult(); |
| 5021 EXPECT_EQ(OK, rv); | 5037 EXPECT_EQ(OK, rv); |
| 5022 } | 5038 } |
| 5023 | 5039 |
| 5024 TEST_F(HttpNetworkTransactionTest, BuildRequest_Referer) { | 5040 TEST_F(HttpNetworkTransactionTest, BuildRequest_Referer) { |
| 5025 HttpRequestInfo request; | 5041 HttpRequestInfo request; |
| 5026 request.method = "GET"; | 5042 request.method = "GET"; |
| 5027 request.url = GURL("http://www.google.com/"); | 5043 request.url = GURL("http://www.google.com/"); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 5045 MockRead("HTTP/1.0 200 OK\r\n"), | 5061 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5046 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5062 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5047 MockRead("Content-Length: 100\r\n\r\n"), | 5063 MockRead("Content-Length: 100\r\n\r\n"), |
| 5048 MockRead(false, OK), | 5064 MockRead(false, OK), |
| 5049 }; | 5065 }; |
| 5050 | 5066 |
| 5051 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5067 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5052 data_writes, arraysize(data_writes)); | 5068 data_writes, arraysize(data_writes)); |
| 5053 session_deps.socket_factory.AddSocketDataProvider(&data); | 5069 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5054 | 5070 |
| 5055 TestOldCompletionCallback callback; | 5071 TestCompletionCallback callback; |
| 5056 | 5072 |
| 5057 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5073 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5058 EXPECT_EQ(ERR_IO_PENDING, rv); | 5074 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5059 | 5075 |
| 5060 rv = callback.WaitForResult(); | 5076 rv = callback.WaitForResult(); |
| 5061 EXPECT_EQ(OK, rv); | 5077 EXPECT_EQ(OK, rv); |
| 5062 } | 5078 } |
| 5063 | 5079 |
| 5064 TEST_F(HttpNetworkTransactionTest, BuildRequest_PostContentLengthZero) { | 5080 TEST_F(HttpNetworkTransactionTest, BuildRequest_PostContentLengthZero) { |
| 5065 HttpRequestInfo request; | 5081 HttpRequestInfo request; |
| 5066 request.method = "POST"; | 5082 request.method = "POST"; |
| 5067 request.url = GURL("http://www.google.com/"); | 5083 request.url = GURL("http://www.google.com/"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5082 MockRead("HTTP/1.0 200 OK\r\n"), | 5098 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5083 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5099 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5084 MockRead("Content-Length: 100\r\n\r\n"), | 5100 MockRead("Content-Length: 100\r\n\r\n"), |
| 5085 MockRead(false, OK), | 5101 MockRead(false, OK), |
| 5086 }; | 5102 }; |
| 5087 | 5103 |
| 5088 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5104 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5089 data_writes, arraysize(data_writes)); | 5105 data_writes, arraysize(data_writes)); |
| 5090 session_deps.socket_factory.AddSocketDataProvider(&data); | 5106 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5091 | 5107 |
| 5092 TestOldCompletionCallback callback; | 5108 TestCompletionCallback callback; |
| 5093 | 5109 |
| 5094 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5110 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5095 EXPECT_EQ(ERR_IO_PENDING, rv); | 5111 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5096 | 5112 |
| 5097 rv = callback.WaitForResult(); | 5113 rv = callback.WaitForResult(); |
| 5098 EXPECT_EQ(OK, rv); | 5114 EXPECT_EQ(OK, rv); |
| 5099 } | 5115 } |
| 5100 | 5116 |
| 5101 TEST_F(HttpNetworkTransactionTest, BuildRequest_PutContentLengthZero) { | 5117 TEST_F(HttpNetworkTransactionTest, BuildRequest_PutContentLengthZero) { |
| 5102 HttpRequestInfo request; | 5118 HttpRequestInfo request; |
| 5103 request.method = "PUT"; | 5119 request.method = "PUT"; |
| 5104 request.url = GURL("http://www.google.com/"); | 5120 request.url = GURL("http://www.google.com/"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5119 MockRead("HTTP/1.0 200 OK\r\n"), | 5135 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5120 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5136 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5121 MockRead("Content-Length: 100\r\n\r\n"), | 5137 MockRead("Content-Length: 100\r\n\r\n"), |
| 5122 MockRead(false, OK), | 5138 MockRead(false, OK), |
| 5123 }; | 5139 }; |
| 5124 | 5140 |
| 5125 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5141 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5126 data_writes, arraysize(data_writes)); | 5142 data_writes, arraysize(data_writes)); |
| 5127 session_deps.socket_factory.AddSocketDataProvider(&data); | 5143 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5128 | 5144 |
| 5129 TestOldCompletionCallback callback; | 5145 TestCompletionCallback callback; |
| 5130 | 5146 |
| 5131 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5147 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5132 EXPECT_EQ(ERR_IO_PENDING, rv); | 5148 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5133 | 5149 |
| 5134 rv = callback.WaitForResult(); | 5150 rv = callback.WaitForResult(); |
| 5135 EXPECT_EQ(OK, rv); | 5151 EXPECT_EQ(OK, rv); |
| 5136 } | 5152 } |
| 5137 | 5153 |
| 5138 TEST_F(HttpNetworkTransactionTest, BuildRequest_HeadContentLengthZero) { | 5154 TEST_F(HttpNetworkTransactionTest, BuildRequest_HeadContentLengthZero) { |
| 5139 HttpRequestInfo request; | 5155 HttpRequestInfo request; |
| 5140 request.method = "HEAD"; | 5156 request.method = "HEAD"; |
| 5141 request.url = GURL("http://www.google.com/"); | 5157 request.url = GURL("http://www.google.com/"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5156 MockRead("HTTP/1.0 200 OK\r\n"), | 5172 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5157 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5173 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5158 MockRead("Content-Length: 100\r\n\r\n"), | 5174 MockRead("Content-Length: 100\r\n\r\n"), |
| 5159 MockRead(false, OK), | 5175 MockRead(false, OK), |
| 5160 }; | 5176 }; |
| 5161 | 5177 |
| 5162 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5178 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5163 data_writes, arraysize(data_writes)); | 5179 data_writes, arraysize(data_writes)); |
| 5164 session_deps.socket_factory.AddSocketDataProvider(&data); | 5180 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5165 | 5181 |
| 5166 TestOldCompletionCallback callback; | 5182 TestCompletionCallback callback; |
| 5167 | 5183 |
| 5168 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5184 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5169 EXPECT_EQ(ERR_IO_PENDING, rv); | 5185 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5170 | 5186 |
| 5171 rv = callback.WaitForResult(); | 5187 rv = callback.WaitForResult(); |
| 5172 EXPECT_EQ(OK, rv); | 5188 EXPECT_EQ(OK, rv); |
| 5173 } | 5189 } |
| 5174 | 5190 |
| 5175 TEST_F(HttpNetworkTransactionTest, BuildRequest_CacheControlNoCache) { | 5191 TEST_F(HttpNetworkTransactionTest, BuildRequest_CacheControlNoCache) { |
| 5176 HttpRequestInfo request; | 5192 HttpRequestInfo request; |
| 5177 request.method = "GET"; | 5193 request.method = "GET"; |
| 5178 request.url = GURL("http://www.google.com/"); | 5194 request.url = GURL("http://www.google.com/"); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5195 MockRead("HTTP/1.0 200 OK\r\n"), | 5211 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5196 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5212 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5197 MockRead("Content-Length: 100\r\n\r\n"), | 5213 MockRead("Content-Length: 100\r\n\r\n"), |
| 5198 MockRead(false, OK), | 5214 MockRead(false, OK), |
| 5199 }; | 5215 }; |
| 5200 | 5216 |
| 5201 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5217 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5202 data_writes, arraysize(data_writes)); | 5218 data_writes, arraysize(data_writes)); |
| 5203 session_deps.socket_factory.AddSocketDataProvider(&data); | 5219 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5204 | 5220 |
| 5205 TestOldCompletionCallback callback; | 5221 TestCompletionCallback callback; |
| 5206 | 5222 |
| 5207 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5223 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5208 EXPECT_EQ(ERR_IO_PENDING, rv); | 5224 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5209 | 5225 |
| 5210 rv = callback.WaitForResult(); | 5226 rv = callback.WaitForResult(); |
| 5211 EXPECT_EQ(OK, rv); | 5227 EXPECT_EQ(OK, rv); |
| 5212 } | 5228 } |
| 5213 | 5229 |
| 5214 TEST_F(HttpNetworkTransactionTest, | 5230 TEST_F(HttpNetworkTransactionTest, |
| 5215 BuildRequest_CacheControlValidateCache) { | 5231 BuildRequest_CacheControlValidateCache) { |
| 5216 HttpRequestInfo request; | 5232 HttpRequestInfo request; |
| 5217 request.method = "GET"; | 5233 request.method = "GET"; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5234 MockRead("HTTP/1.0 200 OK\r\n"), | 5250 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5235 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5251 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5236 MockRead("Content-Length: 100\r\n\r\n"), | 5252 MockRead("Content-Length: 100\r\n\r\n"), |
| 5237 MockRead(false, OK), | 5253 MockRead(false, OK), |
| 5238 }; | 5254 }; |
| 5239 | 5255 |
| 5240 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5256 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5241 data_writes, arraysize(data_writes)); | 5257 data_writes, arraysize(data_writes)); |
| 5242 session_deps.socket_factory.AddSocketDataProvider(&data); | 5258 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5243 | 5259 |
| 5244 TestOldCompletionCallback callback; | 5260 TestCompletionCallback callback; |
| 5245 | 5261 |
| 5246 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5262 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5247 EXPECT_EQ(ERR_IO_PENDING, rv); | 5263 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5248 | 5264 |
| 5249 rv = callback.WaitForResult(); | 5265 rv = callback.WaitForResult(); |
| 5250 EXPECT_EQ(OK, rv); | 5266 EXPECT_EQ(OK, rv); |
| 5251 } | 5267 } |
| 5252 | 5268 |
| 5253 TEST_F(HttpNetworkTransactionTest, BuildRequest_ExtraHeaders) { | 5269 TEST_F(HttpNetworkTransactionTest, BuildRequest_ExtraHeaders) { |
| 5254 HttpRequestInfo request; | 5270 HttpRequestInfo request; |
| 5255 request.method = "GET"; | 5271 request.method = "GET"; |
| 5256 request.url = GURL("http://www.google.com/"); | 5272 request.url = GURL("http://www.google.com/"); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5272 MockRead("HTTP/1.0 200 OK\r\n"), | 5288 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5273 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5289 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5274 MockRead("Content-Length: 100\r\n\r\n"), | 5290 MockRead("Content-Length: 100\r\n\r\n"), |
| 5275 MockRead(false, OK), | 5291 MockRead(false, OK), |
| 5276 }; | 5292 }; |
| 5277 | 5293 |
| 5278 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5294 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5279 data_writes, arraysize(data_writes)); | 5295 data_writes, arraysize(data_writes)); |
| 5280 session_deps.socket_factory.AddSocketDataProvider(&data); | 5296 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5281 | 5297 |
| 5282 TestOldCompletionCallback callback; | 5298 TestCompletionCallback callback; |
| 5283 | 5299 |
| 5284 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5300 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5285 EXPECT_EQ(ERR_IO_PENDING, rv); | 5301 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5286 | 5302 |
| 5287 rv = callback.WaitForResult(); | 5303 rv = callback.WaitForResult(); |
| 5288 EXPECT_EQ(OK, rv); | 5304 EXPECT_EQ(OK, rv); |
| 5289 } | 5305 } |
| 5290 | 5306 |
| 5291 TEST_F(HttpNetworkTransactionTest, BuildRequest_ExtraHeadersStripped) { | 5307 TEST_F(HttpNetworkTransactionTest, BuildRequest_ExtraHeadersStripped) { |
| 5292 HttpRequestInfo request; | 5308 HttpRequestInfo request; |
| 5293 request.method = "GET"; | 5309 request.method = "GET"; |
| 5294 request.url = GURL("http://www.google.com/"); | 5310 request.url = GURL("http://www.google.com/"); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5314 MockRead("HTTP/1.0 200 OK\r\n"), | 5330 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5315 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5331 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5316 MockRead("Content-Length: 100\r\n\r\n"), | 5332 MockRead("Content-Length: 100\r\n\r\n"), |
| 5317 MockRead(false, OK), | 5333 MockRead(false, OK), |
| 5318 }; | 5334 }; |
| 5319 | 5335 |
| 5320 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5336 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5321 data_writes, arraysize(data_writes)); | 5337 data_writes, arraysize(data_writes)); |
| 5322 session_deps.socket_factory.AddSocketDataProvider(&data); | 5338 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5323 | 5339 |
| 5324 TestOldCompletionCallback callback; | 5340 TestCompletionCallback callback; |
| 5325 | 5341 |
| 5326 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5342 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5327 EXPECT_EQ(ERR_IO_PENDING, rv); | 5343 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5328 | 5344 |
| 5329 rv = callback.WaitForResult(); | 5345 rv = callback.WaitForResult(); |
| 5330 EXPECT_EQ(OK, rv); | 5346 EXPECT_EQ(OK, rv); |
| 5331 } | 5347 } |
| 5332 | 5348 |
| 5333 TEST_F(HttpNetworkTransactionTest, SOCKS4_HTTP_GET) { | 5349 TEST_F(HttpNetworkTransactionTest, SOCKS4_HTTP_GET) { |
| 5334 HttpRequestInfo request; | 5350 HttpRequestInfo request; |
| 5335 request.method = "GET"; | 5351 request.method = "GET"; |
| 5336 request.url = GURL("http://www.google.com/"); | 5352 request.url = GURL("http://www.google.com/"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 5357 MockRead("HTTP/1.0 200 OK\r\n"), | 5373 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5358 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), | 5374 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), |
| 5359 MockRead("Payload"), | 5375 MockRead("Payload"), |
| 5360 MockRead(false, OK) | 5376 MockRead(false, OK) |
| 5361 }; | 5377 }; |
| 5362 | 5378 |
| 5363 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5379 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5364 data_writes, arraysize(data_writes)); | 5380 data_writes, arraysize(data_writes)); |
| 5365 session_deps.socket_factory.AddSocketDataProvider(&data); | 5381 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5366 | 5382 |
| 5367 TestOldCompletionCallback callback; | 5383 TestCompletionCallback callback; |
| 5368 | 5384 |
| 5369 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5385 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5370 EXPECT_EQ(ERR_IO_PENDING, rv); | 5386 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5371 | 5387 |
| 5372 rv = callback.WaitForResult(); | 5388 rv = callback.WaitForResult(); |
| 5373 EXPECT_EQ(OK, rv); | 5389 EXPECT_EQ(OK, rv); |
| 5374 | 5390 |
| 5375 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5391 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5376 ASSERT_TRUE(response != NULL); | 5392 ASSERT_TRUE(response != NULL); |
| 5377 | 5393 |
| 5378 std::string response_text; | 5394 std::string response_text; |
| 5379 rv = ReadTransaction(trans.get(), &response_text); | 5395 rv = ReadTransaction(trans.get(), &response_text); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5413 MockRead(false, OK) | 5429 MockRead(false, OK) |
| 5414 }; | 5430 }; |
| 5415 | 5431 |
| 5416 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5432 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5417 data_writes, arraysize(data_writes)); | 5433 data_writes, arraysize(data_writes)); |
| 5418 session_deps.socket_factory.AddSocketDataProvider(&data); | 5434 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5419 | 5435 |
| 5420 SSLSocketDataProvider ssl(true, OK); | 5436 SSLSocketDataProvider ssl(true, OK); |
| 5421 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 5437 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 5422 | 5438 |
| 5423 TestOldCompletionCallback callback; | 5439 TestCompletionCallback callback; |
| 5424 | 5440 |
| 5425 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5441 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5426 EXPECT_EQ(ERR_IO_PENDING, rv); | 5442 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5427 | 5443 |
| 5428 rv = callback.WaitForResult(); | 5444 rv = callback.WaitForResult(); |
| 5429 EXPECT_EQ(OK, rv); | 5445 EXPECT_EQ(OK, rv); |
| 5430 | 5446 |
| 5431 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5447 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5432 ASSERT_TRUE(response != NULL); | 5448 ASSERT_TRUE(response != NULL); |
| 5433 | 5449 |
| 5434 std::string response_text; | 5450 std::string response_text; |
| 5435 rv = ReadTransaction(trans.get(), &response_text); | 5451 rv = ReadTransaction(trans.get(), &response_text); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5478 MockRead("HTTP/1.0 200 OK\r\n"), | 5494 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5479 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), | 5495 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), |
| 5480 MockRead("Payload"), | 5496 MockRead("Payload"), |
| 5481 MockRead(false, OK) | 5497 MockRead(false, OK) |
| 5482 }; | 5498 }; |
| 5483 | 5499 |
| 5484 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5500 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5485 data_writes, arraysize(data_writes)); | 5501 data_writes, arraysize(data_writes)); |
| 5486 session_deps.socket_factory.AddSocketDataProvider(&data); | 5502 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5487 | 5503 |
| 5488 TestOldCompletionCallback callback; | 5504 TestCompletionCallback callback; |
| 5489 | 5505 |
| 5490 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5506 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5491 EXPECT_EQ(ERR_IO_PENDING, rv); | 5507 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5492 | 5508 |
| 5493 rv = callback.WaitForResult(); | 5509 rv = callback.WaitForResult(); |
| 5494 EXPECT_EQ(OK, rv); | 5510 EXPECT_EQ(OK, rv); |
| 5495 | 5511 |
| 5496 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5512 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5497 ASSERT_TRUE(response != NULL); | 5513 ASSERT_TRUE(response != NULL); |
| 5498 | 5514 |
| 5499 std::string response_text; | 5515 std::string response_text; |
| 5500 rv = ReadTransaction(trans.get(), &response_text); | 5516 rv = ReadTransaction(trans.get(), &response_text); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5548 MockRead(false, OK) | 5564 MockRead(false, OK) |
| 5549 }; | 5565 }; |
| 5550 | 5566 |
| 5551 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5567 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5552 data_writes, arraysize(data_writes)); | 5568 data_writes, arraysize(data_writes)); |
| 5553 session_deps.socket_factory.AddSocketDataProvider(&data); | 5569 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5554 | 5570 |
| 5555 SSLSocketDataProvider ssl(true, OK); | 5571 SSLSocketDataProvider ssl(true, OK); |
| 5556 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 5572 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 5557 | 5573 |
| 5558 TestOldCompletionCallback callback; | 5574 TestCompletionCallback callback; |
| 5559 | 5575 |
| 5560 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5576 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5561 EXPECT_EQ(ERR_IO_PENDING, rv); | 5577 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5562 | 5578 |
| 5563 rv = callback.WaitForResult(); | 5579 rv = callback.WaitForResult(); |
| 5564 EXPECT_EQ(OK, rv); | 5580 EXPECT_EQ(OK, rv); |
| 5565 | 5581 |
| 5566 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5582 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5567 ASSERT_TRUE(response != NULL); | 5583 ASSERT_TRUE(response != NULL); |
| 5568 | 5584 |
| 5569 std::string response_text; | 5585 std::string response_text; |
| 5570 rv = ReadTransaction(trans.get(), &response_text); | 5586 rv = ReadTransaction(trans.get(), &response_text); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 5597 int GroupNameTransactionHelper( | 5613 int GroupNameTransactionHelper( |
| 5598 const std::string& url, | 5614 const std::string& url, |
| 5599 const scoped_refptr<HttpNetworkSession>& session) { | 5615 const scoped_refptr<HttpNetworkSession>& session) { |
| 5600 HttpRequestInfo request; | 5616 HttpRequestInfo request; |
| 5601 request.method = "GET"; | 5617 request.method = "GET"; |
| 5602 request.url = GURL(url); | 5618 request.url = GURL(url); |
| 5603 request.load_flags = 0; | 5619 request.load_flags = 0; |
| 5604 | 5620 |
| 5605 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 5621 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 5606 | 5622 |
| 5607 TestOldCompletionCallback callback; | 5623 TestCompletionCallback callback; |
| 5608 | 5624 |
| 5609 // We do not complete this request, the dtor will clean the transaction up. | 5625 // We do not complete this request, the dtor will clean the transaction up. |
| 5610 return trans->Start(&request, &callback, BoundNetLog()); | 5626 return trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5611 } | 5627 } |
| 5612 | 5628 |
| 5613 TEST_F(HttpNetworkTransactionTest, GroupNameForDirectConnections) { | 5629 TEST_F(HttpNetworkTransactionTest, GroupNameForDirectConnections) { |
| 5614 const GroupNameTest tests[] = { | 5630 const GroupNameTest tests[] = { |
| 5615 { | 5631 { |
| 5616 "", // unused | 5632 "", // unused |
| 5617 "http://www.google.com/direct", | 5633 "http://www.google.com/direct", |
| 5618 "www.google.com:80", | 5634 "www.google.com:80", |
| 5619 false, | 5635 false, |
| 5620 }, | 5636 }, |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5820 SessionDependencies session_deps( | 5836 SessionDependencies session_deps( |
| 5821 ProxyService::CreateFixed("myproxy:70;foobar:80")); | 5837 ProxyService::CreateFixed("myproxy:70;foobar:80")); |
| 5822 | 5838 |
| 5823 // This simulates failure resolving all hostnames; that means we will fail | 5839 // This simulates failure resolving all hostnames; that means we will fail |
| 5824 // connecting to both proxies (myproxy:70 and foobar:80). | 5840 // connecting to both proxies (myproxy:70 and foobar:80). |
| 5825 session_deps.host_resolver->rules()->AddSimulatedFailure("*"); | 5841 session_deps.host_resolver->rules()->AddSimulatedFailure("*"); |
| 5826 | 5842 |
| 5827 scoped_ptr<HttpTransaction> trans( | 5843 scoped_ptr<HttpTransaction> trans( |
| 5828 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5844 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5829 | 5845 |
| 5830 TestOldCompletionCallback callback; | 5846 TestCompletionCallback callback; |
| 5831 | 5847 |
| 5832 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5848 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5833 EXPECT_EQ(ERR_IO_PENDING, rv); | 5849 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5834 | 5850 |
| 5835 rv = callback.WaitForResult(); | 5851 rv = callback.WaitForResult(); |
| 5836 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, rv); | 5852 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, rv); |
| 5837 } | 5853 } |
| 5838 | 5854 |
| 5839 // Base test to make sure that when the load flags for a request specify to | 5855 // Base test to make sure that when the load flags for a request specify to |
| 5840 // bypass the cache, the DNS cache is not used. | 5856 // bypass the cache, the DNS cache is not used. |
| 5841 void BypassHostCacheOnRefreshHelper(int load_flags) { | 5857 void BypassHostCacheOnRefreshHelper(int load_flags) { |
| 5842 // Issue a request, asking to bypass the cache(s). | 5858 // Issue a request, asking to bypass the cache(s). |
| 5843 HttpRequestInfo request; | 5859 HttpRequestInfo request; |
| 5844 request.method = "GET"; | 5860 request.method = "GET"; |
| 5845 request.load_flags = load_flags; | 5861 request.load_flags = load_flags; |
| 5846 request.url = GURL("http://www.google.com/"); | 5862 request.url = GURL("http://www.google.com/"); |
| 5847 | 5863 |
| 5848 SessionDependencies session_deps; | 5864 SessionDependencies session_deps; |
| 5849 | 5865 |
| 5850 // Select a host resolver that does caching. | 5866 // Select a host resolver that does caching. |
| 5851 session_deps.host_resolver.reset(new MockCachingHostResolver); | 5867 session_deps.host_resolver.reset(new MockCachingHostResolver); |
| 5852 | 5868 |
| 5853 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( | 5869 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( |
| 5854 CreateSession(&session_deps))); | 5870 CreateSession(&session_deps))); |
| 5855 | 5871 |
| 5856 // Warm up the host cache so it has an entry for "www.google.com". | 5872 // Warm up the host cache so it has an entry for "www.google.com". |
| 5857 AddressList addrlist; | 5873 AddressList addrlist; |
| 5858 TestCompletionCallback callback; | 5874 TestCompletionCallback callback; |
| 5859 TestOldCompletionCallback old_callback; | |
| 5860 int rv = session_deps.host_resolver->Resolve( | 5875 int rv = session_deps.host_resolver->Resolve( |
| 5861 HostResolver::RequestInfo(HostPortPair("www.google.com", 80)), &addrlist, | 5876 HostResolver::RequestInfo(HostPortPair("www.google.com", 80)), &addrlist, |
| 5862 callback.callback(), NULL, BoundNetLog()); | 5877 callback.callback(), NULL, BoundNetLog()); |
| 5863 EXPECT_EQ(ERR_IO_PENDING, rv); | 5878 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5864 rv = callback.WaitForResult(); | 5879 rv = callback.WaitForResult(); |
| 5865 EXPECT_EQ(OK, rv); | 5880 EXPECT_EQ(OK, rv); |
| 5866 | 5881 |
| 5867 // Verify that it was added to host cache, by doing a subsequent async lookup | 5882 // Verify that it was added to host cache, by doing a subsequent async lookup |
| 5868 // and confirming it completes synchronously. | 5883 // and confirming it completes synchronously. |
| 5869 rv = session_deps.host_resolver->Resolve( | 5884 rv = session_deps.host_resolver->Resolve( |
| 5870 HostResolver::RequestInfo(HostPortPair("www.google.com", 80)), &addrlist, | 5885 HostResolver::RequestInfo(HostPortPair("www.google.com", 80)), &addrlist, |
| 5871 callback.callback(), NULL, BoundNetLog()); | 5886 callback.callback(), NULL, BoundNetLog()); |
| 5872 ASSERT_EQ(OK, rv); | 5887 ASSERT_EQ(OK, rv); |
| 5873 | 5888 |
| 5874 // Inject a failure the next time that "www.google.com" is resolved. This way | 5889 // Inject a failure the next time that "www.google.com" is resolved. This way |
| 5875 // we can tell if the next lookup hit the cache, or the "network". | 5890 // we can tell if the next lookup hit the cache, or the "network". |
| 5876 // (cache --> success, "network" --> failure). | 5891 // (cache --> success, "network" --> failure). |
| 5877 session_deps.host_resolver->rules()->AddSimulatedFailure("www.google.com"); | 5892 session_deps.host_resolver->rules()->AddSimulatedFailure("www.google.com"); |
| 5878 | 5893 |
| 5879 // Connect up a mock socket which will fail with ERR_UNEXPECTED during the | 5894 // Connect up a mock socket which will fail with ERR_UNEXPECTED during the |
| 5880 // first read -- this won't be reached as the host resolution will fail first. | 5895 // first read -- this won't be reached as the host resolution will fail first. |
| 5881 MockRead data_reads[] = { MockRead(false, ERR_UNEXPECTED) }; | 5896 MockRead data_reads[] = { MockRead(false, ERR_UNEXPECTED) }; |
| 5882 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 5897 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 5883 session_deps.socket_factory.AddSocketDataProvider(&data); | 5898 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5884 | 5899 |
| 5885 // Run the request. | 5900 // Run the request. |
| 5886 rv = trans->Start(&request, &old_callback, BoundNetLog()); | 5901 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5887 ASSERT_EQ(ERR_IO_PENDING, rv); | 5902 ASSERT_EQ(ERR_IO_PENDING, rv); |
| 5888 rv = old_callback.WaitForResult(); | 5903 rv = callback.WaitForResult(); |
| 5889 | 5904 |
| 5890 // If we bypassed the cache, we would have gotten a failure while resolving | 5905 // If we bypassed the cache, we would have gotten a failure while resolving |
| 5891 // "www.google.com". | 5906 // "www.google.com". |
| 5892 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv); | 5907 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv); |
| 5893 } | 5908 } |
| 5894 | 5909 |
| 5895 // There are multiple load flags that should trigger the host cache bypass. | 5910 // There are multiple load flags that should trigger the host cache bypass. |
| 5896 // Test each in isolation: | 5911 // Test each in isolation: |
| 5897 TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh1) { | 5912 TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh1) { |
| 5898 BypassHostCacheOnRefreshHelper(LOAD_BYPASS_CACHE); | 5913 BypassHostCacheOnRefreshHelper(LOAD_BYPASS_CACHE); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 5916 request.url = GURL("http://www.foo.com/"); | 5931 request.url = GURL("http://www.foo.com/"); |
| 5917 request.load_flags = 0; | 5932 request.load_flags = 0; |
| 5918 | 5933 |
| 5919 MockWrite write_failure[] = { | 5934 MockWrite write_failure[] = { |
| 5920 MockWrite(true, ERR_CONNECTION_RESET), | 5935 MockWrite(true, ERR_CONNECTION_RESET), |
| 5921 }; | 5936 }; |
| 5922 StaticSocketDataProvider data(NULL, 0, | 5937 StaticSocketDataProvider data(NULL, 0, |
| 5923 write_failure, arraysize(write_failure)); | 5938 write_failure, arraysize(write_failure)); |
| 5924 session_deps.socket_factory.AddSocketDataProvider(&data); | 5939 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5925 | 5940 |
| 5926 TestOldCompletionCallback callback; | 5941 TestCompletionCallback callback; |
| 5927 | 5942 |
| 5928 scoped_ptr<HttpTransaction> trans( | 5943 scoped_ptr<HttpTransaction> trans( |
| 5929 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5944 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5930 | 5945 |
| 5931 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5946 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5932 EXPECT_EQ(ERR_IO_PENDING, rv); | 5947 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5933 | 5948 |
| 5934 rv = callback.WaitForResult(); | 5949 rv = callback.WaitForResult(); |
| 5935 EXPECT_EQ(ERR_CONNECTION_RESET, rv); | 5950 EXPECT_EQ(ERR_CONNECTION_RESET, rv); |
| 5936 } | 5951 } |
| 5937 | 5952 |
| 5938 // Check that a connection closed after the start of the headers finishes ok. | 5953 // Check that a connection closed after the start of the headers finishes ok. |
| 5939 TEST_F(HttpNetworkTransactionTest, ConnectionClosedAfterStartOfHeaders) { | 5954 TEST_F(HttpNetworkTransactionTest, ConnectionClosedAfterStartOfHeaders) { |
| 5940 SessionDependencies session_deps; | 5955 SessionDependencies session_deps; |
| 5941 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 5956 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 5942 | 5957 |
| 5943 HttpRequestInfo request; | 5958 HttpRequestInfo request; |
| 5944 request.method = "GET"; | 5959 request.method = "GET"; |
| 5945 request.url = GURL("http://www.foo.com/"); | 5960 request.url = GURL("http://www.foo.com/"); |
| 5946 request.load_flags = 0; | 5961 request.load_flags = 0; |
| 5947 | 5962 |
| 5948 MockRead data_reads[] = { | 5963 MockRead data_reads[] = { |
| 5949 MockRead("HTTP/1."), | 5964 MockRead("HTTP/1."), |
| 5950 MockRead(false, OK), | 5965 MockRead(false, OK), |
| 5951 }; | 5966 }; |
| 5952 | 5967 |
| 5953 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 5968 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 5954 session_deps.socket_factory.AddSocketDataProvider(&data); | 5969 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 5955 | 5970 |
| 5956 TestOldCompletionCallback callback; | 5971 TestCompletionCallback callback; |
| 5957 | 5972 |
| 5958 scoped_ptr<HttpTransaction> trans( | 5973 scoped_ptr<HttpTransaction> trans( |
| 5959 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5974 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5960 | 5975 |
| 5961 int rv = trans->Start(&request, &callback, BoundNetLog()); | 5976 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5962 EXPECT_EQ(ERR_IO_PENDING, rv); | 5977 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5963 | 5978 |
| 5964 rv = callback.WaitForResult(); | 5979 rv = callback.WaitForResult(); |
| 5965 EXPECT_EQ(OK, rv); | 5980 EXPECT_EQ(OK, rv); |
| 5966 | 5981 |
| 5967 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5982 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5968 ASSERT_TRUE(response != NULL); | 5983 ASSERT_TRUE(response != NULL); |
| 5969 | 5984 |
| 5970 EXPECT_TRUE(response->headers != NULL); | 5985 EXPECT_TRUE(response->headers != NULL); |
| 5971 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 5986 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6020 MockRead("HTTP/1.1 200 OK\r\n"), | 6035 MockRead("HTTP/1.1 200 OK\r\n"), |
| 6021 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 6036 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 6022 MockRead("Content-Length: 100\r\n\r\n"), | 6037 MockRead("Content-Length: 100\r\n\r\n"), |
| 6023 MockRead(false, OK), | 6038 MockRead(false, OK), |
| 6024 }; | 6039 }; |
| 6025 | 6040 |
| 6026 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 6041 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 6027 data_writes2, arraysize(data_writes2)); | 6042 data_writes2, arraysize(data_writes2)); |
| 6028 session_deps.socket_factory.AddSocketDataProvider(&data2); | 6043 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 6029 | 6044 |
| 6030 TestOldCompletionCallback callback1; | 6045 TestCompletionCallback callback1; |
| 6031 | 6046 |
| 6032 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 6047 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 6033 | 6048 |
| 6034 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 6049 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 6035 EXPECT_EQ(ERR_IO_PENDING, rv); | 6050 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6036 | 6051 |
| 6037 rv = callback1.WaitForResult(); | 6052 rv = callback1.WaitForResult(); |
| 6038 EXPECT_EQ(OK, rv); | 6053 EXPECT_EQ(OK, rv); |
| 6039 | 6054 |
| 6040 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6055 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6041 ASSERT_TRUE(response != NULL); | 6056 ASSERT_TRUE(response != NULL); |
| 6042 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 6057 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 6043 | 6058 |
| 6044 TestOldCompletionCallback callback2; | 6059 TestCompletionCallback callback2; |
| 6045 | 6060 |
| 6046 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | 6061 rv = trans->RestartWithAuth( |
| 6062 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 6047 EXPECT_EQ(ERR_IO_PENDING, rv); | 6063 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6048 | 6064 |
| 6049 rv = callback2.WaitForResult(); | 6065 rv = callback2.WaitForResult(); |
| 6050 EXPECT_EQ(OK, rv); | 6066 EXPECT_EQ(OK, rv); |
| 6051 | 6067 |
| 6052 response = trans->GetResponseInfo(); | 6068 response = trans->GetResponseInfo(); |
| 6053 ASSERT_TRUE(response != NULL); | 6069 ASSERT_TRUE(response != NULL); |
| 6054 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6070 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 6055 EXPECT_EQ(100, response->headers->GetContentLength()); | 6071 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 6056 } | 6072 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 6068 MockRead("HTTP/1.0 200 Connected\r\n\r\nExtra data"), | 6084 MockRead("HTTP/1.0 200 Connected\r\n\r\nExtra data"), |
| 6069 MockRead(false, OK) | 6085 MockRead(false, OK) |
| 6070 }; | 6086 }; |
| 6071 | 6087 |
| 6072 StaticSocketDataProvider data(proxy_reads, arraysize(proxy_reads), NULL, 0); | 6088 StaticSocketDataProvider data(proxy_reads, arraysize(proxy_reads), NULL, 0); |
| 6073 SSLSocketDataProvider ssl(true, OK); | 6089 SSLSocketDataProvider ssl(true, OK); |
| 6074 | 6090 |
| 6075 session_deps.socket_factory.AddSocketDataProvider(&data); | 6091 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 6076 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 6092 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 6077 | 6093 |
| 6078 TestOldCompletionCallback callback; | 6094 TestCompletionCallback callback; |
| 6079 | 6095 |
| 6080 session_deps.socket_factory.ResetNextMockIndexes(); | 6096 session_deps.socket_factory.ResetNextMockIndexes(); |
| 6081 | 6097 |
| 6082 scoped_ptr<HttpTransaction> trans( | 6098 scoped_ptr<HttpTransaction> trans( |
| 6083 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6099 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 6084 | 6100 |
| 6085 int rv = trans->Start(&request, &callback, BoundNetLog()); | 6101 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6086 EXPECT_EQ(ERR_IO_PENDING, rv); | 6102 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6087 | 6103 |
| 6088 rv = callback.WaitForResult(); | 6104 rv = callback.WaitForResult(); |
| 6089 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); | 6105 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); |
| 6090 } | 6106 } |
| 6091 | 6107 |
| 6092 TEST_F(HttpNetworkTransactionTest, LargeContentLengthThenClose) { | 6108 TEST_F(HttpNetworkTransactionTest, LargeContentLengthThenClose) { |
| 6093 HttpRequestInfo request; | 6109 HttpRequestInfo request; |
| 6094 request.method = "GET"; | 6110 request.method = "GET"; |
| 6095 request.url = GURL("http://www.google.com/"); | 6111 request.url = GURL("http://www.google.com/"); |
| 6096 request.load_flags = 0; | 6112 request.load_flags = 0; |
| 6097 | 6113 |
| 6098 SessionDependencies session_deps; | 6114 SessionDependencies session_deps; |
| 6099 scoped_ptr<HttpTransaction> trans( | 6115 scoped_ptr<HttpTransaction> trans( |
| 6100 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6116 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 6101 | 6117 |
| 6102 MockRead data_reads[] = { | 6118 MockRead data_reads[] = { |
| 6103 MockRead("HTTP/1.0 200 OK\r\nContent-Length:6719476739\r\n\r\n"), | 6119 MockRead("HTTP/1.0 200 OK\r\nContent-Length:6719476739\r\n\r\n"), |
| 6104 MockRead(false, OK), | 6120 MockRead(false, OK), |
| 6105 }; | 6121 }; |
| 6106 | 6122 |
| 6107 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 6123 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 6108 session_deps.socket_factory.AddSocketDataProvider(&data); | 6124 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 6109 | 6125 |
| 6110 TestOldCompletionCallback callback; | 6126 TestCompletionCallback callback; |
| 6111 | 6127 |
| 6112 int rv = trans->Start(&request, &callback, BoundNetLog()); | 6128 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6113 EXPECT_EQ(ERR_IO_PENDING, rv); | 6129 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6114 | 6130 |
| 6115 EXPECT_EQ(OK, callback.WaitForResult()); | 6131 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6116 | 6132 |
| 6117 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6133 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6118 ASSERT_TRUE(response != NULL); | 6134 ASSERT_TRUE(response != NULL); |
| 6119 | 6135 |
| 6120 EXPECT_TRUE(response->headers != NULL); | 6136 EXPECT_TRUE(response->headers != NULL); |
| 6121 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 6137 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
| 6122 | 6138 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 6149 EXPECT_EQ(kFakeSize, request.upload_data->GetContentLength()); | 6165 EXPECT_EQ(kFakeSize, request.upload_data->GetContentLength()); |
| 6150 | 6166 |
| 6151 MockRead data_reads[] = { | 6167 MockRead data_reads[] = { |
| 6152 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | 6168 MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
| 6153 MockRead("hello world"), | 6169 MockRead("hello world"), |
| 6154 MockRead(false, OK), | 6170 MockRead(false, OK), |
| 6155 }; | 6171 }; |
| 6156 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 6172 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 6157 session_deps.socket_factory.AddSocketDataProvider(&data); | 6173 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 6158 | 6174 |
| 6159 TestOldCompletionCallback callback; | 6175 TestCompletionCallback callback; |
| 6160 | 6176 |
| 6161 int rv = trans->Start(&request, &callback, BoundNetLog()); | 6177 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6162 EXPECT_EQ(ERR_IO_PENDING, rv); | 6178 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6163 | 6179 |
| 6164 rv = callback.WaitForResult(); | 6180 rv = callback.WaitForResult(); |
| 6165 EXPECT_EQ(OK, rv); | 6181 EXPECT_EQ(OK, rv); |
| 6166 | 6182 |
| 6167 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6183 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6168 ASSERT_TRUE(response != NULL); | 6184 ASSERT_TRUE(response != NULL); |
| 6169 | 6185 |
| 6170 EXPECT_TRUE(response->headers != NULL); | 6186 EXPECT_TRUE(response->headers != NULL); |
| 6171 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 6187 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6212 MockWrite("POST /upload HTTP/1.1\r\n" | 6228 MockWrite("POST /upload HTTP/1.1\r\n" |
| 6213 "Host: www.google.com\r\n" | 6229 "Host: www.google.com\r\n" |
| 6214 "Connection: keep-alive\r\n" | 6230 "Connection: keep-alive\r\n" |
| 6215 "Content-Length: 0\r\n\r\n"), | 6231 "Content-Length: 0\r\n\r\n"), |
| 6216 MockWrite(false, OK), | 6232 MockWrite(false, OK), |
| 6217 }; | 6233 }; |
| 6218 StaticSocketDataProvider data(data_reads, arraysize(data_reads), data_writes, | 6234 StaticSocketDataProvider data(data_reads, arraysize(data_reads), data_writes, |
| 6219 arraysize(data_writes)); | 6235 arraysize(data_writes)); |
| 6220 session_deps.socket_factory.AddSocketDataProvider(&data); | 6236 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 6221 | 6237 |
| 6222 TestOldCompletionCallback callback; | 6238 TestCompletionCallback callback; |
| 6223 | 6239 |
| 6224 int rv = trans->Start(&request, &callback, BoundNetLog()); | 6240 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6225 EXPECT_EQ(ERR_IO_PENDING, rv); | 6241 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6226 | 6242 |
| 6227 rv = callback.WaitForResult(); | 6243 rv = callback.WaitForResult(); |
| 6228 EXPECT_EQ(OK, rv); | 6244 EXPECT_EQ(OK, rv); |
| 6229 | 6245 |
| 6230 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6246 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6231 ASSERT_TRUE(response != NULL); | 6247 ASSERT_TRUE(response != NULL); |
| 6232 EXPECT_TRUE(response->headers != NULL); | 6248 EXPECT_TRUE(response->headers != NULL); |
| 6233 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 6249 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
| 6234 | 6250 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6280 "Connection: keep-alive\r\n" | 6296 "Connection: keep-alive\r\n" |
| 6281 "Content-Length: 16\r\n" | 6297 "Content-Length: 16\r\n" |
| 6282 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), | 6298 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), |
| 6283 MockWrite(false, unreadable_contents.c_str(), temp_file_contents.length()), | 6299 MockWrite(false, unreadable_contents.c_str(), temp_file_contents.length()), |
| 6284 MockWrite(false, OK), | 6300 MockWrite(false, OK), |
| 6285 }; | 6301 }; |
| 6286 StaticSocketDataProvider data(data_reads, arraysize(data_reads), data_writes, | 6302 StaticSocketDataProvider data(data_reads, arraysize(data_reads), data_writes, |
| 6287 arraysize(data_writes)); | 6303 arraysize(data_writes)); |
| 6288 session_deps.socket_factory.AddSocketDataProvider(&data); | 6304 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 6289 | 6305 |
| 6290 TestOldCompletionCallback callback1; | 6306 TestCompletionCallback callback1; |
| 6291 | 6307 |
| 6292 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 6308 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 6293 EXPECT_EQ(ERR_IO_PENDING, rv); | 6309 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6294 | 6310 |
| 6295 rv = callback1.WaitForResult(); | 6311 rv = callback1.WaitForResult(); |
| 6296 EXPECT_EQ(OK, rv); | 6312 EXPECT_EQ(OK, rv); |
| 6297 | 6313 |
| 6298 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6314 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6299 ASSERT_TRUE(response != NULL); | 6315 ASSERT_TRUE(response != NULL); |
| 6300 ASSERT_TRUE(response->headers != NULL); | 6316 ASSERT_TRUE(response->headers != NULL); |
| 6301 EXPECT_EQ("HTTP/1.1 401 Unauthorized", response->headers->GetStatusLine()); | 6317 EXPECT_EQ("HTTP/1.1 401 Unauthorized", response->headers->GetStatusLine()); |
| 6302 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 6318 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
| 6303 | 6319 |
| 6304 // Now make the file unreadable and try again. | 6320 // Now make the file unreadable and try again. |
| 6305 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); | 6321 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); |
| 6306 | 6322 |
| 6307 TestOldCompletionCallback callback2; | 6323 TestCompletionCallback callback2; |
| 6308 | 6324 |
| 6309 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); | 6325 rv = trans->RestartWithAuth( |
| 6326 AuthCredentials(kFoo, kBar), callback2.callback()); |
| 6310 EXPECT_EQ(ERR_IO_PENDING, rv); | 6327 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6311 | 6328 |
| 6312 rv = callback2.WaitForResult(); | 6329 rv = callback2.WaitForResult(); |
| 6313 EXPECT_EQ(OK, rv); | 6330 EXPECT_EQ(OK, rv); |
| 6314 | 6331 |
| 6315 response = trans->GetResponseInfo(); | 6332 response = trans->GetResponseInfo(); |
| 6316 ASSERT_TRUE(response != NULL); | 6333 ASSERT_TRUE(response != NULL); |
| 6317 EXPECT_TRUE(response->headers != NULL); | 6334 EXPECT_TRUE(response->headers != NULL); |
| 6318 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6335 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 6319 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6336 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6397 data_writes2, arraysize(data_writes2)); | 6414 data_writes2, arraysize(data_writes2)); |
| 6398 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), | 6415 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), |
| 6399 data_writes3, arraysize(data_writes3)); | 6416 data_writes3, arraysize(data_writes3)); |
| 6400 StaticSocketDataProvider data4(data_reads4, arraysize(data_reads4), | 6417 StaticSocketDataProvider data4(data_reads4, arraysize(data_reads4), |
| 6401 data_writes4, arraysize(data_writes4)); | 6418 data_writes4, arraysize(data_writes4)); |
| 6402 session_deps.socket_factory.AddSocketDataProvider(&data1); | 6419 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 6403 session_deps.socket_factory.AddSocketDataProvider(&data2); | 6420 session_deps.socket_factory.AddSocketDataProvider(&data2); |
| 6404 session_deps.socket_factory.AddSocketDataProvider(&data3); | 6421 session_deps.socket_factory.AddSocketDataProvider(&data3); |
| 6405 session_deps.socket_factory.AddSocketDataProvider(&data4); | 6422 session_deps.socket_factory.AddSocketDataProvider(&data4); |
| 6406 | 6423 |
| 6407 TestOldCompletionCallback callback1; | 6424 TestCompletionCallback callback1; |
| 6408 | 6425 |
| 6409 scoped_ptr<HttpTransaction> trans( | 6426 scoped_ptr<HttpTransaction> trans( |
| 6410 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6427 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 6411 | 6428 |
| 6412 // Issue the first request with Authorize headers. There should be a | 6429 // Issue the first request with Authorize headers. There should be a |
| 6413 // password prompt for first_realm waiting to be filled in after the | 6430 // password prompt for first_realm waiting to be filled in after the |
| 6414 // transaction completes. | 6431 // transaction completes. |
| 6415 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 6432 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 6416 EXPECT_EQ(ERR_IO_PENDING, rv); | 6433 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6417 rv = callback1.WaitForResult(); | 6434 rv = callback1.WaitForResult(); |
| 6418 EXPECT_EQ(OK, rv); | 6435 EXPECT_EQ(OK, rv); |
| 6419 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6436 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6420 ASSERT_TRUE(response != NULL); | 6437 ASSERT_TRUE(response != NULL); |
| 6421 const AuthChallengeInfo* challenge = response->auth_challenge.get(); | 6438 const AuthChallengeInfo* challenge = response->auth_challenge.get(); |
| 6422 ASSERT_FALSE(challenge == NULL); | 6439 ASSERT_FALSE(challenge == NULL); |
| 6423 EXPECT_FALSE(challenge->is_proxy); | 6440 EXPECT_FALSE(challenge->is_proxy); |
| 6424 EXPECT_EQ("www.google.com:80", challenge->challenger.ToString()); | 6441 EXPECT_EQ("www.google.com:80", challenge->challenger.ToString()); |
| 6425 EXPECT_EQ("first_realm", challenge->realm); | 6442 EXPECT_EQ("first_realm", challenge->realm); |
| 6426 EXPECT_EQ("basic", challenge->scheme); | 6443 EXPECT_EQ("basic", challenge->scheme); |
| 6427 | 6444 |
| 6428 // Issue the second request with an incorrect password. There should be a | 6445 // Issue the second request with an incorrect password. There should be a |
| 6429 // password prompt for second_realm waiting to be filled in after the | 6446 // password prompt for second_realm waiting to be filled in after the |
| 6430 // transaction completes. | 6447 // transaction completes. |
| 6431 TestOldCompletionCallback callback2; | 6448 TestCompletionCallback callback2; |
| 6432 rv = trans->RestartWithAuth(AuthCredentials(kFirst, kBaz), &callback2); | 6449 rv = trans->RestartWithAuth( |
| 6450 AuthCredentials(kFirst, kBaz), callback2.callback()); |
| 6433 EXPECT_EQ(ERR_IO_PENDING, rv); | 6451 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6434 rv = callback2.WaitForResult(); | 6452 rv = callback2.WaitForResult(); |
| 6435 EXPECT_EQ(OK, rv); | 6453 EXPECT_EQ(OK, rv); |
| 6436 response = trans->GetResponseInfo(); | 6454 response = trans->GetResponseInfo(); |
| 6437 ASSERT_TRUE(response != NULL); | 6455 ASSERT_TRUE(response != NULL); |
| 6438 challenge = response->auth_challenge.get(); | 6456 challenge = response->auth_challenge.get(); |
| 6439 ASSERT_FALSE(challenge == NULL); | 6457 ASSERT_FALSE(challenge == NULL); |
| 6440 EXPECT_FALSE(challenge->is_proxy); | 6458 EXPECT_FALSE(challenge->is_proxy); |
| 6441 EXPECT_EQ("www.google.com:80", challenge->challenger.ToString()); | 6459 EXPECT_EQ("www.google.com:80", challenge->challenger.ToString()); |
| 6442 EXPECT_EQ("second_realm", challenge->realm); | 6460 EXPECT_EQ("second_realm", challenge->realm); |
| 6443 EXPECT_EQ("basic", challenge->scheme); | 6461 EXPECT_EQ("basic", challenge->scheme); |
| 6444 | 6462 |
| 6445 // Issue the third request with another incorrect password. There should be | 6463 // Issue the third request with another incorrect password. There should be |
| 6446 // a password prompt for first_realm waiting to be filled in. If the password | 6464 // a password prompt for first_realm waiting to be filled in. If the password |
| 6447 // prompt is not present, it indicates that the HttpAuthCacheEntry for | 6465 // prompt is not present, it indicates that the HttpAuthCacheEntry for |
| 6448 // first_realm was not correctly removed. | 6466 // first_realm was not correctly removed. |
| 6449 TestOldCompletionCallback callback3; | 6467 TestCompletionCallback callback3; |
| 6450 rv = trans->RestartWithAuth(AuthCredentials(kSecond, kFou), &callback3); | 6468 rv = trans->RestartWithAuth( |
| 6469 AuthCredentials(kSecond, kFou), callback3.callback()); |
| 6451 EXPECT_EQ(ERR_IO_PENDING, rv); | 6470 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6452 rv = callback3.WaitForResult(); | 6471 rv = callback3.WaitForResult(); |
| 6453 EXPECT_EQ(OK, rv); | 6472 EXPECT_EQ(OK, rv); |
| 6454 response = trans->GetResponseInfo(); | 6473 response = trans->GetResponseInfo(); |
| 6455 ASSERT_TRUE(response != NULL); | 6474 ASSERT_TRUE(response != NULL); |
| 6456 challenge = response->auth_challenge.get(); | 6475 challenge = response->auth_challenge.get(); |
| 6457 ASSERT_FALSE(challenge == NULL); | 6476 ASSERT_FALSE(challenge == NULL); |
| 6458 EXPECT_FALSE(challenge->is_proxy); | 6477 EXPECT_FALSE(challenge->is_proxy); |
| 6459 EXPECT_EQ("www.google.com:80", challenge->challenger.ToString()); | 6478 EXPECT_EQ("www.google.com:80", challenge->challenger.ToString()); |
| 6460 EXPECT_EQ("first_realm", challenge->realm); | 6479 EXPECT_EQ("first_realm", challenge->realm); |
| 6461 EXPECT_EQ("basic", challenge->scheme); | 6480 EXPECT_EQ("basic", challenge->scheme); |
| 6462 | 6481 |
| 6463 // Issue the fourth request with the correct password and username. | 6482 // Issue the fourth request with the correct password and username. |
| 6464 TestOldCompletionCallback callback4; | 6483 TestCompletionCallback callback4; |
| 6465 rv = trans->RestartWithAuth(AuthCredentials(kFirst, kBar), &callback4); | 6484 rv = trans->RestartWithAuth( |
| 6485 AuthCredentials(kFirst, kBar), callback4.callback()); |
| 6466 EXPECT_EQ(ERR_IO_PENDING, rv); | 6486 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6467 rv = callback4.WaitForResult(); | 6487 rv = callback4.WaitForResult(); |
| 6468 EXPECT_EQ(OK, rv); | 6488 EXPECT_EQ(OK, rv); |
| 6469 response = trans->GetResponseInfo(); | 6489 response = trans->GetResponseInfo(); |
| 6470 ASSERT_TRUE(response != NULL); | 6490 ASSERT_TRUE(response != NULL); |
| 6471 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6491 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 6472 } | 6492 } |
| 6473 | 6493 |
| 6474 TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) { | 6494 TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) { |
| 6475 HttpStreamFactory::set_next_protos(MakeNextProtos("foo", "bar", NULL)); | 6495 HttpStreamFactory::set_next_protos(MakeNextProtos("foo", "bar", NULL)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6486 | 6506 |
| 6487 HttpRequestInfo request; | 6507 HttpRequestInfo request; |
| 6488 request.method = "GET"; | 6508 request.method = "GET"; |
| 6489 request.url = GURL("http://www.google.com/"); | 6509 request.url = GURL("http://www.google.com/"); |
| 6490 request.load_flags = 0; | 6510 request.load_flags = 0; |
| 6491 | 6511 |
| 6492 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 6512 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 6493 | 6513 |
| 6494 session_deps.socket_factory.AddSocketDataProvider(&data); | 6514 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 6495 | 6515 |
| 6496 TestOldCompletionCallback callback; | 6516 TestCompletionCallback callback; |
| 6497 | 6517 |
| 6498 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 6518 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 6499 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 6519 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 6500 | 6520 |
| 6501 int rv = trans->Start(&request, &callback, BoundNetLog()); | 6521 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6502 EXPECT_EQ(ERR_IO_PENDING, rv); | 6522 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6503 | 6523 |
| 6504 HostPortPair http_host_port_pair("www.google.com", 80); | 6524 HostPortPair http_host_port_pair("www.google.com", 80); |
| 6505 const HttpServerProperties& http_server_properties = | 6525 const HttpServerProperties& http_server_properties = |
| 6506 *session->http_server_properties(); | 6526 *session->http_server_properties(); |
| 6507 EXPECT_FALSE( | 6527 EXPECT_FALSE( |
| 6508 http_server_properties.HasAlternateProtocol(http_host_port_pair)); | 6528 http_server_properties.HasAlternateProtocol(http_host_port_pair)); |
| 6509 | 6529 |
| 6510 EXPECT_EQ(OK, callback.WaitForResult()); | 6530 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6511 | 6531 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6560 HttpServerProperties* http_server_properties = | 6580 HttpServerProperties* http_server_properties = |
| 6561 session->http_server_properties(); | 6581 session->http_server_properties(); |
| 6562 // Port must be < 1024, or the header will be ignored (since initial port was | 6582 // Port must be < 1024, or the header will be ignored (since initial port was |
| 6563 // port 80 (another restricted port). | 6583 // port 80 (another restricted port). |
| 6564 http_server_properties->SetAlternateProtocol( | 6584 http_server_properties->SetAlternateProtocol( |
| 6565 HostPortPair::FromURL(request.url), | 6585 HostPortPair::FromURL(request.url), |
| 6566 666 /* port is ignored by MockConnect anyway */, | 6586 666 /* port is ignored by MockConnect anyway */, |
| 6567 NPN_SPDY_2); | 6587 NPN_SPDY_2); |
| 6568 | 6588 |
| 6569 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 6589 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 6570 TestOldCompletionCallback callback; | 6590 TestCompletionCallback callback; |
| 6571 | 6591 |
| 6572 int rv = trans->Start(&request, &callback, BoundNetLog()); | 6592 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6573 EXPECT_EQ(ERR_IO_PENDING, rv); | 6593 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6574 EXPECT_EQ(OK, callback.WaitForResult()); | 6594 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6575 | 6595 |
| 6576 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6596 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6577 ASSERT_TRUE(response != NULL); | 6597 ASSERT_TRUE(response != NULL); |
| 6578 ASSERT_TRUE(response->headers != NULL); | 6598 ASSERT_TRUE(response->headers != NULL); |
| 6579 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6599 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 6580 | 6600 |
| 6581 std::string response_data; | 6601 std::string response_data; |
| 6582 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 6602 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6622 | 6642 |
| 6623 HttpServerProperties* http_server_properties = | 6643 HttpServerProperties* http_server_properties = |
| 6624 session->http_server_properties(); | 6644 session->http_server_properties(); |
| 6625 const int kUnrestrictedAlternatePort = 1024; | 6645 const int kUnrestrictedAlternatePort = 1024; |
| 6626 http_server_properties->SetAlternateProtocol( | 6646 http_server_properties->SetAlternateProtocol( |
| 6627 HostPortPair::FromURL(restricted_port_request.url), | 6647 HostPortPair::FromURL(restricted_port_request.url), |
| 6628 kUnrestrictedAlternatePort, | 6648 kUnrestrictedAlternatePort, |
| 6629 NPN_SPDY_2); | 6649 NPN_SPDY_2); |
| 6630 | 6650 |
| 6631 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 6651 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 6632 TestOldCompletionCallback callback; | 6652 TestCompletionCallback callback; |
| 6633 | 6653 |
| 6634 int rv = trans->Start(&restricted_port_request, &callback, BoundNetLog()); | 6654 int rv = trans->Start( |
| 6655 &restricted_port_request, callback.callback(), BoundNetLog()); |
| 6635 EXPECT_EQ(ERR_IO_PENDING, rv); | 6656 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6636 // Invalid change to unrestricted port should fail. | 6657 // Invalid change to unrestricted port should fail. |
| 6637 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); | 6658 EXPECT_EQ(ERR_CONNECTION_REFUSED, callback.WaitForResult()); |
| 6638 | 6659 |
| 6639 HttpStreamFactory::set_use_alternate_protocols(false); | 6660 HttpStreamFactory::set_use_alternate_protocols(false); |
| 6640 } | 6661 } |
| 6641 | 6662 |
| 6642 TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortRestrictedAllowed) { | 6663 TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortRestrictedAllowed) { |
| 6643 // Ensure that we're not allowed to redirect traffic via an alternate | 6664 // Ensure that we're not allowed to redirect traffic via an alternate |
| 6644 // protocol to an unrestricted (port >= 1024) when the original traffic was | 6665 // protocol to an unrestricted (port >= 1024) when the original traffic was |
| (...skipping 25 matching lines...) Expand all Loading... |
| 6670 | 6691 |
| 6671 HttpServerProperties* http_server_properties = | 6692 HttpServerProperties* http_server_properties = |
| 6672 session->http_server_properties(); | 6693 session->http_server_properties(); |
| 6673 const int kRestrictedAlternatePort = 80; | 6694 const int kRestrictedAlternatePort = 80; |
| 6674 http_server_properties->SetAlternateProtocol( | 6695 http_server_properties->SetAlternateProtocol( |
| 6675 HostPortPair::FromURL(restricted_port_request.url), | 6696 HostPortPair::FromURL(restricted_port_request.url), |
| 6676 kRestrictedAlternatePort, | 6697 kRestrictedAlternatePort, |
| 6677 NPN_SPDY_2); | 6698 NPN_SPDY_2); |
| 6678 | 6699 |
| 6679 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 6700 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 6680 TestOldCompletionCallback callback; | 6701 TestCompletionCallback callback; |
| 6681 | 6702 |
| 6682 int rv = trans->Start(&restricted_port_request, &callback, BoundNetLog()); | 6703 int rv = trans->Start( |
| 6704 &restricted_port_request, callback.callback(), BoundNetLog()); |
| 6683 EXPECT_EQ(ERR_IO_PENDING, rv); | 6705 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6684 // Valid change to restricted port should pass. | 6706 // Valid change to restricted port should pass. |
| 6685 EXPECT_EQ(OK, callback.WaitForResult()); | 6707 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6686 | 6708 |
| 6687 HttpStreamFactory::set_use_alternate_protocols(false); | 6709 HttpStreamFactory::set_use_alternate_protocols(false); |
| 6688 } | 6710 } |
| 6689 | 6711 |
| 6690 TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortUnrestrictedAllowed1) { | 6712 TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortUnrestrictedAllowed1) { |
| 6691 // Ensure that we're not allowed to redirect traffic via an alternate | 6713 // Ensure that we're not allowed to redirect traffic via an alternate |
| 6692 // protocol to an unrestricted (port >= 1024) when the original traffic was | 6714 // protocol to an unrestricted (port >= 1024) when the original traffic was |
| (...skipping 25 matching lines...) Expand all Loading... |
| 6718 | 6740 |
| 6719 HttpServerProperties* http_server_properties = | 6741 HttpServerProperties* http_server_properties = |
| 6720 session->http_server_properties(); | 6742 session->http_server_properties(); |
| 6721 const int kRestrictedAlternatePort = 80; | 6743 const int kRestrictedAlternatePort = 80; |
| 6722 http_server_properties->SetAlternateProtocol( | 6744 http_server_properties->SetAlternateProtocol( |
| 6723 HostPortPair::FromURL(unrestricted_port_request.url), | 6745 HostPortPair::FromURL(unrestricted_port_request.url), |
| 6724 kRestrictedAlternatePort, | 6746 kRestrictedAlternatePort, |
| 6725 NPN_SPDY_2); | 6747 NPN_SPDY_2); |
| 6726 | 6748 |
| 6727 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 6749 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 6728 TestOldCompletionCallback callback; | 6750 TestCompletionCallback callback; |
| 6729 | 6751 |
| 6730 int rv = trans->Start(&unrestricted_port_request, &callback, BoundNetLog()); | 6752 int rv = trans->Start( |
| 6753 &unrestricted_port_request, callback.callback(), BoundNetLog()); |
| 6731 EXPECT_EQ(ERR_IO_PENDING, rv); | 6754 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6732 // Valid change to restricted port should pass. | 6755 // Valid change to restricted port should pass. |
| 6733 EXPECT_EQ(OK, callback.WaitForResult()); | 6756 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6734 | 6757 |
| 6735 HttpStreamFactory::set_use_alternate_protocols(false); | 6758 HttpStreamFactory::set_use_alternate_protocols(false); |
| 6736 } | 6759 } |
| 6737 | 6760 |
| 6738 TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortUnrestrictedAllowed2) { | 6761 TEST_F(HttpNetworkTransactionTest, AlternateProtocolPortUnrestrictedAllowed2) { |
| 6739 // Ensure that we're not allowed to redirect traffic via an alternate | 6762 // Ensure that we're not allowed to redirect traffic via an alternate |
| 6740 // protocol to an unrestricted (port >= 1024) when the original traffic was | 6763 // protocol to an unrestricted (port >= 1024) when the original traffic was |
| (...skipping 25 matching lines...) Expand all Loading... |
| 6766 | 6789 |
| 6767 HttpServerProperties* http_server_properties = | 6790 HttpServerProperties* http_server_properties = |
| 6768 session->http_server_properties(); | 6791 session->http_server_properties(); |
| 6769 const int kUnrestrictedAlternatePort = 1024; | 6792 const int kUnrestrictedAlternatePort = 1024; |
| 6770 http_server_properties->SetAlternateProtocol( | 6793 http_server_properties->SetAlternateProtocol( |
| 6771 HostPortPair::FromURL(unrestricted_port_request.url), | 6794 HostPortPair::FromURL(unrestricted_port_request.url), |
| 6772 kUnrestrictedAlternatePort, | 6795 kUnrestrictedAlternatePort, |
| 6773 NPN_SPDY_2); | 6796 NPN_SPDY_2); |
| 6774 | 6797 |
| 6775 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 6798 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 6776 TestOldCompletionCallback callback; | 6799 TestCompletionCallback callback; |
| 6777 | 6800 |
| 6778 int rv = trans->Start(&unrestricted_port_request, &callback, BoundNetLog()); | 6801 int rv = trans->Start( |
| 6802 &unrestricted_port_request, callback.callback(), BoundNetLog()); |
| 6779 EXPECT_EQ(ERR_IO_PENDING, rv); | 6803 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6780 // Valid change to an unrestricted port should pass. | 6804 // Valid change to an unrestricted port should pass. |
| 6781 EXPECT_EQ(OK, callback.WaitForResult()); | 6805 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6782 | 6806 |
| 6783 HttpStreamFactory::set_use_alternate_protocols(false); | 6807 HttpStreamFactory::set_use_alternate_protocols(false); |
| 6784 } | 6808 } |
| 6785 | 6809 |
| 6786 TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { | 6810 TEST_F(HttpNetworkTransactionTest, UseAlternateProtocolForNpnSpdy) { |
| 6787 HttpStreamFactory::set_use_alternate_protocols(true); | 6811 HttpStreamFactory::set_use_alternate_protocols(true); |
| 6788 HttpStreamFactory::set_next_protos(SpdyNextProtos()); | 6812 HttpStreamFactory::set_next_protos(SpdyNextProtos()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6829 session_deps.socket_factory.AddSocketDataProvider(spdy_data); | 6853 session_deps.socket_factory.AddSocketDataProvider(spdy_data); |
| 6830 | 6854 |
| 6831 MockConnect never_finishing_connect(false, ERR_IO_PENDING); | 6855 MockConnect never_finishing_connect(false, ERR_IO_PENDING); |
| 6832 StaticSocketDataProvider hanging_non_alternate_protocol_socket( | 6856 StaticSocketDataProvider hanging_non_alternate_protocol_socket( |
| 6833 NULL, 0, NULL, 0); | 6857 NULL, 0, NULL, 0); |
| 6834 hanging_non_alternate_protocol_socket.set_connect_data( | 6858 hanging_non_alternate_protocol_socket.set_connect_data( |
| 6835 never_finishing_connect); | 6859 never_finishing_connect); |
| 6836 session_deps.socket_factory.AddSocketDataProvider( | 6860 session_deps.socket_factory.AddSocketDataProvider( |
| 6837 &hanging_non_alternate_protocol_socket); | 6861 &hanging_non_alternate_protocol_socket); |
| 6838 | 6862 |
| 6839 TestOldCompletionCallback callback; | 6863 TestCompletionCallback callback; |
| 6840 | 6864 |
| 6841 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 6865 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 6842 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 6866 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 6843 | 6867 |
| 6844 int rv = trans->Start(&request, &callback, BoundNetLog()); | 6868 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6845 EXPECT_EQ(ERR_IO_PENDING, rv); | 6869 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6846 EXPECT_EQ(OK, callback.WaitForResult()); | 6870 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6847 | 6871 |
| 6848 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6872 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6849 ASSERT_TRUE(response != NULL); | 6873 ASSERT_TRUE(response != NULL); |
| 6850 ASSERT_TRUE(response->headers != NULL); | 6874 ASSERT_TRUE(response->headers != NULL); |
| 6851 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6875 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 6852 | 6876 |
| 6853 std::string response_data; | 6877 std::string response_data; |
| 6854 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 6878 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 6855 EXPECT_EQ("hello world", response_data); | 6879 EXPECT_EQ("hello world", response_data); |
| 6856 | 6880 |
| 6857 trans.reset(new HttpNetworkTransaction(session)); | 6881 trans.reset(new HttpNetworkTransaction(session)); |
| 6858 | 6882 |
| 6859 rv = trans->Start(&request, &callback, BoundNetLog()); | 6883 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6860 EXPECT_EQ(ERR_IO_PENDING, rv); | 6884 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6861 EXPECT_EQ(OK, callback.WaitForResult()); | 6885 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6862 | 6886 |
| 6863 response = trans->GetResponseInfo(); | 6887 response = trans->GetResponseInfo(); |
| 6864 ASSERT_TRUE(response != NULL); | 6888 ASSERT_TRUE(response != NULL); |
| 6865 ASSERT_TRUE(response->headers != NULL); | 6889 ASSERT_TRUE(response->headers != NULL); |
| 6866 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6890 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 6867 EXPECT_TRUE(response->was_fetched_via_spdy); | 6891 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 6868 EXPECT_TRUE(response->was_npn_negotiated); | 6892 EXPECT_TRUE(response->was_npn_negotiated); |
| 6869 | 6893 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6934 2, // wait for writes to finish before reading. | 6958 2, // wait for writes to finish before reading. |
| 6935 spdy_reads, arraysize(spdy_reads), | 6959 spdy_reads, arraysize(spdy_reads), |
| 6936 spdy_writes, arraysize(spdy_writes))); | 6960 spdy_writes, arraysize(spdy_writes))); |
| 6937 // Socket 4 is the successful Alternate-Protocol for transaction 3. | 6961 // Socket 4 is the successful Alternate-Protocol for transaction 3. |
| 6938 session_deps.socket_factory.AddSocketDataProvider(spdy_data); | 6962 session_deps.socket_factory.AddSocketDataProvider(spdy_data); |
| 6939 | 6963 |
| 6940 // Socket 5 is the unsuccessful non-Alternate-Protocol for transaction 3. | 6964 // Socket 5 is the unsuccessful non-Alternate-Protocol for transaction 3. |
| 6941 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); | 6965 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); |
| 6942 | 6966 |
| 6943 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 6967 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 6944 TestOldCompletionCallback callback1; | 6968 TestCompletionCallback callback1; |
| 6945 HttpNetworkTransaction trans1(session); | 6969 HttpNetworkTransaction trans1(session); |
| 6946 | 6970 |
| 6947 int rv = trans1.Start(&request, &callback1, BoundNetLog()); | 6971 int rv = trans1.Start(&request, callback1.callback(), BoundNetLog()); |
| 6948 EXPECT_EQ(ERR_IO_PENDING, rv); | 6972 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6949 EXPECT_EQ(OK, callback1.WaitForResult()); | 6973 EXPECT_EQ(OK, callback1.WaitForResult()); |
| 6950 | 6974 |
| 6951 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 6975 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
| 6952 ASSERT_TRUE(response != NULL); | 6976 ASSERT_TRUE(response != NULL); |
| 6953 ASSERT_TRUE(response->headers != NULL); | 6977 ASSERT_TRUE(response->headers != NULL); |
| 6954 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6978 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 6955 | 6979 |
| 6956 std::string response_data; | 6980 std::string response_data; |
| 6957 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 6981 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
| 6958 EXPECT_EQ("hello world", response_data); | 6982 EXPECT_EQ("hello world", response_data); |
| 6959 | 6983 |
| 6960 TestOldCompletionCallback callback2; | 6984 TestCompletionCallback callback2; |
| 6961 HttpNetworkTransaction trans2(session); | 6985 HttpNetworkTransaction trans2(session); |
| 6962 rv = trans2.Start(&request, &callback2, BoundNetLog()); | 6986 rv = trans2.Start(&request, callback2.callback(), BoundNetLog()); |
| 6963 EXPECT_EQ(ERR_IO_PENDING, rv); | 6987 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6964 | 6988 |
| 6965 TestOldCompletionCallback callback3; | 6989 TestCompletionCallback callback3; |
| 6966 HttpNetworkTransaction trans3(session); | 6990 HttpNetworkTransaction trans3(session); |
| 6967 rv = trans3.Start(&request, &callback3, BoundNetLog()); | 6991 rv = trans3.Start(&request, callback3.callback(), BoundNetLog()); |
| 6968 EXPECT_EQ(ERR_IO_PENDING, rv); | 6992 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6969 | 6993 |
| 6970 EXPECT_EQ(OK, callback2.WaitForResult()); | 6994 EXPECT_EQ(OK, callback2.WaitForResult()); |
| 6971 EXPECT_EQ(OK, callback3.WaitForResult()); | 6995 EXPECT_EQ(OK, callback3.WaitForResult()); |
| 6972 | 6996 |
| 6973 response = trans2.GetResponseInfo(); | 6997 response = trans2.GetResponseInfo(); |
| 6974 ASSERT_TRUE(response != NULL); | 6998 ASSERT_TRUE(response != NULL); |
| 6975 ASSERT_TRUE(response->headers != NULL); | 6999 ASSERT_TRUE(response->headers != NULL); |
| 6976 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7000 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 6977 EXPECT_TRUE(response->was_fetched_via_spdy); | 7001 EXPECT_TRUE(response->was_fetched_via_spdy); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7023 StaticSocketDataProvider hanging_alternate_protocol_socket( | 7047 StaticSocketDataProvider hanging_alternate_protocol_socket( |
| 7024 NULL, 0, NULL, 0); | 7048 NULL, 0, NULL, 0); |
| 7025 hanging_alternate_protocol_socket.set_connect_data( | 7049 hanging_alternate_protocol_socket.set_connect_data( |
| 7026 never_finishing_connect); | 7050 never_finishing_connect); |
| 7027 session_deps.socket_factory.AddSocketDataProvider( | 7051 session_deps.socket_factory.AddSocketDataProvider( |
| 7028 &hanging_alternate_protocol_socket); | 7052 &hanging_alternate_protocol_socket); |
| 7029 | 7053 |
| 7030 // 2nd request is just a copy of the first one, over HTTP again. | 7054 // 2nd request is just a copy of the first one, over HTTP again. |
| 7031 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7055 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); |
| 7032 | 7056 |
| 7033 TestOldCompletionCallback callback; | 7057 TestCompletionCallback callback; |
| 7034 | 7058 |
| 7035 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7059 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 7036 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 7060 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 7037 | 7061 |
| 7038 int rv = trans->Start(&request, &callback, BoundNetLog()); | 7062 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 7039 EXPECT_EQ(ERR_IO_PENDING, rv); | 7063 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7040 EXPECT_EQ(OK, callback.WaitForResult()); | 7064 EXPECT_EQ(OK, callback.WaitForResult()); |
| 7041 | 7065 |
| 7042 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7066 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7043 ASSERT_TRUE(response != NULL); | 7067 ASSERT_TRUE(response != NULL); |
| 7044 ASSERT_TRUE(response->headers != NULL); | 7068 ASSERT_TRUE(response->headers != NULL); |
| 7045 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7069 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 7046 | 7070 |
| 7047 std::string response_data; | 7071 std::string response_data; |
| 7048 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 7072 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 7049 EXPECT_EQ("hello world", response_data); | 7073 EXPECT_EQ("hello world", response_data); |
| 7050 | 7074 |
| 7051 trans.reset(new HttpNetworkTransaction(session)); | 7075 trans.reset(new HttpNetworkTransaction(session)); |
| 7052 | 7076 |
| 7053 rv = trans->Start(&request, &callback, BoundNetLog()); | 7077 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 7054 EXPECT_EQ(ERR_IO_PENDING, rv); | 7078 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7055 EXPECT_EQ(OK, callback.WaitForResult()); | 7079 EXPECT_EQ(OK, callback.WaitForResult()); |
| 7056 | 7080 |
| 7057 response = trans->GetResponseInfo(); | 7081 response = trans->GetResponseInfo(); |
| 7058 ASSERT_TRUE(response != NULL); | 7082 ASSERT_TRUE(response != NULL); |
| 7059 ASSERT_TRUE(response->headers != NULL); | 7083 ASSERT_TRUE(response->headers != NULL); |
| 7060 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7084 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 7061 EXPECT_FALSE(response->was_fetched_via_spdy); | 7085 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 7062 EXPECT_FALSE(response->was_npn_negotiated); | 7086 EXPECT_FALSE(response->was_npn_negotiated); |
| 7063 | 7087 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7179 session_deps.socket_factory.AddSocketDataProvider(spdy_data); | 7203 session_deps.socket_factory.AddSocketDataProvider(spdy_data); |
| 7180 | 7204 |
| 7181 MockConnect never_finishing_connect(false, ERR_IO_PENDING); | 7205 MockConnect never_finishing_connect(false, ERR_IO_PENDING); |
| 7182 StaticSocketDataProvider hanging_non_alternate_protocol_socket( | 7206 StaticSocketDataProvider hanging_non_alternate_protocol_socket( |
| 7183 NULL, 0, NULL, 0); | 7207 NULL, 0, NULL, 0); |
| 7184 hanging_non_alternate_protocol_socket.set_connect_data( | 7208 hanging_non_alternate_protocol_socket.set_connect_data( |
| 7185 never_finishing_connect); | 7209 never_finishing_connect); |
| 7186 session_deps.socket_factory.AddSocketDataProvider( | 7210 session_deps.socket_factory.AddSocketDataProvider( |
| 7187 &hanging_non_alternate_protocol_socket); | 7211 &hanging_non_alternate_protocol_socket); |
| 7188 | 7212 |
| 7189 TestOldCompletionCallback callback; | 7213 TestCompletionCallback callback; |
| 7190 | 7214 |
| 7191 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7215 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 7192 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 7216 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 7193 | 7217 |
| 7194 int rv = trans->Start(&request, &callback, BoundNetLog()); | 7218 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 7195 EXPECT_EQ(ERR_IO_PENDING, rv); | 7219 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7196 EXPECT_EQ(OK, callback.WaitForResult()); | 7220 EXPECT_EQ(OK, callback.WaitForResult()); |
| 7197 | 7221 |
| 7198 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7222 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7199 ASSERT_TRUE(response != NULL); | 7223 ASSERT_TRUE(response != NULL); |
| 7200 ASSERT_TRUE(response->headers != NULL); | 7224 ASSERT_TRUE(response->headers != NULL); |
| 7201 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7225 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 7202 EXPECT_FALSE(response->was_fetched_via_spdy); | 7226 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 7203 EXPECT_FALSE(response->was_npn_negotiated); | 7227 EXPECT_FALSE(response->was_npn_negotiated); |
| 7204 | 7228 |
| 7205 std::string response_data; | 7229 std::string response_data; |
| 7206 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 7230 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 7207 EXPECT_EQ("hello world", response_data); | 7231 EXPECT_EQ("hello world", response_data); |
| 7208 | 7232 |
| 7209 trans.reset(new HttpNetworkTransaction(session)); | 7233 trans.reset(new HttpNetworkTransaction(session)); |
| 7210 | 7234 |
| 7211 rv = trans->Start(&request, &callback, BoundNetLog()); | 7235 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 7212 EXPECT_EQ(ERR_IO_PENDING, rv); | 7236 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7213 EXPECT_EQ(OK, callback.WaitForResult()); | 7237 EXPECT_EQ(OK, callback.WaitForResult()); |
| 7214 | 7238 |
| 7215 response = trans->GetResponseInfo(); | 7239 response = trans->GetResponseInfo(); |
| 7216 ASSERT_TRUE(response != NULL); | 7240 ASSERT_TRUE(response != NULL); |
| 7217 ASSERT_TRUE(response->headers != NULL); | 7241 ASSERT_TRUE(response->headers != NULL); |
| 7218 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7242 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 7219 EXPECT_TRUE(response->was_fetched_via_spdy); | 7243 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 7220 EXPECT_TRUE(response->was_npn_negotiated); | 7244 EXPECT_TRUE(response->was_npn_negotiated); |
| 7221 | 7245 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7272 MockRead(true, 0, 0), | 7296 MockRead(true, 0, 0), |
| 7273 }; | 7297 }; |
| 7274 | 7298 |
| 7275 scoped_refptr<DelayedSocketData> spdy_data( | 7299 scoped_refptr<DelayedSocketData> spdy_data( |
| 7276 new DelayedSocketData( | 7300 new DelayedSocketData( |
| 7277 1, // wait for one write to finish before reading. | 7301 1, // wait for one write to finish before reading. |
| 7278 spdy_reads, arraysize(spdy_reads), | 7302 spdy_reads, arraysize(spdy_reads), |
| 7279 spdy_writes, arraysize(spdy_writes))); | 7303 spdy_writes, arraysize(spdy_writes))); |
| 7280 session_deps.socket_factory.AddSocketDataProvider(spdy_data); | 7304 session_deps.socket_factory.AddSocketDataProvider(spdy_data); |
| 7281 | 7305 |
| 7282 TestOldCompletionCallback callback_old; | |
| 7283 TestCompletionCallback callback; | 7306 TestCompletionCallback callback; |
| 7284 | 7307 |
| 7285 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7308 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 7286 | 7309 |
| 7287 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 7310 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 7288 | 7311 |
| 7289 int rv = trans->Start(&request, &callback_old, BoundNetLog()); | 7312 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 7290 EXPECT_EQ(ERR_IO_PENDING, rv); | 7313 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7291 EXPECT_EQ(OK, callback_old.WaitForResult()); | 7314 EXPECT_EQ(OK, callback.WaitForResult()); |
| 7292 | 7315 |
| 7293 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7316 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7294 ASSERT_TRUE(response != NULL); | 7317 ASSERT_TRUE(response != NULL); |
| 7295 ASSERT_TRUE(response->headers != NULL); | 7318 ASSERT_TRUE(response->headers != NULL); |
| 7296 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7319 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 7297 | 7320 |
| 7298 std::string response_data; | 7321 std::string response_data; |
| 7299 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 7322 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 7300 EXPECT_EQ("hello world", response_data); | 7323 EXPECT_EQ("hello world", response_data); |
| 7301 | 7324 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 7327 NULL /* ssl_host_info */, context)); | 7350 NULL /* ssl_host_info */, context)); |
| 7328 EXPECT_EQ(ERR_IO_PENDING, | 7351 EXPECT_EQ(ERR_IO_PENDING, |
| 7329 ssl_connection->socket()->Connect(callback.callback())); | 7352 ssl_connection->socket()->Connect(callback.callback())); |
| 7330 EXPECT_EQ(OK, callback.WaitForResult()); | 7353 EXPECT_EQ(OK, callback.WaitForResult()); |
| 7331 | 7354 |
| 7332 EXPECT_EQ(OK, spdy_session->InitializeWithSocket(ssl_connection.release(), | 7355 EXPECT_EQ(OK, spdy_session->InitializeWithSocket(ssl_connection.release(), |
| 7333 true, OK)); | 7356 true, OK)); |
| 7334 | 7357 |
| 7335 trans.reset(new HttpNetworkTransaction(session)); | 7358 trans.reset(new HttpNetworkTransaction(session)); |
| 7336 | 7359 |
| 7337 rv = trans->Start(&request, &callback_old, BoundNetLog()); | 7360 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 7338 EXPECT_EQ(ERR_IO_PENDING, rv); | 7361 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7339 EXPECT_EQ(OK, callback_old.WaitForResult()); | 7362 EXPECT_EQ(OK, callback.WaitForResult()); |
| 7340 | 7363 |
| 7341 response = trans->GetResponseInfo(); | 7364 response = trans->GetResponseInfo(); |
| 7342 ASSERT_TRUE(response != NULL); | 7365 ASSERT_TRUE(response != NULL); |
| 7343 ASSERT_TRUE(response->headers != NULL); | 7366 ASSERT_TRUE(response->headers != NULL); |
| 7344 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7367 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 7345 EXPECT_TRUE(response->was_fetched_via_spdy); | 7368 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 7346 EXPECT_TRUE(response->was_npn_negotiated); | 7369 EXPECT_TRUE(response->was_npn_negotiated); |
| 7347 | 7370 |
| 7348 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 7371 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 7349 EXPECT_EQ("hello!", response_data); | 7372 EXPECT_EQ("hello!", response_data); |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7729 reads, length_reads, writes, length_writes); | 7752 reads, length_reads, writes, length_writes); |
| 7730 session_deps.socket_factory.AddSocketDataProvider(&data_provider); | 7753 session_deps.socket_factory.AddSocketDataProvider(&data_provider); |
| 7731 | 7754 |
| 7732 // Add an SSL sequence if necessary. | 7755 // Add an SSL sequence if necessary. |
| 7733 SSLSocketDataProvider ssl_socket_data_provider(false, OK); | 7756 SSLSocketDataProvider ssl_socket_data_provider(false, OK); |
| 7734 if (round >= test_config.first_ssl_round) | 7757 if (round >= test_config.first_ssl_round) |
| 7735 session_deps.socket_factory.AddSSLSocketDataProvider( | 7758 session_deps.socket_factory.AddSSLSocketDataProvider( |
| 7736 &ssl_socket_data_provider); | 7759 &ssl_socket_data_provider); |
| 7737 | 7760 |
| 7738 // Start or restart the transaction. | 7761 // Start or restart the transaction. |
| 7739 TestOldCompletionCallback callback; | 7762 TestCompletionCallback callback; |
| 7740 int rv; | 7763 int rv; |
| 7741 if (round == 0) { | 7764 if (round == 0) { |
| 7742 rv = trans.Start(&request, &callback, BoundNetLog()); | 7765 rv = trans.Start(&request, callback.callback(), BoundNetLog()); |
| 7743 } else { | 7766 } else { |
| 7744 rv = trans.RestartWithAuth(AuthCredentials(kFoo, kBar), &callback); | 7767 rv = trans.RestartWithAuth( |
| 7768 AuthCredentials(kFoo, kBar), callback.callback()); |
| 7745 } | 7769 } |
| 7746 if (rv == ERR_IO_PENDING) | 7770 if (rv == ERR_IO_PENDING) |
| 7747 rv = callback.WaitForResult(); | 7771 rv = callback.WaitForResult(); |
| 7748 | 7772 |
| 7749 // Compare results with expected data. | 7773 // Compare results with expected data. |
| 7750 EXPECT_EQ(read_write_round.expected_rv, rv); | 7774 EXPECT_EQ(read_write_round.expected_rv, rv); |
| 7751 const HttpResponseInfo* response = trans.GetResponseInfo(); | 7775 const HttpResponseInfo* response = trans.GetResponseInfo(); |
| 7752 if (read_write_round.expected_rv == OK) { | 7776 if (read_write_round.expected_rv == OK) { |
| 7753 ASSERT_TRUE(response != NULL); | 7777 ASSERT_TRUE(response != NULL); |
| 7754 } else { | 7778 } else { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7805 &transport_pool_histograms, | 7829 &transport_pool_histograms, |
| 7806 session_deps.host_resolver.get(), | 7830 session_deps.host_resolver.get(), |
| 7807 &session_deps.socket_factory, | 7831 &session_deps.socket_factory, |
| 7808 session_deps.net_log); | 7832 session_deps.net_log); |
| 7809 MockClientSocketPoolManager* mock_pool_manager = | 7833 MockClientSocketPoolManager* mock_pool_manager = |
| 7810 new MockClientSocketPoolManager; | 7834 new MockClientSocketPoolManager; |
| 7811 mock_pool_manager->SetTransportSocketPool(transport_pool); | 7835 mock_pool_manager->SetTransportSocketPool(transport_pool); |
| 7812 session_peer.SetClientSocketPoolManager(mock_pool_manager); | 7836 session_peer.SetClientSocketPoolManager(mock_pool_manager); |
| 7813 | 7837 |
| 7814 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 7838 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 7815 TestOldCompletionCallback callback; | 7839 TestCompletionCallback callback; |
| 7816 | 7840 |
| 7817 const MockWrite kGet( | 7841 const MockWrite kGet( |
| 7818 "GET / HTTP/1.1\r\n" | 7842 "GET / HTTP/1.1\r\n" |
| 7819 "Host: www.example.com\r\n" | 7843 "Host: www.example.com\r\n" |
| 7820 "Connection: keep-alive\r\n\r\n"); | 7844 "Connection: keep-alive\r\n\r\n"); |
| 7821 const MockWrite kGetAuth( | 7845 const MockWrite kGetAuth( |
| 7822 "GET / HTTP/1.1\r\n" | 7846 "GET / HTTP/1.1\r\n" |
| 7823 "Host: www.example.com\r\n" | 7847 "Host: www.example.com\r\n" |
| 7824 "Connection: keep-alive\r\n" | 7848 "Connection: keep-alive\r\n" |
| 7825 "Authorization: auth_token\r\n\r\n"); | 7849 "Authorization: auth_token\r\n\r\n"); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7861 kSuccess, | 7885 kSuccess, |
| 7862 }; | 7886 }; |
| 7863 StaticSocketDataProvider data_provider(reads, arraysize(reads), | 7887 StaticSocketDataProvider data_provider(reads, arraysize(reads), |
| 7864 writes, arraysize(writes)); | 7888 writes, arraysize(writes)); |
| 7865 session_deps.socket_factory.AddSocketDataProvider(&data_provider); | 7889 session_deps.socket_factory.AddSocketDataProvider(&data_provider); |
| 7866 | 7890 |
| 7867 const char* const kSocketGroup = "www.example.com:80"; | 7891 const char* const kSocketGroup = "www.example.com:80"; |
| 7868 | 7892 |
| 7869 // First round of authentication. | 7893 // First round of authentication. |
| 7870 auth_handler->SetGenerateExpectation(false, OK); | 7894 auth_handler->SetGenerateExpectation(false, OK); |
| 7871 rv = trans->Start(&request, &callback, BoundNetLog()); | 7895 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 7872 if (rv == ERR_IO_PENDING) | 7896 if (rv == ERR_IO_PENDING) |
| 7873 rv = callback.WaitForResult(); | 7897 rv = callback.WaitForResult(); |
| 7874 EXPECT_EQ(OK, rv); | 7898 EXPECT_EQ(OK, rv); |
| 7875 response = trans->GetResponseInfo(); | 7899 response = trans->GetResponseInfo(); |
| 7876 ASSERT_TRUE(response != NULL); | 7900 ASSERT_TRUE(response != NULL); |
| 7877 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 7901 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
| 7878 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 7902 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
| 7879 | 7903 |
| 7880 // In between rounds, another request comes in for the same domain. | 7904 // In between rounds, another request comes in for the same domain. |
| 7881 // It should not be able to grab the TCP socket that trans has already | 7905 // It should not be able to grab the TCP socket that trans has already |
| 7882 // claimed. | 7906 // claimed. |
| 7883 scoped_ptr<HttpTransaction> trans_compete( | 7907 scoped_ptr<HttpTransaction> trans_compete( |
| 7884 new HttpNetworkTransaction(session)); | 7908 new HttpNetworkTransaction(session)); |
| 7885 TestOldCompletionCallback callback_compete; | 7909 TestCompletionCallback callback_compete; |
| 7886 rv = trans_compete->Start(&request, &callback_compete, BoundNetLog()); | 7910 rv = trans_compete->Start( |
| 7911 &request, callback_compete.callback(), BoundNetLog()); |
| 7887 EXPECT_EQ(ERR_IO_PENDING, rv); | 7912 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7888 // callback_compete.WaitForResult at this point would stall forever, | 7913 // callback_compete.WaitForResult at this point would stall forever, |
| 7889 // since the HttpNetworkTransaction does not release the request back to | 7914 // since the HttpNetworkTransaction does not release the request back to |
| 7890 // the pool until after authentication completes. | 7915 // the pool until after authentication completes. |
| 7891 | 7916 |
| 7892 // Second round of authentication. | 7917 // Second round of authentication. |
| 7893 auth_handler->SetGenerateExpectation(false, OK); | 7918 auth_handler->SetGenerateExpectation(false, OK); |
| 7894 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback); | 7919 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), callback.callback()); |
| 7895 if (rv == ERR_IO_PENDING) | 7920 if (rv == ERR_IO_PENDING) |
| 7896 rv = callback.WaitForResult(); | 7921 rv = callback.WaitForResult(); |
| 7897 EXPECT_EQ(OK, rv); | 7922 EXPECT_EQ(OK, rv); |
| 7898 response = trans->GetResponseInfo(); | 7923 response = trans->GetResponseInfo(); |
| 7899 ASSERT_TRUE(response != NULL); | 7924 ASSERT_TRUE(response != NULL); |
| 7900 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 7925 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 7901 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 7926 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
| 7902 | 7927 |
| 7903 // Third round of authentication. | 7928 // Third round of authentication. |
| 7904 auth_handler->SetGenerateExpectation(false, OK); | 7929 auth_handler->SetGenerateExpectation(false, OK); |
| 7905 rv = trans->RestartWithAuth(AuthCredentials(), &callback); | 7930 rv = trans->RestartWithAuth(AuthCredentials(), callback.callback()); |
| 7906 if (rv == ERR_IO_PENDING) | 7931 if (rv == ERR_IO_PENDING) |
| 7907 rv = callback.WaitForResult(); | 7932 rv = callback.WaitForResult(); |
| 7908 EXPECT_EQ(OK, rv); | 7933 EXPECT_EQ(OK, rv); |
| 7909 response = trans->GetResponseInfo(); | 7934 response = trans->GetResponseInfo(); |
| 7910 ASSERT_TRUE(response != NULL); | 7935 ASSERT_TRUE(response != NULL); |
| 7911 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 7936 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 7912 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 7937 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
| 7913 | 7938 |
| 7914 // Fourth round of authentication, which completes successfully. | 7939 // Fourth round of authentication, which completes successfully. |
| 7915 auth_handler->SetGenerateExpectation(false, OK); | 7940 auth_handler->SetGenerateExpectation(false, OK); |
| 7916 rv = trans->RestartWithAuth(AuthCredentials(), &callback); | 7941 rv = trans->RestartWithAuth(AuthCredentials(), callback.callback()); |
| 7917 if (rv == ERR_IO_PENDING) | 7942 if (rv == ERR_IO_PENDING) |
| 7918 rv = callback.WaitForResult(); | 7943 rv = callback.WaitForResult(); |
| 7919 EXPECT_EQ(OK, rv); | 7944 EXPECT_EQ(OK, rv); |
| 7920 response = trans->GetResponseInfo(); | 7945 response = trans->GetResponseInfo(); |
| 7921 ASSERT_TRUE(response != NULL); | 7946 ASSERT_TRUE(response != NULL); |
| 7922 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 7947 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 7923 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 7948 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
| 7924 | 7949 |
| 7925 // Read the body since the fourth round was successful. This will also | 7950 // Read the body since the fourth round was successful. This will also |
| 7926 // release the socket back to the pool. | 7951 // release the socket back to the pool. |
| 7927 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(50)); | 7952 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(50)); |
| 7928 rv = trans->Read(io_buf, io_buf->size(), &callback); | 7953 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); |
| 7929 if (rv == ERR_IO_PENDING) | 7954 if (rv == ERR_IO_PENDING) |
| 7930 rv = callback.WaitForResult(); | 7955 rv = callback.WaitForResult(); |
| 7931 EXPECT_EQ(3, rv); | 7956 EXPECT_EQ(3, rv); |
| 7932 rv = trans->Read(io_buf, io_buf->size(), &callback); | 7957 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); |
| 7933 EXPECT_EQ(0, rv); | 7958 EXPECT_EQ(0, rv); |
| 7934 // There are still 0 idle sockets, since the trans_compete transaction | 7959 // There are still 0 idle sockets, since the trans_compete transaction |
| 7935 // will be handed it immediately after trans releases it to the group. | 7960 // will be handed it immediately after trans releases it to the group. |
| 7936 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 7961 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
| 7937 | 7962 |
| 7938 // The competing request can now finish. Wait for the headers and then | 7963 // The competing request can now finish. Wait for the headers and then |
| 7939 // read the body. | 7964 // read the body. |
| 7940 rv = callback_compete.WaitForResult(); | 7965 rv = callback_compete.WaitForResult(); |
| 7941 EXPECT_EQ(OK, rv); | 7966 EXPECT_EQ(OK, rv); |
| 7942 rv = trans_compete->Read(io_buf, io_buf->size(), &callback); | 7967 rv = trans_compete->Read(io_buf, io_buf->size(), callback.callback()); |
| 7943 if (rv == ERR_IO_PENDING) | 7968 if (rv == ERR_IO_PENDING) |
| 7944 rv = callback.WaitForResult(); | 7969 rv = callback.WaitForResult(); |
| 7945 EXPECT_EQ(3, rv); | 7970 EXPECT_EQ(3, rv); |
| 7946 rv = trans_compete->Read(io_buf, io_buf->size(), &callback); | 7971 rv = trans_compete->Read(io_buf, io_buf->size(), callback.callback()); |
| 7947 EXPECT_EQ(0, rv); | 7972 EXPECT_EQ(0, rv); |
| 7948 | 7973 |
| 7949 // Finally, the socket is released to the group. | 7974 // Finally, the socket is released to the group. |
| 7950 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 7975 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
| 7951 } | 7976 } |
| 7952 | 7977 |
| 7953 class TLSDecompressionFailureSocketDataProvider : public SocketDataProvider { | 7978 class TLSDecompressionFailureSocketDataProvider : public SocketDataProvider { |
| 7954 public: | 7979 public: |
| 7955 explicit TLSDecompressionFailureSocketDataProvider(bool fail_all) | 7980 explicit TLSDecompressionFailureSocketDataProvider(bool fail_all) |
| 7956 : fail_all_(fail_all) { | 7981 : fail_all_(fail_all) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7998 session_deps.socket_factory.AddSSLSocketDataProvider( | 8023 session_deps.socket_factory.AddSSLSocketDataProvider( |
| 7999 &ssl_socket_data_provider2); | 8024 &ssl_socket_data_provider2); |
| 8000 | 8025 |
| 8001 // Work around http://crbug.com/37454 | 8026 // Work around http://crbug.com/37454 |
| 8002 StaticSocketDataProvider bug37454_connection; | 8027 StaticSocketDataProvider bug37454_connection; |
| 8003 bug37454_connection.set_connect_data(MockConnect(true, ERR_UNEXPECTED)); | 8028 bug37454_connection.set_connect_data(MockConnect(true, ERR_UNEXPECTED)); |
| 8004 session_deps.socket_factory.AddSocketDataProvider(&bug37454_connection); | 8029 session_deps.socket_factory.AddSocketDataProvider(&bug37454_connection); |
| 8005 | 8030 |
| 8006 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8031 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8007 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8032 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 8008 TestOldCompletionCallback callback; | 8033 TestCompletionCallback callback; |
| 8009 | 8034 |
| 8010 int rv = trans->Start(&request, &callback, BoundNetLog()); | 8035 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 8011 EXPECT_EQ(ERR_IO_PENDING, rv); | 8036 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8012 EXPECT_EQ(OK, callback.WaitForResult()); | 8037 EXPECT_EQ(OK, callback.WaitForResult()); |
| 8013 | 8038 |
| 8014 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8039 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 8015 ASSERT_TRUE(response != NULL); | 8040 ASSERT_TRUE(response != NULL); |
| 8016 ASSERT_TRUE(response->headers != NULL); | 8041 ASSERT_TRUE(response->headers != NULL); |
| 8017 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8042 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 8018 | 8043 |
| 8019 std::string response_data; | 8044 std::string response_data; |
| 8020 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8045 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 8040 SSLSocketDataProvider ssl_socket_data_provider2(false, OK); | 8065 SSLSocketDataProvider ssl_socket_data_provider2(false, OK); |
| 8041 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider1); | 8066 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider1); |
| 8042 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider2); | 8067 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider2); |
| 8043 session_deps.socket_factory.AddSSLSocketDataProvider( | 8068 session_deps.socket_factory.AddSSLSocketDataProvider( |
| 8044 &ssl_socket_data_provider1); | 8069 &ssl_socket_data_provider1); |
| 8045 session_deps.socket_factory.AddSSLSocketDataProvider( | 8070 session_deps.socket_factory.AddSSLSocketDataProvider( |
| 8046 &ssl_socket_data_provider2); | 8071 &ssl_socket_data_provider2); |
| 8047 | 8072 |
| 8048 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8073 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8049 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8074 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 8050 TestOldCompletionCallback callback; | 8075 TestCompletionCallback callback; |
| 8051 | 8076 |
| 8052 int rv = trans->Start(&request, &callback, BoundNetLog()); | 8077 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 8053 EXPECT_EQ(ERR_IO_PENDING, rv); | 8078 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8054 EXPECT_EQ(OK, callback.WaitForResult()); | 8079 EXPECT_EQ(OK, callback.WaitForResult()); |
| 8055 | 8080 |
| 8056 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8081 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 8057 ASSERT_TRUE(response != NULL); | 8082 ASSERT_TRUE(response != NULL); |
| 8058 ASSERT_TRUE(response->headers != NULL); | 8083 ASSERT_TRUE(response->headers != NULL); |
| 8059 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8084 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 8060 | 8085 |
| 8061 std::string response_data; | 8086 std::string response_data; |
| 8062 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8087 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 8091 SSLSocketDataProvider ssl(true, OK); | 8116 SSLSocketDataProvider ssl(true, OK); |
| 8092 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 8117 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
| 8093 ssl.next_proto = "http/1.1"; | 8118 ssl.next_proto = "http/1.1"; |
| 8094 | 8119 |
| 8095 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 8120 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 8096 | 8121 |
| 8097 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 8122 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 8098 data_writes, arraysize(data_writes)); | 8123 data_writes, arraysize(data_writes)); |
| 8099 session_deps.socket_factory.AddSocketDataProvider(&data); | 8124 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 8100 | 8125 |
| 8101 TestOldCompletionCallback callback; | 8126 TestCompletionCallback callback; |
| 8102 | 8127 |
| 8103 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8128 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8104 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8129 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 8105 | 8130 |
| 8106 int rv = trans->Start(&request, &callback, BoundNetLog()); | 8131 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 8107 | 8132 |
| 8108 EXPECT_EQ(ERR_IO_PENDING, rv); | 8133 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8109 EXPECT_EQ(OK, callback.WaitForResult()); | 8134 EXPECT_EQ(OK, callback.WaitForResult()); |
| 8110 | 8135 |
| 8111 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8136 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 8112 ASSERT_TRUE(response != NULL); | 8137 ASSERT_TRUE(response != NULL); |
| 8113 ASSERT_TRUE(response->headers != NULL); | 8138 ASSERT_TRUE(response->headers != NULL); |
| 8114 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8139 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 8115 | 8140 |
| 8116 std::string response_data; | 8141 std::string response_data; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8150 MockRead(false, 0, 0) // Not async - return 0 immediately. | 8175 MockRead(false, 0, 0) // Not async - return 0 immediately. |
| 8151 }; | 8176 }; |
| 8152 | 8177 |
| 8153 scoped_refptr<DelayedSocketData> spdy_data( | 8178 scoped_refptr<DelayedSocketData> spdy_data( |
| 8154 new DelayedSocketData( | 8179 new DelayedSocketData( |
| 8155 0, // don't wait in this case, immediate hangup. | 8180 0, // don't wait in this case, immediate hangup. |
| 8156 spdy_reads, arraysize(spdy_reads), | 8181 spdy_reads, arraysize(spdy_reads), |
| 8157 spdy_writes, arraysize(spdy_writes))); | 8182 spdy_writes, arraysize(spdy_writes))); |
| 8158 session_deps.socket_factory.AddSocketDataProvider(spdy_data); | 8183 session_deps.socket_factory.AddSocketDataProvider(spdy_data); |
| 8159 | 8184 |
| 8160 TestOldCompletionCallback callback; | 8185 TestCompletionCallback callback; |
| 8161 | 8186 |
| 8162 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8187 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8163 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 8188 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 8164 | 8189 |
| 8165 int rv = trans->Start(&request, &callback, BoundNetLog()); | 8190 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 8166 EXPECT_EQ(ERR_IO_PENDING, rv); | 8191 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8167 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); | 8192 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); |
| 8168 | 8193 |
| 8169 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 8194 HttpStreamFactory::set_next_protos(std::vector<std::string>()); |
| 8170 HttpStreamFactory::set_use_alternate_protocols(false); | 8195 HttpStreamFactory::set_use_alternate_protocols(false); |
| 8171 } | 8196 } |
| 8172 | 8197 |
| 8173 TEST_F(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { | 8198 TEST_F(HttpNetworkTransactionTest, SpdyAlternateProtocolThroughProxy) { |
| 8174 // This test ensures that the URL passed into the proxy is upgraded | 8199 // This test ensures that the URL passed into the proxy is upgraded |
| 8175 // to https when doing an Alternate Protocol upgrade. | 8200 // to https when doing an Alternate Protocol upgrade. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8282 never_finishing_connect); | 8307 never_finishing_connect); |
| 8283 | 8308 |
| 8284 session_deps.socket_factory.AddSocketDataProvider(&data_1); | 8309 session_deps.socket_factory.AddSocketDataProvider(&data_1); |
| 8285 session_deps.socket_factory.AddSocketDataProvider(data_2.get()); | 8310 session_deps.socket_factory.AddSocketDataProvider(data_2.get()); |
| 8286 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 8311 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 8287 session_deps.socket_factory.AddSocketDataProvider( | 8312 session_deps.socket_factory.AddSocketDataProvider( |
| 8288 &hanging_non_alternate_protocol_socket); | 8313 &hanging_non_alternate_protocol_socket); |
| 8289 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8314 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8290 | 8315 |
| 8291 // First round should work and provide the Alternate-Protocol state. | 8316 // First round should work and provide the Alternate-Protocol state. |
| 8292 TestOldCompletionCallback callback_1; | 8317 TestCompletionCallback callback_1; |
| 8293 scoped_ptr<HttpTransaction> trans_1(new HttpNetworkTransaction(session)); | 8318 scoped_ptr<HttpTransaction> trans_1(new HttpNetworkTransaction(session)); |
| 8294 int rv = trans_1->Start(&request, &callback_1, BoundNetLog()); | 8319 int rv = trans_1->Start(&request, callback_1.callback(), BoundNetLog()); |
| 8295 EXPECT_EQ(ERR_IO_PENDING, rv); | 8320 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8296 EXPECT_EQ(OK, callback_1.WaitForResult()); | 8321 EXPECT_EQ(OK, callback_1.WaitForResult()); |
| 8297 | 8322 |
| 8298 // Second round should attempt a tunnel connect and get an auth challenge. | 8323 // Second round should attempt a tunnel connect and get an auth challenge. |
| 8299 TestOldCompletionCallback callback_2; | 8324 TestCompletionCallback callback_2; |
| 8300 scoped_ptr<HttpTransaction> trans_2(new HttpNetworkTransaction(session)); | 8325 scoped_ptr<HttpTransaction> trans_2(new HttpNetworkTransaction(session)); |
| 8301 rv = trans_2->Start(&request, &callback_2, BoundNetLog()); | 8326 rv = trans_2->Start(&request, callback_2.callback(), BoundNetLog()); |
| 8302 EXPECT_EQ(ERR_IO_PENDING, rv); | 8327 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8303 EXPECT_EQ(OK, callback_2.WaitForResult()); | 8328 EXPECT_EQ(OK, callback_2.WaitForResult()); |
| 8304 const HttpResponseInfo* response = trans_2->GetResponseInfo(); | 8329 const HttpResponseInfo* response = trans_2->GetResponseInfo(); |
| 8305 ASSERT_TRUE(response != NULL); | 8330 ASSERT_TRUE(response != NULL); |
| 8306 ASSERT_FALSE(response->auth_challenge.get() == NULL); | 8331 ASSERT_FALSE(response->auth_challenge.get() == NULL); |
| 8307 | 8332 |
| 8308 // Restart with auth. Tunnel should work and response received. | 8333 // Restart with auth. Tunnel should work and response received. |
| 8309 TestOldCompletionCallback callback_3; | 8334 TestCompletionCallback callback_3; |
| 8310 rv = trans_2->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback_3); | 8335 rv = trans_2->RestartWithAuth( |
| 8336 AuthCredentials(kFoo, kBar), callback_3.callback()); |
| 8311 EXPECT_EQ(ERR_IO_PENDING, rv); | 8337 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8312 EXPECT_EQ(OK, callback_3.WaitForResult()); | 8338 EXPECT_EQ(OK, callback_3.WaitForResult()); |
| 8313 | 8339 |
| 8314 // After all that work, these two lines (or actually, just the scheme) are | 8340 // After all that work, these two lines (or actually, just the scheme) are |
| 8315 // what this test is all about. Make sure it happens correctly. | 8341 // what this test is all about. Make sure it happens correctly. |
| 8316 const GURL& request_url = auth_handler->request_url(); | 8342 const GURL& request_url = auth_handler->request_url(); |
| 8317 EXPECT_EQ("https", request_url.scheme()); | 8343 EXPECT_EQ("https", request_url.scheme()); |
| 8318 EXPECT_EQ("www.google.com", request_url.host()); | 8344 EXPECT_EQ("www.google.com", request_url.host()); |
| 8319 | 8345 |
| 8320 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 8346 HttpStreamFactory::set_next_protos(std::vector<std::string>()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 8343 | 8369 |
| 8344 SessionDependencies session_deps; | 8370 SessionDependencies session_deps; |
| 8345 session_deps.host_resolver->set_synchronous_mode(true); | 8371 session_deps.host_resolver->set_synchronous_mode(true); |
| 8346 scoped_ptr<HttpTransaction> trans( | 8372 scoped_ptr<HttpTransaction> trans( |
| 8347 new HttpNetworkTransaction(CreateSession(&session_deps))); | 8373 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 8348 | 8374 |
| 8349 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 8375 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 8350 data.set_connect_data(mock_connect); | 8376 data.set_connect_data(mock_connect); |
| 8351 session_deps.socket_factory.AddSocketDataProvider(&data); | 8377 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 8352 | 8378 |
| 8353 TestOldCompletionCallback callback; | 8379 TestCompletionCallback callback; |
| 8354 | 8380 |
| 8355 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8381 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
| 8356 int rv = trans->Start(&request, &callback, log.bound()); | 8382 int rv = trans->Start(&request, callback.callback(), log.bound()); |
| 8357 EXPECT_EQ(ERR_IO_PENDING, rv); | 8383 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8358 trans.reset(); // Cancel the transaction here. | 8384 trans.reset(); // Cancel the transaction here. |
| 8359 | 8385 |
| 8360 MessageLoop::current()->RunAllPending(); | 8386 MessageLoop::current()->RunAllPending(); |
| 8361 } | 8387 } |
| 8362 | 8388 |
| 8363 // Test a basic GET request through a proxy. | 8389 // Test a basic GET request through a proxy. |
| 8364 TEST_F(HttpNetworkTransactionTest, ProxyGet) { | 8390 TEST_F(HttpNetworkTransactionTest, ProxyGet) { |
| 8365 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8391 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 8366 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 8392 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 8381 MockRead("HTTP/1.1 200 OK\r\n"), | 8407 MockRead("HTTP/1.1 200 OK\r\n"), |
| 8382 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 8408 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 8383 MockRead("Content-Length: 100\r\n\r\n"), | 8409 MockRead("Content-Length: 100\r\n\r\n"), |
| 8384 MockRead(false, OK), | 8410 MockRead(false, OK), |
| 8385 }; | 8411 }; |
| 8386 | 8412 |
| 8387 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 8413 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 8388 data_writes1, arraysize(data_writes1)); | 8414 data_writes1, arraysize(data_writes1)); |
| 8389 session_deps.socket_factory.AddSocketDataProvider(&data1); | 8415 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 8390 | 8416 |
| 8391 TestOldCompletionCallback callback1; | 8417 TestCompletionCallback callback1; |
| 8392 | 8418 |
| 8393 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8419 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 8394 | 8420 |
| 8395 int rv = trans->Start(&request, &callback1, log.bound()); | 8421 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 8396 EXPECT_EQ(ERR_IO_PENDING, rv); | 8422 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8397 | 8423 |
| 8398 rv = callback1.WaitForResult(); | 8424 rv = callback1.WaitForResult(); |
| 8399 EXPECT_EQ(OK, rv); | 8425 EXPECT_EQ(OK, rv); |
| 8400 | 8426 |
| 8401 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8427 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 8402 ASSERT_TRUE(response != NULL); | 8428 ASSERT_TRUE(response != NULL); |
| 8403 | 8429 |
| 8404 EXPECT_TRUE(response->headers->IsKeepAlive()); | 8430 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 8405 EXPECT_EQ(200, response->headers->response_code()); | 8431 EXPECT_EQ(200, response->headers->response_code()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8438 MockRead("Content-Length: 100\r\n\r\n"), | 8464 MockRead("Content-Length: 100\r\n\r\n"), |
| 8439 MockRead(false, OK), | 8465 MockRead(false, OK), |
| 8440 }; | 8466 }; |
| 8441 | 8467 |
| 8442 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 8468 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 8443 data_writes1, arraysize(data_writes1)); | 8469 data_writes1, arraysize(data_writes1)); |
| 8444 session_deps.socket_factory.AddSocketDataProvider(&data1); | 8470 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 8445 SSLSocketDataProvider ssl(true, OK); | 8471 SSLSocketDataProvider ssl(true, OK); |
| 8446 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 8472 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 8447 | 8473 |
| 8448 TestOldCompletionCallback callback1; | 8474 TestCompletionCallback callback1; |
| 8449 | 8475 |
| 8450 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8476 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 8451 | 8477 |
| 8452 int rv = trans->Start(&request, &callback1, log.bound()); | 8478 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 8453 EXPECT_EQ(ERR_IO_PENDING, rv); | 8479 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8454 | 8480 |
| 8455 rv = callback1.WaitForResult(); | 8481 rv = callback1.WaitForResult(); |
| 8456 EXPECT_EQ(OK, rv); | 8482 EXPECT_EQ(OK, rv); |
| 8457 net::CapturingNetLog::EntryList entries; | 8483 net::CapturingNetLog::EntryList entries; |
| 8458 log.GetEntries(&entries); | 8484 log.GetEntries(&entries); |
| 8459 size_t pos = ExpectLogContainsSomewhere( | 8485 size_t pos = ExpectLogContainsSomewhere( |
| 8460 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 8486 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 8461 NetLog::PHASE_NONE); | 8487 NetLog::PHASE_NONE); |
| 8462 ExpectLogContainsSomewhere( | 8488 ExpectLogContainsSomewhere( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8502 MockRead("HTTP/1.1 200 Connection Established\r\n\r\n"), | 8528 MockRead("HTTP/1.1 200 Connection Established\r\n\r\n"), |
| 8503 MockRead(true, 0, 0), // EOF | 8529 MockRead(true, 0, 0), // EOF |
| 8504 }; | 8530 }; |
| 8505 | 8531 |
| 8506 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 8532 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 8507 data_writes1, arraysize(data_writes1)); | 8533 data_writes1, arraysize(data_writes1)); |
| 8508 session_deps.socket_factory.AddSocketDataProvider(&data1); | 8534 session_deps.socket_factory.AddSocketDataProvider(&data1); |
| 8509 SSLSocketDataProvider ssl(true, OK); | 8535 SSLSocketDataProvider ssl(true, OK); |
| 8510 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 8536 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 8511 | 8537 |
| 8512 TestOldCompletionCallback callback1; | 8538 TestCompletionCallback callback1; |
| 8513 | 8539 |
| 8514 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8540 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 8515 | 8541 |
| 8516 int rv = trans->Start(&request, &callback1, log.bound()); | 8542 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 8517 EXPECT_EQ(ERR_IO_PENDING, rv); | 8543 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8518 | 8544 |
| 8519 rv = callback1.WaitForResult(); | 8545 rv = callback1.WaitForResult(); |
| 8520 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); | 8546 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); |
| 8521 net::CapturingNetLog::EntryList entries; | 8547 net::CapturingNetLog::EntryList entries; |
| 8522 log.GetEntries(&entries); | 8548 log.GetEntries(&entries); |
| 8523 size_t pos = ExpectLogContainsSomewhere( | 8549 size_t pos = ExpectLogContainsSomewhere( |
| 8524 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 8550 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 8525 NetLog::PHASE_NONE); | 8551 NetLog::PHASE_NONE); |
| 8526 ExpectLogContainsSomewhere( | 8552 ExpectLogContainsSomewhere( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8560 | 8586 |
| 8561 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8587 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8562 | 8588 |
| 8563 // Set up an initial SpdySession in the pool to reuse. | 8589 // Set up an initial SpdySession in the pool to reuse. |
| 8564 HostPortPair host_port_pair("www.google.com", 443); | 8590 HostPortPair host_port_pair("www.google.com", 443); |
| 8565 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | 8591 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); |
| 8566 scoped_refptr<SpdySession> spdy_session = | 8592 scoped_refptr<SpdySession> spdy_session = |
| 8567 session->spdy_session_pool()->Get(pair, BoundNetLog()); | 8593 session->spdy_session_pool()->Get(pair, BoundNetLog()); |
| 8568 scoped_refptr<TransportSocketParams> transport_params( | 8594 scoped_refptr<TransportSocketParams> transport_params( |
| 8569 new TransportSocketParams(host_port_pair, MEDIUM, false, false)); | 8595 new TransportSocketParams(host_port_pair, MEDIUM, false, false)); |
| 8570 TestOldCompletionCallback old_callback; | |
| 8571 TestCompletionCallback callback; | 8596 TestCompletionCallback callback; |
| 8572 | 8597 |
| 8573 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); | 8598 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); |
| 8574 EXPECT_EQ(ERR_IO_PENDING, | 8599 EXPECT_EQ(ERR_IO_PENDING, |
| 8575 connection->Init(host_port_pair.ToString(), transport_params, | 8600 connection->Init(host_port_pair.ToString(), transport_params, |
| 8576 LOWEST, callback.callback(), | 8601 LOWEST, callback.callback(), |
| 8577 session->GetTransportSocketPool(), BoundNetLog())); | 8602 session->GetTransportSocketPool(), BoundNetLog())); |
| 8578 EXPECT_EQ(OK, callback.WaitForResult()); | 8603 EXPECT_EQ(OK, callback.WaitForResult()); |
| 8579 spdy_session->InitializeWithSocket(connection.release(), false, OK); | 8604 spdy_session->InitializeWithSocket(connection.release(), false, OK); |
| 8580 | 8605 |
| 8581 HttpRequestInfo request; | 8606 HttpRequestInfo request; |
| 8582 request.method = "GET"; | 8607 request.method = "GET"; |
| 8583 request.url = GURL("https://www.google.com/"); | 8608 request.url = GURL("https://www.google.com/"); |
| 8584 request.load_flags = 0; | 8609 request.load_flags = 0; |
| 8585 | 8610 |
| 8586 // This is the important line that marks this as a preconnect. | 8611 // This is the important line that marks this as a preconnect. |
| 8587 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; | 8612 request.motivation = HttpRequestInfo::PRECONNECT_MOTIVATED; |
| 8588 | 8613 |
| 8589 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 8614 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 8590 | 8615 |
| 8591 int rv = trans->Start(&request, &old_callback, BoundNetLog()); | 8616 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 8592 EXPECT_EQ(ERR_IO_PENDING, rv); | 8617 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8593 EXPECT_EQ(OK, old_callback.WaitForResult()); | 8618 EXPECT_EQ(OK, callback.WaitForResult()); |
| 8594 } | 8619 } |
| 8595 | 8620 |
| 8596 // Given a net error, cause that error to be returned from the first Write() | 8621 // Given a net error, cause that error to be returned from the first Write() |
| 8597 // call and verify that the HttpTransaction fails with that error. | 8622 // call and verify that the HttpTransaction fails with that error. |
| 8598 static void CheckErrorIsPassedBack(int error, bool async) { | 8623 static void CheckErrorIsPassedBack(int error, bool async) { |
| 8599 net::HttpRequestInfo request_info; | 8624 net::HttpRequestInfo request_info; |
| 8600 request_info.url = GURL("https://www.example.com/"); | 8625 request_info.url = GURL("https://www.example.com/"); |
| 8601 request_info.method = "GET"; | 8626 request_info.method = "GET"; |
| 8602 request_info.load_flags = net::LOAD_NORMAL; | 8627 request_info.load_flags = net::LOAD_NORMAL; |
| 8603 | 8628 |
| 8604 SessionDependencies session_deps; | 8629 SessionDependencies session_deps; |
| 8605 | 8630 |
| 8606 SSLSocketDataProvider ssl_data(async, OK); | 8631 SSLSocketDataProvider ssl_data(async, OK); |
| 8607 net::MockWrite data_writes[] = { | 8632 net::MockWrite data_writes[] = { |
| 8608 net::MockWrite(async, error), | 8633 net::MockWrite(async, error), |
| 8609 }; | 8634 }; |
| 8610 net::StaticSocketDataProvider data(NULL, 0, | 8635 net::StaticSocketDataProvider data(NULL, 0, |
| 8611 data_writes, arraysize(data_writes)); | 8636 data_writes, arraysize(data_writes)); |
| 8612 session_deps.socket_factory.AddSocketDataProvider(&data); | 8637 session_deps.socket_factory.AddSocketDataProvider(&data); |
| 8613 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data); | 8638 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data); |
| 8614 | 8639 |
| 8615 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8640 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8616 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 8641 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 8617 | 8642 |
| 8618 TestOldCompletionCallback callback; | 8643 TestCompletionCallback callback; |
| 8619 int rv = trans->Start(&request_info, &callback, net::BoundNetLog()); | 8644 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
| 8620 if (rv == net::ERR_IO_PENDING) | 8645 if (rv == net::ERR_IO_PENDING) |
| 8621 rv = callback.WaitForResult(); | 8646 rv = callback.WaitForResult(); |
| 8622 ASSERT_EQ(error, rv); | 8647 ASSERT_EQ(error, rv); |
| 8623 } | 8648 } |
| 8624 | 8649 |
| 8625 TEST_F(HttpNetworkTransactionTest, SSLWriteCertError) { | 8650 TEST_F(HttpNetworkTransactionTest, SSLWriteCertError) { |
| 8626 // Just check a grab bag of cert errors. | 8651 // Just check a grab bag of cert errors. |
| 8627 static const int kErrors[] = { | 8652 static const int kErrors[] = { |
| 8628 ERR_CERT_COMMON_NAME_INVALID, | 8653 ERR_CERT_COMMON_NAME_INVALID, |
| 8629 ERR_CERT_AUTHORITY_INVALID, | 8654 ERR_CERT_AUTHORITY_INVALID, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8686 net::ERR_SSL_PROTOCOL_ERROR); | 8711 net::ERR_SSL_PROTOCOL_ERROR); |
| 8687 ssl_data3.cert_request_info = cert_request.get(); | 8712 ssl_data3.cert_request_info = cert_request.get(); |
| 8688 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data3); | 8713 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data3); |
| 8689 net::StaticSocketDataProvider data3(NULL, 0, NULL, 0); | 8714 net::StaticSocketDataProvider data3(NULL, 0, NULL, 0); |
| 8690 session_deps.socket_factory.AddSocketDataProvider(&data3); | 8715 session_deps.socket_factory.AddSocketDataProvider(&data3); |
| 8691 | 8716 |
| 8692 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8717 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8693 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 8718 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 8694 | 8719 |
| 8695 // Begin the SSL handshake with the peer. This consumes ssl_data1. | 8720 // Begin the SSL handshake with the peer. This consumes ssl_data1. |
| 8696 TestOldCompletionCallback callback; | 8721 TestCompletionCallback callback; |
| 8697 int rv = trans->Start(&request_info, &callback, net::BoundNetLog()); | 8722 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
| 8698 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 8723 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
| 8699 | 8724 |
| 8700 // Complete the SSL handshake, which should abort due to requiring a | 8725 // Complete the SSL handshake, which should abort due to requiring a |
| 8701 // client certificate. | 8726 // client certificate. |
| 8702 rv = callback.WaitForResult(); | 8727 rv = callback.WaitForResult(); |
| 8703 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); | 8728 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); |
| 8704 | 8729 |
| 8705 // Indicate that no certificate should be supplied. From the perspective | 8730 // Indicate that no certificate should be supplied. From the perspective |
| 8706 // of SSLClientCertCache, NULL is just as meaningful as a real | 8731 // of SSLClientCertCache, NULL is just as meaningful as a real |
| 8707 // certificate, so this is the same as supply a | 8732 // certificate, so this is the same as supply a |
| 8708 // legitimate-but-unacceptable certificate. | 8733 // legitimate-but-unacceptable certificate. |
| 8709 rv = trans->RestartWithCertificate(NULL, &callback); | 8734 rv = trans->RestartWithCertificate(NULL, callback.callback()); |
| 8710 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 8735 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
| 8711 | 8736 |
| 8712 // Ensure the certificate was added to the client auth cache before | 8737 // Ensure the certificate was added to the client auth cache before |
| 8713 // allowing the connection to continue restarting. | 8738 // allowing the connection to continue restarting. |
| 8714 scoped_refptr<X509Certificate> client_cert; | 8739 scoped_refptr<X509Certificate> client_cert; |
| 8715 ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", | 8740 ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", |
| 8716 &client_cert)); | 8741 &client_cert)); |
| 8717 ASSERT_EQ(NULL, client_cert.get()); | 8742 ASSERT_EQ(NULL, client_cert.get()); |
| 8718 | 8743 |
| 8719 // Restart the handshake. This will consume ssl_data2, which fails, and | 8744 // Restart the handshake. This will consume ssl_data2, which fails, and |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8791 ssl_data3.cert_request_info = cert_request.get(); | 8816 ssl_data3.cert_request_info = cert_request.get(); |
| 8792 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data3); | 8817 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data3); |
| 8793 net::StaticSocketDataProvider data3( | 8818 net::StaticSocketDataProvider data3( |
| 8794 data2_reads, arraysize(data2_reads), NULL, 0); | 8819 data2_reads, arraysize(data2_reads), NULL, 0); |
| 8795 session_deps.socket_factory.AddSocketDataProvider(&data3); | 8820 session_deps.socket_factory.AddSocketDataProvider(&data3); |
| 8796 | 8821 |
| 8797 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8822 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8798 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 8823 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 8799 | 8824 |
| 8800 // Begin the initial SSL handshake. | 8825 // Begin the initial SSL handshake. |
| 8801 TestOldCompletionCallback callback; | 8826 TestCompletionCallback callback; |
| 8802 int rv = trans->Start(&request_info, &callback, net::BoundNetLog()); | 8827 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
| 8803 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 8828 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
| 8804 | 8829 |
| 8805 // Complete the SSL handshake, which should abort due to requiring a | 8830 // Complete the SSL handshake, which should abort due to requiring a |
| 8806 // client certificate. | 8831 // client certificate. |
| 8807 rv = callback.WaitForResult(); | 8832 rv = callback.WaitForResult(); |
| 8808 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); | 8833 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); |
| 8809 | 8834 |
| 8810 // Indicate that no certificate should be supplied. From the perspective | 8835 // Indicate that no certificate should be supplied. From the perspective |
| 8811 // of SSLClientCertCache, NULL is just as meaningful as a real | 8836 // of SSLClientCertCache, NULL is just as meaningful as a real |
| 8812 // certificate, so this is the same as supply a | 8837 // certificate, so this is the same as supply a |
| 8813 // legitimate-but-unacceptable certificate. | 8838 // legitimate-but-unacceptable certificate. |
| 8814 rv = trans->RestartWithCertificate(NULL, &callback); | 8839 rv = trans->RestartWithCertificate(NULL, callback.callback()); |
| 8815 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 8840 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
| 8816 | 8841 |
| 8817 // Ensure the certificate was added to the client auth cache before | 8842 // Ensure the certificate was added to the client auth cache before |
| 8818 // allowing the connection to continue restarting. | 8843 // allowing the connection to continue restarting. |
| 8819 scoped_refptr<X509Certificate> client_cert; | 8844 scoped_refptr<X509Certificate> client_cert; |
| 8820 ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", | 8845 ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", |
| 8821 &client_cert)); | 8846 &client_cert)); |
| 8822 ASSERT_EQ(NULL, client_cert.get()); | 8847 ASSERT_EQ(NULL, client_cert.get()); |
| 8823 | 8848 |
| 8824 | 8849 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8885 requests[1].method = "GET"; | 8910 requests[1].method = "GET"; |
| 8886 requests[1].load_flags = net::LOAD_NORMAL; | 8911 requests[1].load_flags = net::LOAD_NORMAL; |
| 8887 | 8912 |
| 8888 for (size_t i = 0; i < arraysize(requests); ++i) { | 8913 for (size_t i = 0; i < arraysize(requests); ++i) { |
| 8889 session_deps.socket_factory.ResetNextMockIndexes(); | 8914 session_deps.socket_factory.ResetNextMockIndexes(); |
| 8890 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8915 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8891 scoped_ptr<HttpNetworkTransaction> trans( | 8916 scoped_ptr<HttpNetworkTransaction> trans( |
| 8892 new HttpNetworkTransaction(session)); | 8917 new HttpNetworkTransaction(session)); |
| 8893 | 8918 |
| 8894 // Begin the SSL handshake with the proxy. | 8919 // Begin the SSL handshake with the proxy. |
| 8895 TestOldCompletionCallback callback; | 8920 TestCompletionCallback callback; |
| 8896 int rv = trans->Start(&requests[i], &callback, net::BoundNetLog()); | 8921 int rv = trans->Start( |
| 8922 &requests[i], callback.callback(), net::BoundNetLog()); |
| 8897 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 8923 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
| 8898 | 8924 |
| 8899 // Complete the SSL handshake, which should abort due to requiring a | 8925 // Complete the SSL handshake, which should abort due to requiring a |
| 8900 // client certificate. | 8926 // client certificate. |
| 8901 rv = callback.WaitForResult(); | 8927 rv = callback.WaitForResult(); |
| 8902 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); | 8928 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); |
| 8903 | 8929 |
| 8904 // Indicate that no certificate should be supplied. From the perspective | 8930 // Indicate that no certificate should be supplied. From the perspective |
| 8905 // of SSLClientCertCache, NULL is just as meaningful as a real | 8931 // of SSLClientCertCache, NULL is just as meaningful as a real |
| 8906 // certificate, so this is the same as supply a | 8932 // certificate, so this is the same as supply a |
| 8907 // legitimate-but-unacceptable certificate. | 8933 // legitimate-but-unacceptable certificate. |
| 8908 rv = trans->RestartWithCertificate(NULL, &callback); | 8934 rv = trans->RestartWithCertificate(NULL, callback.callback()); |
| 8909 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 8935 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
| 8910 | 8936 |
| 8911 // Ensure the certificate was added to the client auth cache before | 8937 // Ensure the certificate was added to the client auth cache before |
| 8912 // allowing the connection to continue restarting. | 8938 // allowing the connection to continue restarting. |
| 8913 scoped_refptr<X509Certificate> client_cert; | 8939 scoped_refptr<X509Certificate> client_cert; |
| 8914 ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup("proxy:70", | 8940 ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup("proxy:70", |
| 8915 &client_cert)); | 8941 &client_cert)); |
| 8916 ASSERT_EQ(NULL, client_cert.get()); | 8942 ASSERT_EQ(NULL, client_cert.get()); |
| 8917 // Ensure the certificate was NOT cached for the endpoint. This only | 8943 // Ensure the certificate was NOT cached for the endpoint. This only |
| 8918 // applies to HTTPS requests, but is fine to check for HTTP requests. | 8944 // applies to HTTPS requests, but is fine to check for HTTP requests. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9014 MockRead(true, 0, 7), | 9040 MockRead(true, 0, 7), |
| 9015 }; | 9041 }; |
| 9016 | 9042 |
| 9017 scoped_refptr<OrderedSocketData> spdy_data( | 9043 scoped_refptr<OrderedSocketData> spdy_data( |
| 9018 new OrderedSocketData( | 9044 new OrderedSocketData( |
| 9019 spdy_reads, arraysize(spdy_reads), | 9045 spdy_reads, arraysize(spdy_reads), |
| 9020 spdy_writes, arraysize(spdy_writes))); | 9046 spdy_writes, arraysize(spdy_writes))); |
| 9021 session_deps.socket_factory.AddSocketDataProvider(spdy_data); | 9047 session_deps.socket_factory.AddSocketDataProvider(spdy_data); |
| 9022 | 9048 |
| 9023 TestCompletionCallback callback; | 9049 TestCompletionCallback callback; |
| 9024 TestOldCompletionCallback old_callback; | |
| 9025 HttpRequestInfo request1; | 9050 HttpRequestInfo request1; |
| 9026 request1.method = "GET"; | 9051 request1.method = "GET"; |
| 9027 request1.url = GURL("https://www.google.com/"); | 9052 request1.url = GURL("https://www.google.com/"); |
| 9028 request1.load_flags = 0; | 9053 request1.load_flags = 0; |
| 9029 HttpNetworkTransaction trans1(session); | 9054 HttpNetworkTransaction trans1(session); |
| 9030 | 9055 |
| 9031 int rv = trans1.Start(&request1, &old_callback, BoundNetLog()); | 9056 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); |
| 9032 EXPECT_EQ(ERR_IO_PENDING, rv); | 9057 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9033 EXPECT_EQ(OK, old_callback.WaitForResult()); | 9058 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9034 | 9059 |
| 9035 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 9060 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
| 9036 ASSERT_TRUE(response != NULL); | 9061 ASSERT_TRUE(response != NULL); |
| 9037 ASSERT_TRUE(response->headers != NULL); | 9062 ASSERT_TRUE(response->headers != NULL); |
| 9038 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9063 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9039 | 9064 |
| 9040 std::string response_data; | 9065 std::string response_data; |
| 9041 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 9066 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
| 9042 EXPECT_EQ("hello!", response_data); | 9067 EXPECT_EQ("hello!", response_data); |
| 9043 | 9068 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 9056 // (www.google.com, 443). | 9081 // (www.google.com, 443). |
| 9057 IPPoolingAddAlias(&host_resolver, &pool_peer, "www.google.com", 443, | 9082 IPPoolingAddAlias(&host_resolver, &pool_peer, "www.google.com", 443, |
| 9058 "127.0.0.1"); | 9083 "127.0.0.1"); |
| 9059 | 9084 |
| 9060 HttpRequestInfo request2; | 9085 HttpRequestInfo request2; |
| 9061 request2.method = "GET"; | 9086 request2.method = "GET"; |
| 9062 request2.url = GURL("https://www.gmail.com/"); | 9087 request2.url = GURL("https://www.gmail.com/"); |
| 9063 request2.load_flags = 0; | 9088 request2.load_flags = 0; |
| 9064 HttpNetworkTransaction trans2(session); | 9089 HttpNetworkTransaction trans2(session); |
| 9065 | 9090 |
| 9066 rv = trans2.Start(&request2, &old_callback, BoundNetLog()); | 9091 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); |
| 9067 EXPECT_EQ(ERR_IO_PENDING, rv); | 9092 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9068 EXPECT_EQ(OK, old_callback.WaitForResult()); | 9093 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9069 | 9094 |
| 9070 response = trans2.GetResponseInfo(); | 9095 response = trans2.GetResponseInfo(); |
| 9071 ASSERT_TRUE(response != NULL); | 9096 ASSERT_TRUE(response != NULL); |
| 9072 ASSERT_TRUE(response->headers != NULL); | 9097 ASSERT_TRUE(response->headers != NULL); |
| 9073 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9098 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9074 EXPECT_TRUE(response->was_fetched_via_spdy); | 9099 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 9075 EXPECT_TRUE(response->was_npn_negotiated); | 9100 EXPECT_TRUE(response->was_npn_negotiated); |
| 9076 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 9101 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
| 9077 EXPECT_EQ("hello!", response_data); | 9102 EXPECT_EQ("hello!", response_data); |
| 9078 | 9103 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9174 spdy_writes, arraysize(spdy_writes))); | 9199 spdy_writes, arraysize(spdy_writes))); |
| 9175 session_deps.socket_factory.AddSocketDataProvider(spdy_data); | 9200 session_deps.socket_factory.AddSocketDataProvider(spdy_data); |
| 9176 | 9201 |
| 9177 TestCompletionCallback callback; | 9202 TestCompletionCallback callback; |
| 9178 HttpRequestInfo request1; | 9203 HttpRequestInfo request1; |
| 9179 request1.method = "GET"; | 9204 request1.method = "GET"; |
| 9180 request1.url = GURL("https://www.google.com/"); | 9205 request1.url = GURL("https://www.google.com/"); |
| 9181 request1.load_flags = 0; | 9206 request1.load_flags = 0; |
| 9182 HttpNetworkTransaction trans1(session); | 9207 HttpNetworkTransaction trans1(session); |
| 9183 | 9208 |
| 9184 TestOldCompletionCallback old_callback; | 9209 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); |
| 9185 int rv = trans1.Start(&request1, &old_callback, BoundNetLog()); | |
| 9186 EXPECT_EQ(ERR_IO_PENDING, rv); | 9210 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9187 EXPECT_EQ(OK, old_callback.WaitForResult()); | 9211 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9188 | 9212 |
| 9189 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 9213 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
| 9190 ASSERT_TRUE(response != NULL); | 9214 ASSERT_TRUE(response != NULL); |
| 9191 ASSERT_TRUE(response->headers != NULL); | 9215 ASSERT_TRUE(response->headers != NULL); |
| 9192 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9216 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9193 | 9217 |
| 9194 std::string response_data; | 9218 std::string response_data; |
| 9195 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 9219 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
| 9196 EXPECT_EQ("hello!", response_data); | 9220 EXPECT_EQ("hello!", response_data); |
| 9197 | 9221 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 9209 request2.url = GURL("https://www.gmail.com/"); | 9233 request2.url = GURL("https://www.gmail.com/"); |
| 9210 request2.load_flags = 0; | 9234 request2.load_flags = 0; |
| 9211 HttpNetworkTransaction trans2(session); | 9235 HttpNetworkTransaction trans2(session); |
| 9212 | 9236 |
| 9213 // MockHostResolver returns 127.0.0.1, port 443 for https://www.google.com/ | 9237 // MockHostResolver returns 127.0.0.1, port 443 for https://www.google.com/ |
| 9214 // and https://www.gmail.com/. Add 127.0.0.1 as alias for host_port_pair: | 9238 // and https://www.gmail.com/. Add 127.0.0.1 as alias for host_port_pair: |
| 9215 // (www.google.com, 443). | 9239 // (www.google.com, 443). |
| 9216 IPPoolingAddAlias(host_resolver.GetMockHostResolver(), &pool_peer, | 9240 IPPoolingAddAlias(host_resolver.GetMockHostResolver(), &pool_peer, |
| 9217 "www.google.com", 443, "127.0.0.1"); | 9241 "www.google.com", 443, "127.0.0.1"); |
| 9218 | 9242 |
| 9219 rv = trans2.Start(&request2, &old_callback, BoundNetLog()); | 9243 rv = trans2.Start(&request2, callback.callback(), BoundNetLog()); |
| 9220 EXPECT_EQ(ERR_IO_PENDING, rv); | 9244 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9221 EXPECT_EQ(OK, old_callback.WaitForResult()); | 9245 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9222 | 9246 |
| 9223 response = trans2.GetResponseInfo(); | 9247 response = trans2.GetResponseInfo(); |
| 9224 ASSERT_TRUE(response != NULL); | 9248 ASSERT_TRUE(response != NULL); |
| 9225 ASSERT_TRUE(response->headers != NULL); | 9249 ASSERT_TRUE(response->headers != NULL); |
| 9226 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9250 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9227 EXPECT_TRUE(response->was_fetched_via_spdy); | 9251 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 9228 EXPECT_TRUE(response->was_npn_negotiated); | 9252 EXPECT_TRUE(response->was_npn_negotiated); |
| 9229 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); | 9253 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); |
| 9230 EXPECT_EQ("hello!", response_data); | 9254 EXPECT_EQ("hello!", response_data); |
| 9231 | 9255 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9363 StaticSocketDataProvider http_data(http_read, arraysize(http_read), | 9387 StaticSocketDataProvider http_data(http_read, arraysize(http_read), |
| 9364 http_write, arraysize(http_write)); | 9388 http_write, arraysize(http_write)); |
| 9365 session_deps.socket_factory.AddSocketDataProvider(&http_data); | 9389 session_deps.socket_factory.AddSocketDataProvider(&http_data); |
| 9366 | 9390 |
| 9367 HostPortPair host_port_pair_a("www.a.com", 443); | 9391 HostPortPair host_port_pair_a("www.a.com", 443); |
| 9368 HostPortProxyPair host_port_proxy_pair_a( | 9392 HostPortProxyPair host_port_proxy_pair_a( |
| 9369 host_port_pair_a, ProxyServer::Direct()); | 9393 host_port_pair_a, ProxyServer::Direct()); |
| 9370 EXPECT_FALSE( | 9394 EXPECT_FALSE( |
| 9371 session->spdy_session_pool()->HasSession(host_port_proxy_pair_a)); | 9395 session->spdy_session_pool()->HasSession(host_port_proxy_pair_a)); |
| 9372 | 9396 |
| 9373 TestOldCompletionCallback callback; | 9397 TestCompletionCallback callback; |
| 9374 HttpRequestInfo request1; | 9398 HttpRequestInfo request1; |
| 9375 request1.method = "GET"; | 9399 request1.method = "GET"; |
| 9376 request1.url = GURL("https://www.a.com/"); | 9400 request1.url = GURL("https://www.a.com/"); |
| 9377 request1.load_flags = 0; | 9401 request1.load_flags = 0; |
| 9378 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 9402 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 9379 | 9403 |
| 9380 int rv = trans->Start(&request1, &callback, BoundNetLog()); | 9404 int rv = trans->Start(&request1, callback.callback(), BoundNetLog()); |
| 9381 EXPECT_EQ(ERR_IO_PENDING, rv); | 9405 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9382 EXPECT_EQ(OK, callback.WaitForResult()); | 9406 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9383 | 9407 |
| 9384 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9408 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 9385 ASSERT_TRUE(response != NULL); | 9409 ASSERT_TRUE(response != NULL); |
| 9386 ASSERT_TRUE(response->headers != NULL); | 9410 ASSERT_TRUE(response->headers != NULL); |
| 9387 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9411 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9388 EXPECT_TRUE(response->was_fetched_via_spdy); | 9412 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 9389 EXPECT_TRUE(response->was_npn_negotiated); | 9413 EXPECT_TRUE(response->was_npn_negotiated); |
| 9390 | 9414 |
| 9391 std::string response_data; | 9415 std::string response_data; |
| 9392 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9416 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9393 EXPECT_EQ("hello!", response_data); | 9417 EXPECT_EQ("hello!", response_data); |
| 9394 trans.reset(); | 9418 trans.reset(); |
| 9395 EXPECT_TRUE( | 9419 EXPECT_TRUE( |
| 9396 session->spdy_session_pool()->HasSession(host_port_proxy_pair_a)); | 9420 session->spdy_session_pool()->HasSession(host_port_proxy_pair_a)); |
| 9397 | 9421 |
| 9398 HostPortPair host_port_pair_b("www.b.com", 443); | 9422 HostPortPair host_port_pair_b("www.b.com", 443); |
| 9399 HostPortProxyPair host_port_proxy_pair_b( | 9423 HostPortProxyPair host_port_proxy_pair_b( |
| 9400 host_port_pair_b, ProxyServer::Direct()); | 9424 host_port_pair_b, ProxyServer::Direct()); |
| 9401 EXPECT_FALSE( | 9425 EXPECT_FALSE( |
| 9402 session->spdy_session_pool()->HasSession(host_port_proxy_pair_b)); | 9426 session->spdy_session_pool()->HasSession(host_port_proxy_pair_b)); |
| 9403 HttpRequestInfo request2; | 9427 HttpRequestInfo request2; |
| 9404 request2.method = "GET"; | 9428 request2.method = "GET"; |
| 9405 request2.url = GURL("https://www.b.com/"); | 9429 request2.url = GURL("https://www.b.com/"); |
| 9406 request2.load_flags = 0; | 9430 request2.load_flags = 0; |
| 9407 trans.reset(new HttpNetworkTransaction(session)); | 9431 trans.reset(new HttpNetworkTransaction(session)); |
| 9408 | 9432 |
| 9409 rv = trans->Start(&request2, &callback, BoundNetLog()); | 9433 rv = trans->Start(&request2, callback.callback(), BoundNetLog()); |
| 9410 EXPECT_EQ(ERR_IO_PENDING, rv); | 9434 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9411 EXPECT_EQ(OK, callback.WaitForResult()); | 9435 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9412 | 9436 |
| 9413 response = trans->GetResponseInfo(); | 9437 response = trans->GetResponseInfo(); |
| 9414 ASSERT_TRUE(response != NULL); | 9438 ASSERT_TRUE(response != NULL); |
| 9415 ASSERT_TRUE(response->headers != NULL); | 9439 ASSERT_TRUE(response->headers != NULL); |
| 9416 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9440 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9417 EXPECT_TRUE(response->was_fetched_via_spdy); | 9441 EXPECT_TRUE(response->was_fetched_via_spdy); |
| 9418 EXPECT_TRUE(response->was_npn_negotiated); | 9442 EXPECT_TRUE(response->was_npn_negotiated); |
| 9419 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9443 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9420 EXPECT_EQ("hello!", response_data); | 9444 EXPECT_EQ("hello!", response_data); |
| 9421 EXPECT_FALSE( | 9445 EXPECT_FALSE( |
| 9422 session->spdy_session_pool()->HasSession(host_port_proxy_pair_a)); | 9446 session->spdy_session_pool()->HasSession(host_port_proxy_pair_a)); |
| 9423 EXPECT_TRUE( | 9447 EXPECT_TRUE( |
| 9424 session->spdy_session_pool()->HasSession(host_port_proxy_pair_b)); | 9448 session->spdy_session_pool()->HasSession(host_port_proxy_pair_b)); |
| 9425 | 9449 |
| 9426 HostPortPair host_port_pair_a1("www.a.com", 80); | 9450 HostPortPair host_port_pair_a1("www.a.com", 80); |
| 9427 HostPortProxyPair host_port_proxy_pair_a1( | 9451 HostPortProxyPair host_port_proxy_pair_a1( |
| 9428 host_port_pair_a1, ProxyServer::Direct()); | 9452 host_port_pair_a1, ProxyServer::Direct()); |
| 9429 EXPECT_FALSE( | 9453 EXPECT_FALSE( |
| 9430 session->spdy_session_pool()->HasSession(host_port_proxy_pair_a1)); | 9454 session->spdy_session_pool()->HasSession(host_port_proxy_pair_a1)); |
| 9431 HttpRequestInfo request3; | 9455 HttpRequestInfo request3; |
| 9432 request3.method = "GET"; | 9456 request3.method = "GET"; |
| 9433 request3.url = GURL("http://www.a.com/"); | 9457 request3.url = GURL("http://www.a.com/"); |
| 9434 request3.load_flags = 0; | 9458 request3.load_flags = 0; |
| 9435 trans.reset(new HttpNetworkTransaction(session)); | 9459 trans.reset(new HttpNetworkTransaction(session)); |
| 9436 | 9460 |
| 9437 rv = trans->Start(&request3, &callback, BoundNetLog()); | 9461 rv = trans->Start(&request3, callback.callback(), BoundNetLog()); |
| 9438 EXPECT_EQ(ERR_IO_PENDING, rv); | 9462 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9439 EXPECT_EQ(OK, callback.WaitForResult()); | 9463 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9440 | 9464 |
| 9441 response = trans->GetResponseInfo(); | 9465 response = trans->GetResponseInfo(); |
| 9442 ASSERT_TRUE(response != NULL); | 9466 ASSERT_TRUE(response != NULL); |
| 9443 ASSERT_TRUE(response->headers != NULL); | 9467 ASSERT_TRUE(response->headers != NULL); |
| 9444 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9468 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9445 EXPECT_FALSE(response->was_fetched_via_spdy); | 9469 EXPECT_FALSE(response->was_fetched_via_spdy); |
| 9446 EXPECT_FALSE(response->was_npn_negotiated); | 9470 EXPECT_FALSE(response->was_npn_negotiated); |
| 9447 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 9471 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 9448 EXPECT_EQ("hello!", response_data); | 9472 EXPECT_EQ("hello!", response_data); |
| 9449 EXPECT_FALSE( | 9473 EXPECT_FALSE( |
| 9450 session->spdy_session_pool()->HasSession(host_port_proxy_pair_a)); | 9474 session->spdy_session_pool()->HasSession(host_port_proxy_pair_a)); |
| 9451 EXPECT_FALSE( | 9475 EXPECT_FALSE( |
| 9452 session->spdy_session_pool()->HasSession(host_port_proxy_pair_b)); | 9476 session->spdy_session_pool()->HasSession(host_port_proxy_pair_b)); |
| 9453 | 9477 |
| 9454 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 9478 HttpStreamFactory::set_next_protos(std::vector<std::string>()); |
| 9455 ClientSocketPoolManager::set_max_sockets_per_pool(old_max_sockets_per_pool); | 9479 ClientSocketPoolManager::set_max_sockets_per_pool(old_max_sockets_per_pool); |
| 9456 ClientSocketPoolManager::set_max_sockets_per_proxy_server( | 9480 ClientSocketPoolManager::set_max_sockets_per_proxy_server( |
| 9457 old_max_sockets_per_proxy_server); | 9481 old_max_sockets_per_proxy_server); |
| 9458 ClientSocketPoolManager::set_max_sockets_per_group(old_max_sockets_per_group); | 9482 ClientSocketPoolManager::set_max_sockets_per_group(old_max_sockets_per_group); |
| 9459 } | 9483 } |
| 9460 | 9484 |
| 9461 } // namespace net | 9485 } // namespace net |
| OLD | NEW |