| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 ReplaceChars(double_quote_headers, "\"", "'", headers); | 130 ReplaceChars(double_quote_headers, "\"", "'", headers); |
| 131 return true; | 131 return true; |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace | 134 } // namespace |
| 135 | 135 |
| 136 namespace net { | 136 namespace net { |
| 137 | 137 |
| 138 namespace { | 138 namespace { |
| 139 | 139 |
| 140 // Helper to manage the lifetimes of the dependencies for a | 140 HttpNetworkSession* CreateSession(SpdySessionDependencies* session_deps) { |
| 141 // HttpNetworkTransaction. | 141 return SpdySessionDependencies::SpdyCreateSession(session_deps); |
| 142 struct SessionDependencies { | |
| 143 // Default set of dependencies -- "null" proxy service. | |
| 144 SessionDependencies() | |
| 145 : host_resolver(new MockHostResolver), | |
| 146 cert_verifier(new MockCertVerifier), | |
| 147 proxy_service(ProxyService::CreateDirect()), | |
| 148 ssl_config_service(new SSLConfigServiceDefaults), | |
| 149 http_auth_handler_factory( | |
| 150 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), | |
| 151 net_log(NULL) {} | |
| 152 | |
| 153 // Custom proxy service dependency. | |
| 154 explicit SessionDependencies(ProxyService* proxy_service) | |
| 155 : host_resolver(new MockHostResolver), | |
| 156 cert_verifier(new MockCertVerifier), | |
| 157 proxy_service(proxy_service), | |
| 158 ssl_config_service(new SSLConfigServiceDefaults), | |
| 159 http_auth_handler_factory( | |
| 160 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())), | |
| 161 net_log(NULL) {} | |
| 162 | |
| 163 scoped_ptr<MockHostResolverBase> host_resolver; | |
| 164 scoped_ptr<CertVerifier> cert_verifier; | |
| 165 scoped_ptr<ProxyService> proxy_service; | |
| 166 scoped_refptr<SSLConfigService> ssl_config_service; | |
| 167 MockClientSocketFactory socket_factory; | |
| 168 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory; | |
| 169 HttpServerPropertiesImpl http_server_properties; | |
| 170 NetLog* net_log; | |
| 171 std::string trusted_spdy_proxy; | |
| 172 }; | |
| 173 | |
| 174 HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { | |
| 175 net::HttpNetworkSession::Params params; | |
| 176 params.client_socket_factory = &session_deps->socket_factory; | |
| 177 params.host_resolver = session_deps->host_resolver.get(); | |
| 178 params.cert_verifier = session_deps->cert_verifier.get(); | |
| 179 params.proxy_service = session_deps->proxy_service.get(); | |
| 180 params.ssl_config_service = session_deps->ssl_config_service; | |
| 181 params.http_auth_handler_factory = | |
| 182 session_deps->http_auth_handler_factory.get(); | |
| 183 params.http_server_properties = &session_deps->http_server_properties; | |
| 184 params.net_log = session_deps->net_log; | |
| 185 params.trusted_spdy_proxy = session_deps->trusted_spdy_proxy; | |
| 186 HttpNetworkSession* http_session = new HttpNetworkSession(params); | |
| 187 SpdySessionPoolPeer pool_peer(http_session->spdy_session_pool()); | |
| 188 pool_peer.EnableSendingInitialSettings(false); | |
| 189 return http_session; | |
| 190 } | 142 } |
| 191 | 143 |
| 192 } // namespace | 144 } // namespace |
| 193 | 145 |
| 194 class HttpNetworkTransactionSpdy2Test : public PlatformTest { | 146 class HttpNetworkTransactionSpdy2Test : public PlatformTest { |
| 195 protected: | 147 protected: |
| 196 struct SimpleGetHelperResult { | 148 struct SimpleGetHelperResult { |
| 197 int rv; | 149 int rv; |
| 198 std::string status_line; | 150 std::string status_line; |
| 199 std::string response_data; | 151 std::string response_data; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 224 | 176 |
| 225 SimpleGetHelperResult SimpleGetHelperForData(StaticSocketDataProvider* data[], | 177 SimpleGetHelperResult SimpleGetHelperForData(StaticSocketDataProvider* data[], |
| 226 size_t data_count) { | 178 size_t data_count) { |
| 227 SimpleGetHelperResult out; | 179 SimpleGetHelperResult out; |
| 228 | 180 |
| 229 HttpRequestInfo request; | 181 HttpRequestInfo request; |
| 230 request.method = "GET"; | 182 request.method = "GET"; |
| 231 request.url = GURL("http://www.google.com/"); | 183 request.url = GURL("http://www.google.com/"); |
| 232 request.load_flags = 0; | 184 request.load_flags = 0; |
| 233 | 185 |
| 234 SessionDependencies session_deps; | 186 SpdySessionDependencies session_deps; |
| 235 scoped_ptr<HttpTransaction> trans( | 187 scoped_ptr<HttpTransaction> trans( |
| 236 new HttpNetworkTransaction(CreateSession(&session_deps))); | 188 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 237 | 189 |
| 238 for (size_t i = 0; i < data_count; ++i) { | 190 for (size_t i = 0; i < data_count; ++i) { |
| 239 session_deps.socket_factory.AddSocketDataProvider(data[i]); | 191 session_deps.socket_factory->AddSocketDataProvider(data[i]); |
| 240 } | 192 } |
| 241 | 193 |
| 242 TestCompletionCallback callback; | 194 TestCompletionCallback callback; |
| 243 | 195 |
| 244 CapturingBoundNetLog log; | 196 CapturingBoundNetLog log; |
| 245 EXPECT_TRUE(log.bound().IsLoggingAllEvents()); | 197 EXPECT_TRUE(log.bound().IsLoggingAllEvents()); |
| 246 int rv = trans->Start(&request, callback.callback(), log.bound()); | 198 int rv = trans->Start(&request, callback.callback(), log.bound()); |
| 247 EXPECT_EQ(ERR_IO_PENDING, rv); | 199 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 248 | 200 |
| 249 out.rv = callback.WaitForResult(); | 201 out.rv = callback.WaitForResult(); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 EXPECT_FALSE(auth_challenge->is_proxy); | 415 EXPECT_FALSE(auth_challenge->is_proxy); |
| 464 EXPECT_EQ("172.22.68.17:80", auth_challenge->challenger.ToString()); | 416 EXPECT_EQ("172.22.68.17:80", auth_challenge->challenger.ToString()); |
| 465 EXPECT_EQ(std::string(), auth_challenge->realm); | 417 EXPECT_EQ(std::string(), auth_challenge->realm); |
| 466 EXPECT_EQ("ntlm", auth_challenge->scheme); | 418 EXPECT_EQ("ntlm", auth_challenge->scheme); |
| 467 return true; | 419 return true; |
| 468 } | 420 } |
| 469 | 421 |
| 470 } // namespace | 422 } // namespace |
| 471 | 423 |
| 472 TEST_F(HttpNetworkTransactionSpdy2Test, Basic) { | 424 TEST_F(HttpNetworkTransactionSpdy2Test, Basic) { |
| 473 SessionDependencies session_deps; | 425 SpdySessionDependencies session_deps; |
| 474 scoped_ptr<HttpTransaction> trans( | 426 scoped_ptr<HttpTransaction> trans( |
| 475 new HttpNetworkTransaction(CreateSession(&session_deps))); | 427 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 476 } | 428 } |
| 477 | 429 |
| 478 TEST_F(HttpNetworkTransactionSpdy2Test, SimpleGET) { | 430 TEST_F(HttpNetworkTransactionSpdy2Test, SimpleGET) { |
| 479 MockRead data_reads[] = { | 431 MockRead data_reads[] = { |
| 480 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | 432 MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
| 481 MockRead("hello world"), | 433 MockRead("hello world"), |
| 482 MockRead(SYNCHRONOUS, OK), | 434 MockRead(SYNCHRONOUS, OK), |
| 483 }; | 435 }; |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 MockRead("Location: http://good.com/\r\n"), | 710 MockRead("Location: http://good.com/\r\n"), |
| 759 MockRead("Content-Length: 0\r\n\r\n"), | 711 MockRead("Content-Length: 0\r\n\r\n"), |
| 760 MockRead(SYNCHRONOUS, OK), | 712 MockRead(SYNCHRONOUS, OK), |
| 761 }; | 713 }; |
| 762 | 714 |
| 763 HttpRequestInfo request; | 715 HttpRequestInfo request; |
| 764 request.method = "GET"; | 716 request.method = "GET"; |
| 765 request.url = GURL("http://redirect.com/"); | 717 request.url = GURL("http://redirect.com/"); |
| 766 request.load_flags = 0; | 718 request.load_flags = 0; |
| 767 | 719 |
| 768 SessionDependencies session_deps; | 720 SpdySessionDependencies session_deps; |
| 769 scoped_ptr<HttpTransaction> trans( | 721 scoped_ptr<HttpTransaction> trans( |
| 770 new HttpNetworkTransaction(CreateSession(&session_deps))); | 722 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 771 | 723 |
| 772 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 724 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 773 session_deps.socket_factory.AddSocketDataProvider(&data); | 725 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 774 | 726 |
| 775 TestCompletionCallback callback; | 727 TestCompletionCallback callback; |
| 776 | 728 |
| 777 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 729 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 778 EXPECT_EQ(ERR_IO_PENDING, rv); | 730 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 779 | 731 |
| 780 EXPECT_EQ(OK, callback.WaitForResult()); | 732 EXPECT_EQ(OK, callback.WaitForResult()); |
| 781 | 733 |
| 782 const HttpResponseInfo* response = trans->GetResponseInfo(); | 734 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 783 ASSERT_TRUE(response != NULL && response->headers != NULL); | 735 ASSERT_TRUE(response != NULL && response->headers != NULL); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 802 } | 754 } |
| 803 | 755 |
| 804 // Do a request using the HEAD method. Verify that we don't try to read the | 756 // Do a request using the HEAD method. Verify that we don't try to read the |
| 805 // message body (since HEAD has none). | 757 // message body (since HEAD has none). |
| 806 TEST_F(HttpNetworkTransactionSpdy2Test, Head) { | 758 TEST_F(HttpNetworkTransactionSpdy2Test, Head) { |
| 807 HttpRequestInfo request; | 759 HttpRequestInfo request; |
| 808 request.method = "HEAD"; | 760 request.method = "HEAD"; |
| 809 request.url = GURL("http://www.google.com/"); | 761 request.url = GURL("http://www.google.com/"); |
| 810 request.load_flags = 0; | 762 request.load_flags = 0; |
| 811 | 763 |
| 812 SessionDependencies session_deps; | 764 SpdySessionDependencies session_deps; |
| 813 scoped_ptr<HttpTransaction> trans( | 765 scoped_ptr<HttpTransaction> trans( |
| 814 new HttpNetworkTransaction(CreateSession(&session_deps))); | 766 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 815 | 767 |
| 816 MockWrite data_writes1[] = { | 768 MockWrite data_writes1[] = { |
| 817 MockWrite("HEAD / HTTP/1.1\r\n" | 769 MockWrite("HEAD / HTTP/1.1\r\n" |
| 818 "Host: www.google.com\r\n" | 770 "Host: www.google.com\r\n" |
| 819 "Connection: keep-alive\r\n" | 771 "Connection: keep-alive\r\n" |
| 820 "Content-Length: 0\r\n\r\n"), | 772 "Content-Length: 0\r\n\r\n"), |
| 821 }; | 773 }; |
| 822 MockRead data_reads1[] = { | 774 MockRead data_reads1[] = { |
| 823 MockRead("HTTP/1.1 404 Not Found\r\n"), | 775 MockRead("HTTP/1.1 404 Not Found\r\n"), |
| 824 MockRead("Server: Blah\r\n"), | 776 MockRead("Server: Blah\r\n"), |
| 825 MockRead("Content-Length: 1234\r\n\r\n"), | 777 MockRead("Content-Length: 1234\r\n\r\n"), |
| 826 | 778 |
| 827 // No response body because the test stops reading here. | 779 // No response body because the test stops reading here. |
| 828 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. | 780 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. |
| 829 }; | 781 }; |
| 830 | 782 |
| 831 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 783 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 832 data_writes1, arraysize(data_writes1)); | 784 data_writes1, arraysize(data_writes1)); |
| 833 session_deps.socket_factory.AddSocketDataProvider(&data1); | 785 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 834 | 786 |
| 835 TestCompletionCallback callback1; | 787 TestCompletionCallback callback1; |
| 836 | 788 |
| 837 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 789 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 838 EXPECT_EQ(ERR_IO_PENDING, rv); | 790 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 839 | 791 |
| 840 rv = callback1.WaitForResult(); | 792 rv = callback1.WaitForResult(); |
| 841 EXPECT_EQ(OK, rv); | 793 EXPECT_EQ(OK, rv); |
| 842 | 794 |
| 843 const HttpResponseInfo* response = trans->GetResponseInfo(); | 795 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 857 | 809 |
| 858 // Reading should give EOF right away, since there is no message body | 810 // Reading should give EOF right away, since there is no message body |
| 859 // (despite non-zero content-length). | 811 // (despite non-zero content-length). |
| 860 std::string response_data; | 812 std::string response_data; |
| 861 rv = ReadTransaction(trans.get(), &response_data); | 813 rv = ReadTransaction(trans.get(), &response_data); |
| 862 EXPECT_EQ(OK, rv); | 814 EXPECT_EQ(OK, rv); |
| 863 EXPECT_EQ("", response_data); | 815 EXPECT_EQ("", response_data); |
| 864 } | 816 } |
| 865 | 817 |
| 866 TEST_F(HttpNetworkTransactionSpdy2Test, ReuseConnection) { | 818 TEST_F(HttpNetworkTransactionSpdy2Test, ReuseConnection) { |
| 867 SessionDependencies session_deps; | 819 SpdySessionDependencies session_deps; |
| 868 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 820 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 869 | 821 |
| 870 MockRead data_reads[] = { | 822 MockRead data_reads[] = { |
| 871 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), | 823 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), |
| 872 MockRead("hello"), | 824 MockRead("hello"), |
| 873 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), | 825 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), |
| 874 MockRead("world"), | 826 MockRead("world"), |
| 875 MockRead(SYNCHRONOUS, OK), | 827 MockRead(SYNCHRONOUS, OK), |
| 876 }; | 828 }; |
| 877 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 829 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 878 session_deps.socket_factory.AddSocketDataProvider(&data); | 830 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 879 | 831 |
| 880 const char* const kExpectedResponseData[] = { | 832 const char* const kExpectedResponseData[] = { |
| 881 "hello", "world" | 833 "hello", "world" |
| 882 }; | 834 }; |
| 883 | 835 |
| 884 for (int i = 0; i < 2; ++i) { | 836 for (int i = 0; i < 2; ++i) { |
| 885 HttpRequestInfo request; | 837 HttpRequestInfo request; |
| 886 request.method = "GET"; | 838 request.method = "GET"; |
| 887 request.url = GURL("http://www.google.com/"); | 839 request.url = GURL("http://www.google.com/"); |
| 888 request.load_flags = 0; | 840 request.load_flags = 0; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 914 scoped_refptr<UploadData> upload_data(new UploadData()); | 866 scoped_refptr<UploadData> upload_data(new UploadData()); |
| 915 upload_data->AppendBytes("foo", 3); | 867 upload_data->AppendBytes("foo", 3); |
| 916 UploadDataStream upload_data_stream(upload_data); | 868 UploadDataStream upload_data_stream(upload_data); |
| 917 | 869 |
| 918 HttpRequestInfo request; | 870 HttpRequestInfo request; |
| 919 request.method = "POST"; | 871 request.method = "POST"; |
| 920 request.url = GURL("http://www.foo.com/"); | 872 request.url = GURL("http://www.foo.com/"); |
| 921 request.upload_data_stream = &upload_data_stream; | 873 request.upload_data_stream = &upload_data_stream; |
| 922 request.load_flags = 0; | 874 request.load_flags = 0; |
| 923 | 875 |
| 924 SessionDependencies session_deps; | 876 SpdySessionDependencies session_deps; |
| 925 scoped_ptr<HttpTransaction> trans( | 877 scoped_ptr<HttpTransaction> trans( |
| 926 new HttpNetworkTransaction(CreateSession(&session_deps))); | 878 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 927 | 879 |
| 928 MockRead data_reads[] = { | 880 MockRead data_reads[] = { |
| 929 MockRead("HTTP/1.0 100 Continue\r\n\r\n"), | 881 MockRead("HTTP/1.0 100 Continue\r\n\r\n"), |
| 930 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | 882 MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
| 931 MockRead("hello world"), | 883 MockRead("hello world"), |
| 932 MockRead(SYNCHRONOUS, OK), | 884 MockRead(SYNCHRONOUS, OK), |
| 933 }; | 885 }; |
| 934 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 886 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 935 session_deps.socket_factory.AddSocketDataProvider(&data); | 887 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 936 | 888 |
| 937 TestCompletionCallback callback; | 889 TestCompletionCallback callback; |
| 938 | 890 |
| 939 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 891 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 940 EXPECT_EQ(ERR_IO_PENDING, rv); | 892 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 941 | 893 |
| 942 rv = callback.WaitForResult(); | 894 rv = callback.WaitForResult(); |
| 943 EXPECT_EQ(OK, rv); | 895 EXPECT_EQ(OK, rv); |
| 944 | 896 |
| 945 const HttpResponseInfo* response = trans->GetResponseInfo(); | 897 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 956 | 908 |
| 957 // This test is almost the same as Ignores100 above, but the response contains | 909 // This test is almost the same as Ignores100 above, but the response contains |
| 958 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is | 910 // a 102 instead of a 100. Also, instead of HTTP/1.0 the response is |
| 959 // HTTP/1.1 and the two status headers are read in one read. | 911 // HTTP/1.1 and the two status headers are read in one read. |
| 960 TEST_F(HttpNetworkTransactionSpdy2Test, Ignores1xx) { | 912 TEST_F(HttpNetworkTransactionSpdy2Test, Ignores1xx) { |
| 961 HttpRequestInfo request; | 913 HttpRequestInfo request; |
| 962 request.method = "GET"; | 914 request.method = "GET"; |
| 963 request.url = GURL("http://www.foo.com/"); | 915 request.url = GURL("http://www.foo.com/"); |
| 964 request.load_flags = 0; | 916 request.load_flags = 0; |
| 965 | 917 |
| 966 SessionDependencies session_deps; | 918 SpdySessionDependencies session_deps; |
| 967 scoped_ptr<HttpTransaction> trans( | 919 scoped_ptr<HttpTransaction> trans( |
| 968 new HttpNetworkTransaction(CreateSession(&session_deps))); | 920 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 969 | 921 |
| 970 MockRead data_reads[] = { | 922 MockRead data_reads[] = { |
| 971 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n" | 923 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n" |
| 972 "HTTP/1.1 200 OK\r\n\r\n"), | 924 "HTTP/1.1 200 OK\r\n\r\n"), |
| 973 MockRead("hello world"), | 925 MockRead("hello world"), |
| 974 MockRead(SYNCHRONOUS, OK), | 926 MockRead(SYNCHRONOUS, OK), |
| 975 }; | 927 }; |
| 976 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 928 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 977 session_deps.socket_factory.AddSocketDataProvider(&data); | 929 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 978 | 930 |
| 979 TestCompletionCallback callback; | 931 TestCompletionCallback callback; |
| 980 | 932 |
| 981 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 933 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 982 EXPECT_EQ(ERR_IO_PENDING, rv); | 934 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 983 | 935 |
| 984 rv = callback.WaitForResult(); | 936 rv = callback.WaitForResult(); |
| 985 EXPECT_EQ(OK, rv); | 937 EXPECT_EQ(OK, rv); |
| 986 | 938 |
| 987 const HttpResponseInfo* response = trans->GetResponseInfo(); | 939 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 988 ASSERT_TRUE(response != NULL); | 940 ASSERT_TRUE(response != NULL); |
| 989 | 941 |
| 990 EXPECT_TRUE(response->headers != NULL); | 942 EXPECT_TRUE(response->headers != NULL); |
| 991 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 943 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 992 | 944 |
| 993 std::string response_data; | 945 std::string response_data; |
| 994 rv = ReadTransaction(trans.get(), &response_data); | 946 rv = ReadTransaction(trans.get(), &response_data); |
| 995 EXPECT_EQ(OK, rv); | 947 EXPECT_EQ(OK, rv); |
| 996 EXPECT_EQ("hello world", response_data); | 948 EXPECT_EQ("hello world", response_data); |
| 997 } | 949 } |
| 998 | 950 |
| 999 TEST_F(HttpNetworkTransactionSpdy2Test, Incomplete100ThenEOF) { | 951 TEST_F(HttpNetworkTransactionSpdy2Test, Incomplete100ThenEOF) { |
| 1000 HttpRequestInfo request; | 952 HttpRequestInfo request; |
| 1001 request.method = "POST"; | 953 request.method = "POST"; |
| 1002 request.url = GURL("http://www.foo.com/"); | 954 request.url = GURL("http://www.foo.com/"); |
| 1003 request.load_flags = 0; | 955 request.load_flags = 0; |
| 1004 | 956 |
| 1005 SessionDependencies session_deps; | 957 SpdySessionDependencies session_deps; |
| 1006 scoped_ptr<HttpTransaction> trans( | 958 scoped_ptr<HttpTransaction> trans( |
| 1007 new HttpNetworkTransaction(CreateSession(&session_deps))); | 959 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 1008 | 960 |
| 1009 MockRead data_reads[] = { | 961 MockRead data_reads[] = { |
| 1010 MockRead(SYNCHRONOUS, "HTTP/1.0 100 Continue\r\n"), | 962 MockRead(SYNCHRONOUS, "HTTP/1.0 100 Continue\r\n"), |
| 1011 MockRead(ASYNC, 0), | 963 MockRead(ASYNC, 0), |
| 1012 }; | 964 }; |
| 1013 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 965 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 1014 session_deps.socket_factory.AddSocketDataProvider(&data); | 966 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 1015 | 967 |
| 1016 TestCompletionCallback callback; | 968 TestCompletionCallback callback; |
| 1017 | 969 |
| 1018 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 970 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1019 EXPECT_EQ(ERR_IO_PENDING, rv); | 971 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1020 | 972 |
| 1021 rv = callback.WaitForResult(); | 973 rv = callback.WaitForResult(); |
| 1022 EXPECT_EQ(OK, rv); | 974 EXPECT_EQ(OK, rv); |
| 1023 | 975 |
| 1024 std::string response_data; | 976 std::string response_data; |
| 1025 rv = ReadTransaction(trans.get(), &response_data); | 977 rv = ReadTransaction(trans.get(), &response_data); |
| 1026 EXPECT_EQ(OK, rv); | 978 EXPECT_EQ(OK, rv); |
| 1027 EXPECT_EQ("", response_data); | 979 EXPECT_EQ("", response_data); |
| 1028 } | 980 } |
| 1029 | 981 |
| 1030 TEST_F(HttpNetworkTransactionSpdy2Test, EmptyResponse) { | 982 TEST_F(HttpNetworkTransactionSpdy2Test, EmptyResponse) { |
| 1031 HttpRequestInfo request; | 983 HttpRequestInfo request; |
| 1032 request.method = "POST"; | 984 request.method = "POST"; |
| 1033 request.url = GURL("http://www.foo.com/"); | 985 request.url = GURL("http://www.foo.com/"); |
| 1034 request.load_flags = 0; | 986 request.load_flags = 0; |
| 1035 | 987 |
| 1036 SessionDependencies session_deps; | 988 SpdySessionDependencies session_deps; |
| 1037 scoped_ptr<HttpTransaction> trans( | 989 scoped_ptr<HttpTransaction> trans( |
| 1038 new HttpNetworkTransaction(CreateSession(&session_deps))); | 990 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 1039 | 991 |
| 1040 MockRead data_reads[] = { | 992 MockRead data_reads[] = { |
| 1041 MockRead(ASYNC, 0), | 993 MockRead(ASYNC, 0), |
| 1042 }; | 994 }; |
| 1043 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 995 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 1044 session_deps.socket_factory.AddSocketDataProvider(&data); | 996 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 1045 | 997 |
| 1046 TestCompletionCallback callback; | 998 TestCompletionCallback callback; |
| 1047 | 999 |
| 1048 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1000 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1049 EXPECT_EQ(ERR_IO_PENDING, rv); | 1001 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1050 | 1002 |
| 1051 rv = callback.WaitForResult(); | 1003 rv = callback.WaitForResult(); |
| 1052 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); | 1004 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); |
| 1053 } | 1005 } |
| 1054 | 1006 |
| 1055 void HttpNetworkTransactionSpdy2Test::KeepAliveConnectionResendRequestTest( | 1007 void HttpNetworkTransactionSpdy2Test::KeepAliveConnectionResendRequestTest( |
| 1056 const MockWrite* write_failure, | 1008 const MockWrite* write_failure, |
| 1057 const MockRead* read_failure) { | 1009 const MockRead* read_failure) { |
| 1058 HttpRequestInfo request; | 1010 HttpRequestInfo request; |
| 1059 request.method = "GET"; | 1011 request.method = "GET"; |
| 1060 request.url = GURL("http://www.foo.com/"); | 1012 request.url = GURL("http://www.foo.com/"); |
| 1061 request.load_flags = 0; | 1013 request.load_flags = 0; |
| 1062 | 1014 |
| 1063 SessionDependencies session_deps; | 1015 SpdySessionDependencies session_deps; |
| 1064 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1016 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 1065 | 1017 |
| 1066 // Written data for successfully sending both requests. | 1018 // Written data for successfully sending both requests. |
| 1067 MockWrite data1_writes[] = { | 1019 MockWrite data1_writes[] = { |
| 1068 MockWrite("GET / HTTP/1.1\r\n" | 1020 MockWrite("GET / HTTP/1.1\r\n" |
| 1069 "Host: www.foo.com\r\n" | 1021 "Host: www.foo.com\r\n" |
| 1070 "Connection: keep-alive\r\n\r\n"), | 1022 "Connection: keep-alive\r\n\r\n"), |
| 1071 MockWrite("GET / HTTP/1.1\r\n" | 1023 MockWrite("GET / HTTP/1.1\r\n" |
| 1072 "Host: www.foo.com\r\n" | 1024 "Host: www.foo.com\r\n" |
| 1073 "Connection: keep-alive\r\n\r\n") | 1025 "Connection: keep-alive\r\n\r\n") |
| 1074 }; | 1026 }; |
| 1075 | 1027 |
| 1076 // Read results for the first request. | 1028 // Read results for the first request. |
| 1077 MockRead data1_reads[] = { | 1029 MockRead data1_reads[] = { |
| 1078 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), | 1030 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), |
| 1079 MockRead("hello"), | 1031 MockRead("hello"), |
| 1080 MockRead(ASYNC, OK), | 1032 MockRead(ASYNC, OK), |
| 1081 }; | 1033 }; |
| 1082 | 1034 |
| 1083 if (write_failure) { | 1035 if (write_failure) { |
| 1084 ASSERT_TRUE(!read_failure); | 1036 ASSERT_TRUE(!read_failure); |
| 1085 data1_writes[1] = *write_failure; | 1037 data1_writes[1] = *write_failure; |
| 1086 } else { | 1038 } else { |
| 1087 ASSERT_TRUE(read_failure); | 1039 ASSERT_TRUE(read_failure); |
| 1088 data1_reads[2] = *read_failure; | 1040 data1_reads[2] = *read_failure; |
| 1089 } | 1041 } |
| 1090 | 1042 |
| 1091 StaticSocketDataProvider data1(data1_reads, arraysize(data1_reads), | 1043 StaticSocketDataProvider data1(data1_reads, arraysize(data1_reads), |
| 1092 data1_writes, arraysize(data1_writes)); | 1044 data1_writes, arraysize(data1_writes)); |
| 1093 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1045 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 1094 | 1046 |
| 1095 MockRead data2_reads[] = { | 1047 MockRead data2_reads[] = { |
| 1096 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), | 1048 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), |
| 1097 MockRead("world"), | 1049 MockRead("world"), |
| 1098 MockRead(ASYNC, OK), | 1050 MockRead(ASYNC, OK), |
| 1099 }; | 1051 }; |
| 1100 StaticSocketDataProvider data2(data2_reads, arraysize(data2_reads), NULL, 0); | 1052 StaticSocketDataProvider data2(data2_reads, arraysize(data2_reads), NULL, 0); |
| 1101 session_deps.socket_factory.AddSocketDataProvider(&data2); | 1053 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 1102 | 1054 |
| 1103 const char* kExpectedResponseData[] = { | 1055 const char* kExpectedResponseData[] = { |
| 1104 "hello", "world" | 1056 "hello", "world" |
| 1105 }; | 1057 }; |
| 1106 | 1058 |
| 1107 for (int i = 0; i < 2; ++i) { | 1059 for (int i = 0; i < 2; ++i) { |
| 1108 TestCompletionCallback callback; | 1060 TestCompletionCallback callback; |
| 1109 | 1061 |
| 1110 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1062 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1111 | 1063 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 MockRead read_failure(SYNCHRONOUS, OK); // EOF | 1095 MockRead read_failure(SYNCHRONOUS, OK); // EOF |
| 1144 KeepAliveConnectionResendRequestTest(NULL, &read_failure); | 1096 KeepAliveConnectionResendRequestTest(NULL, &read_failure); |
| 1145 } | 1097 } |
| 1146 | 1098 |
| 1147 TEST_F(HttpNetworkTransactionSpdy2Test, NonKeepAliveConnectionReset) { | 1099 TEST_F(HttpNetworkTransactionSpdy2Test, NonKeepAliveConnectionReset) { |
| 1148 HttpRequestInfo request; | 1100 HttpRequestInfo request; |
| 1149 request.method = "GET"; | 1101 request.method = "GET"; |
| 1150 request.url = GURL("http://www.google.com/"); | 1102 request.url = GURL("http://www.google.com/"); |
| 1151 request.load_flags = 0; | 1103 request.load_flags = 0; |
| 1152 | 1104 |
| 1153 SessionDependencies session_deps; | 1105 SpdySessionDependencies session_deps; |
| 1154 scoped_ptr<HttpTransaction> trans( | 1106 scoped_ptr<HttpTransaction> trans( |
| 1155 new HttpNetworkTransaction(CreateSession(&session_deps))); | 1107 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 1156 | 1108 |
| 1157 MockRead data_reads[] = { | 1109 MockRead data_reads[] = { |
| 1158 MockRead(ASYNC, ERR_CONNECTION_RESET), | 1110 MockRead(ASYNC, ERR_CONNECTION_RESET), |
| 1159 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used | 1111 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used |
| 1160 MockRead("hello world"), | 1112 MockRead("hello world"), |
| 1161 MockRead(SYNCHRONOUS, OK), | 1113 MockRead(SYNCHRONOUS, OK), |
| 1162 }; | 1114 }; |
| 1163 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 1115 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 1164 session_deps.socket_factory.AddSocketDataProvider(&data); | 1116 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 1165 | 1117 |
| 1166 TestCompletionCallback callback; | 1118 TestCompletionCallback callback; |
| 1167 | 1119 |
| 1168 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1120 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1169 EXPECT_EQ(ERR_IO_PENDING, rv); | 1121 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1170 | 1122 |
| 1171 rv = callback.WaitForResult(); | 1123 rv = callback.WaitForResult(); |
| 1172 EXPECT_EQ(ERR_CONNECTION_RESET, rv); | 1124 EXPECT_EQ(ERR_CONNECTION_RESET, rv); |
| 1173 | 1125 |
| 1174 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1126 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1199 // Next 2 cases (KeepAliveEarlyClose and KeepAliveEarlyClose2) are regression | 1151 // Next 2 cases (KeepAliveEarlyClose and KeepAliveEarlyClose2) are regression |
| 1200 // tests. There was a bug causing HttpNetworkTransaction to hang in the | 1152 // tests. There was a bug causing HttpNetworkTransaction to hang in the |
| 1201 // destructor in such situations. | 1153 // destructor in such situations. |
| 1202 // See http://crbug.com/154712 and http://crbug.com/156609. | 1154 // See http://crbug.com/154712 and http://crbug.com/156609. |
| 1203 TEST_F(HttpNetworkTransactionSpdy2Test, KeepAliveEarlyClose) { | 1155 TEST_F(HttpNetworkTransactionSpdy2Test, KeepAliveEarlyClose) { |
| 1204 HttpRequestInfo request; | 1156 HttpRequestInfo request; |
| 1205 request.method = "GET"; | 1157 request.method = "GET"; |
| 1206 request.url = GURL("http://www.google.com/"); | 1158 request.url = GURL("http://www.google.com/"); |
| 1207 request.load_flags = 0; | 1159 request.load_flags = 0; |
| 1208 | 1160 |
| 1209 SessionDependencies session_deps; | 1161 SpdySessionDependencies session_deps; |
| 1210 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1162 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 1211 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1163 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1212 | 1164 |
| 1213 MockRead data_reads[] = { | 1165 MockRead data_reads[] = { |
| 1214 MockRead("HTTP/1.0 200 OK\r\n"), | 1166 MockRead("HTTP/1.0 200 OK\r\n"), |
| 1215 MockRead("Connection: keep-alive\r\n"), | 1167 MockRead("Connection: keep-alive\r\n"), |
| 1216 MockRead("Content-Length: 100\r\n\r\n"), | 1168 MockRead("Content-Length: 100\r\n\r\n"), |
| 1217 MockRead("hello"), | 1169 MockRead("hello"), |
| 1218 MockRead(SYNCHRONOUS, 0), | 1170 MockRead(SYNCHRONOUS, 0), |
| 1219 }; | 1171 }; |
| 1220 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 1172 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 1221 session_deps.socket_factory.AddSocketDataProvider(&data); | 1173 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 1222 | 1174 |
| 1223 TestCompletionCallback callback; | 1175 TestCompletionCallback callback; |
| 1224 | 1176 |
| 1225 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1177 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1226 EXPECT_EQ(ERR_IO_PENDING, rv); | 1178 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1227 | 1179 |
| 1228 rv = callback.WaitForResult(); | 1180 rv = callback.WaitForResult(); |
| 1229 EXPECT_EQ(OK, rv); | 1181 EXPECT_EQ(OK, rv); |
| 1230 | 1182 |
| 1231 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); | 1183 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); |
| 1232 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); | 1184 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); |
| 1233 if (rv == ERR_IO_PENDING) | 1185 if (rv == ERR_IO_PENDING) |
| 1234 rv = callback.WaitForResult(); | 1186 rv = callback.WaitForResult(); |
| 1235 EXPECT_EQ(5, rv); | 1187 EXPECT_EQ(5, rv); |
| 1236 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); | 1188 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); |
| 1237 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); | 1189 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); |
| 1238 | 1190 |
| 1239 trans.reset(); | 1191 trans.reset(); |
| 1240 MessageLoop::current()->RunUntilIdle(); | 1192 MessageLoop::current()->RunUntilIdle(); |
| 1241 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 1193 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
| 1242 } | 1194 } |
| 1243 | 1195 |
| 1244 TEST_F(HttpNetworkTransactionSpdy2Test, KeepAliveEarlyClose2) { | 1196 TEST_F(HttpNetworkTransactionSpdy2Test, KeepAliveEarlyClose2) { |
| 1245 HttpRequestInfo request; | 1197 HttpRequestInfo request; |
| 1246 request.method = "GET"; | 1198 request.method = "GET"; |
| 1247 request.url = GURL("http://www.google.com/"); | 1199 request.url = GURL("http://www.google.com/"); |
| 1248 request.load_flags = 0; | 1200 request.load_flags = 0; |
| 1249 | 1201 |
| 1250 SessionDependencies session_deps; | 1202 SpdySessionDependencies session_deps; |
| 1251 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1203 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 1252 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1204 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1253 | 1205 |
| 1254 MockRead data_reads[] = { | 1206 MockRead data_reads[] = { |
| 1255 MockRead("HTTP/1.0 200 OK\r\n"), | 1207 MockRead("HTTP/1.0 200 OK\r\n"), |
| 1256 MockRead("Connection: keep-alive\r\n"), | 1208 MockRead("Connection: keep-alive\r\n"), |
| 1257 MockRead("Content-Length: 100\r\n\r\n"), | 1209 MockRead("Content-Length: 100\r\n\r\n"), |
| 1258 MockRead(SYNCHRONOUS, 0), | 1210 MockRead(SYNCHRONOUS, 0), |
| 1259 }; | 1211 }; |
| 1260 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 1212 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 1261 session_deps.socket_factory.AddSocketDataProvider(&data); | 1213 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 1262 | 1214 |
| 1263 TestCompletionCallback callback; | 1215 TestCompletionCallback callback; |
| 1264 | 1216 |
| 1265 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1217 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1266 EXPECT_EQ(ERR_IO_PENDING, rv); | 1218 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1267 | 1219 |
| 1268 rv = callback.WaitForResult(); | 1220 rv = callback.WaitForResult(); |
| 1269 EXPECT_EQ(OK, rv); | 1221 EXPECT_EQ(OK, rv); |
| 1270 | 1222 |
| 1271 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); | 1223 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(100)); |
| 1272 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); | 1224 rv = trans->Read(io_buf, io_buf->size(), callback.callback()); |
| 1273 if (rv == ERR_IO_PENDING) | 1225 if (rv == ERR_IO_PENDING) |
| 1274 rv = callback.WaitForResult(); | 1226 rv = callback.WaitForResult(); |
| 1275 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); | 1227 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); |
| 1276 | 1228 |
| 1277 trans.reset(); | 1229 trans.reset(); |
| 1278 MessageLoop::current()->RunUntilIdle(); | 1230 MessageLoop::current()->RunUntilIdle(); |
| 1279 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); | 1231 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session.get())); |
| 1280 } | 1232 } |
| 1281 | 1233 |
| 1282 // Test that we correctly reuse a keep-alive connection after not explicitly | 1234 // Test that we correctly reuse a keep-alive connection after not explicitly |
| 1283 // reading the body. | 1235 // reading the body. |
| 1284 TEST_F(HttpNetworkTransactionSpdy2Test, KeepAliveAfterUnreadBody) { | 1236 TEST_F(HttpNetworkTransactionSpdy2Test, KeepAliveAfterUnreadBody) { |
| 1285 HttpRequestInfo request; | 1237 HttpRequestInfo request; |
| 1286 request.method = "GET"; | 1238 request.method = "GET"; |
| 1287 request.url = GURL("http://www.foo.com/"); | 1239 request.url = GURL("http://www.foo.com/"); |
| 1288 request.load_flags = 0; | 1240 request.load_flags = 0; |
| 1289 | 1241 |
| 1290 SessionDependencies session_deps; | 1242 SpdySessionDependencies session_deps; |
| 1291 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1243 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 1292 | 1244 |
| 1293 // Note that because all these reads happen in the same | 1245 // Note that because all these reads happen in the same |
| 1294 // StaticSocketDataProvider, it shows that the same socket is being reused for | 1246 // StaticSocketDataProvider, it shows that the same socket is being reused for |
| 1295 // all transactions. | 1247 // all transactions. |
| 1296 MockRead data1_reads[] = { | 1248 MockRead data1_reads[] = { |
| 1297 MockRead("HTTP/1.1 204 No Content\r\n\r\n"), | 1249 MockRead("HTTP/1.1 204 No Content\r\n\r\n"), |
| 1298 MockRead("HTTP/1.1 205 Reset Content\r\n\r\n"), | 1250 MockRead("HTTP/1.1 205 Reset Content\r\n\r\n"), |
| 1299 MockRead("HTTP/1.1 304 Not Modified\r\n\r\n"), | 1251 MockRead("HTTP/1.1 304 Not Modified\r\n\r\n"), |
| 1300 MockRead("HTTP/1.1 302 Found\r\n" | 1252 MockRead("HTTP/1.1 302 Found\r\n" |
| 1301 "Content-Length: 0\r\n\r\n"), | 1253 "Content-Length: 0\r\n\r\n"), |
| 1302 MockRead("HTTP/1.1 302 Found\r\n" | 1254 MockRead("HTTP/1.1 302 Found\r\n" |
| 1303 "Content-Length: 5\r\n\r\n" | 1255 "Content-Length: 5\r\n\r\n" |
| 1304 "hello"), | 1256 "hello"), |
| 1305 MockRead("HTTP/1.1 301 Moved Permanently\r\n" | 1257 MockRead("HTTP/1.1 301 Moved Permanently\r\n" |
| 1306 "Content-Length: 0\r\n\r\n"), | 1258 "Content-Length: 0\r\n\r\n"), |
| 1307 MockRead("HTTP/1.1 301 Moved Permanently\r\n" | 1259 MockRead("HTTP/1.1 301 Moved Permanently\r\n" |
| 1308 "Content-Length: 5\r\n\r\n" | 1260 "Content-Length: 5\r\n\r\n" |
| 1309 "hello"), | 1261 "hello"), |
| 1310 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), | 1262 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), |
| 1311 MockRead("hello"), | 1263 MockRead("hello"), |
| 1312 }; | 1264 }; |
| 1313 StaticSocketDataProvider data1(data1_reads, arraysize(data1_reads), NULL, 0); | 1265 StaticSocketDataProvider data1(data1_reads, arraysize(data1_reads), NULL, 0); |
| 1314 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1266 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 1315 | 1267 |
| 1316 MockRead data2_reads[] = { | 1268 MockRead data2_reads[] = { |
| 1317 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. | 1269 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. |
| 1318 }; | 1270 }; |
| 1319 StaticSocketDataProvider data2(data2_reads, arraysize(data2_reads), NULL, 0); | 1271 StaticSocketDataProvider data2(data2_reads, arraysize(data2_reads), NULL, 0); |
| 1320 session_deps.socket_factory.AddSocketDataProvider(&data2); | 1272 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 1321 | 1273 |
| 1322 const int kNumUnreadBodies = arraysize(data1_reads) - 2; | 1274 const int kNumUnreadBodies = arraysize(data1_reads) - 2; |
| 1323 std::string response_lines[kNumUnreadBodies]; | 1275 std::string response_lines[kNumUnreadBodies]; |
| 1324 | 1276 |
| 1325 for (size_t i = 0; i < arraysize(data1_reads) - 2; ++i) { | 1277 for (size_t i = 0; i < arraysize(data1_reads) - 2; ++i) { |
| 1326 TestCompletionCallback callback; | 1278 TestCompletionCallback callback; |
| 1327 | 1279 |
| 1328 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1280 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1329 | 1281 |
| 1330 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1282 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1375 } | 1327 } |
| 1376 | 1328 |
| 1377 // Test the request-challenge-retry sequence for basic auth. | 1329 // Test the request-challenge-retry sequence for basic auth. |
| 1378 // (basic auth is the easiest to mock, because it has no randomness). | 1330 // (basic auth is the easiest to mock, because it has no randomness). |
| 1379 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuth) { | 1331 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuth) { |
| 1380 HttpRequestInfo request; | 1332 HttpRequestInfo request; |
| 1381 request.method = "GET"; | 1333 request.method = "GET"; |
| 1382 request.url = GURL("http://www.google.com/"); | 1334 request.url = GURL("http://www.google.com/"); |
| 1383 request.load_flags = 0; | 1335 request.load_flags = 0; |
| 1384 | 1336 |
| 1385 SessionDependencies session_deps; | 1337 SpdySessionDependencies session_deps; |
| 1386 scoped_ptr<HttpTransaction> trans( | 1338 scoped_ptr<HttpTransaction> trans( |
| 1387 new HttpNetworkTransaction(CreateSession(&session_deps))); | 1339 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 1388 | 1340 |
| 1389 MockWrite data_writes1[] = { | 1341 MockWrite data_writes1[] = { |
| 1390 MockWrite("GET / HTTP/1.1\r\n" | 1342 MockWrite("GET / HTTP/1.1\r\n" |
| 1391 "Host: www.google.com\r\n" | 1343 "Host: www.google.com\r\n" |
| 1392 "Connection: keep-alive\r\n\r\n"), | 1344 "Connection: keep-alive\r\n\r\n"), |
| 1393 }; | 1345 }; |
| 1394 | 1346 |
| 1395 MockRead data_reads1[] = { | 1347 MockRead data_reads1[] = { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1419 MockRead("HTTP/1.0 200 OK\r\n"), | 1371 MockRead("HTTP/1.0 200 OK\r\n"), |
| 1420 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 1372 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 1421 MockRead("Content-Length: 100\r\n\r\n"), | 1373 MockRead("Content-Length: 100\r\n\r\n"), |
| 1422 MockRead(SYNCHRONOUS, OK), | 1374 MockRead(SYNCHRONOUS, OK), |
| 1423 }; | 1375 }; |
| 1424 | 1376 |
| 1425 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1377 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1426 data_writes1, arraysize(data_writes1)); | 1378 data_writes1, arraysize(data_writes1)); |
| 1427 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1379 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 1428 data_writes2, arraysize(data_writes2)); | 1380 data_writes2, arraysize(data_writes2)); |
| 1429 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1381 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 1430 session_deps.socket_factory.AddSocketDataProvider(&data2); | 1382 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 1431 | 1383 |
| 1432 TestCompletionCallback callback1; | 1384 TestCompletionCallback callback1; |
| 1433 | 1385 |
| 1434 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 1386 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 1435 EXPECT_EQ(ERR_IO_PENDING, rv); | 1387 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1436 | 1388 |
| 1437 rv = callback1.WaitForResult(); | 1389 rv = callback1.WaitForResult(); |
| 1438 EXPECT_EQ(OK, rv); | 1390 EXPECT_EQ(OK, rv); |
| 1439 | 1391 |
| 1440 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1392 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1455 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1407 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 1456 EXPECT_EQ(100, response->headers->GetContentLength()); | 1408 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 1457 } | 1409 } |
| 1458 | 1410 |
| 1459 TEST_F(HttpNetworkTransactionSpdy2Test, DoNotSendAuth) { | 1411 TEST_F(HttpNetworkTransactionSpdy2Test, DoNotSendAuth) { |
| 1460 HttpRequestInfo request; | 1412 HttpRequestInfo request; |
| 1461 request.method = "GET"; | 1413 request.method = "GET"; |
| 1462 request.url = GURL("http://www.google.com/"); | 1414 request.url = GURL("http://www.google.com/"); |
| 1463 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 1415 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
| 1464 | 1416 |
| 1465 SessionDependencies session_deps; | 1417 SpdySessionDependencies session_deps; |
| 1466 scoped_ptr<HttpTransaction> trans( | 1418 scoped_ptr<HttpTransaction> trans( |
| 1467 new HttpNetworkTransaction(CreateSession(&session_deps))); | 1419 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 1468 | 1420 |
| 1469 MockWrite data_writes[] = { | 1421 MockWrite data_writes[] = { |
| 1470 MockWrite("GET / HTTP/1.1\r\n" | 1422 MockWrite("GET / HTTP/1.1\r\n" |
| 1471 "Host: www.google.com\r\n" | 1423 "Host: www.google.com\r\n" |
| 1472 "Connection: keep-alive\r\n\r\n"), | 1424 "Connection: keep-alive\r\n\r\n"), |
| 1473 }; | 1425 }; |
| 1474 | 1426 |
| 1475 MockRead data_reads[] = { | 1427 MockRead data_reads[] = { |
| 1476 MockRead("HTTP/1.0 401 Unauthorized\r\n"), | 1428 MockRead("HTTP/1.0 401 Unauthorized\r\n"), |
| 1477 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 1429 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 1478 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 1430 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 1479 // Large content-length -- won't matter, as connection will be reset. | 1431 // Large content-length -- won't matter, as connection will be reset. |
| 1480 MockRead("Content-Length: 10000\r\n\r\n"), | 1432 MockRead("Content-Length: 10000\r\n\r\n"), |
| 1481 MockRead(SYNCHRONOUS, ERR_FAILED), | 1433 MockRead(SYNCHRONOUS, ERR_FAILED), |
| 1482 }; | 1434 }; |
| 1483 | 1435 |
| 1484 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 1436 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 1485 data_writes, arraysize(data_writes)); | 1437 data_writes, arraysize(data_writes)); |
| 1486 session_deps.socket_factory.AddSocketDataProvider(&data); | 1438 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 1487 TestCompletionCallback callback; | 1439 TestCompletionCallback callback; |
| 1488 | 1440 |
| 1489 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 1441 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 1490 EXPECT_EQ(ERR_IO_PENDING, rv); | 1442 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1491 | 1443 |
| 1492 rv = callback.WaitForResult(); | 1444 rv = callback.WaitForResult(); |
| 1493 EXPECT_EQ(0, rv); | 1445 EXPECT_EQ(0, rv); |
| 1494 | 1446 |
| 1495 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1447 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 1496 ASSERT_TRUE(response != NULL); | 1448 ASSERT_TRUE(response != NULL); |
| 1497 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1449 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 1498 } | 1450 } |
| 1499 | 1451 |
| 1500 // Test the request-challenge-retry sequence for basic auth, over a keep-alive | 1452 // Test the request-challenge-retry sequence for basic auth, over a keep-alive |
| 1501 // connection. | 1453 // connection. |
| 1502 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthKeepAlive) { | 1454 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthKeepAlive) { |
| 1503 HttpRequestInfo request; | 1455 HttpRequestInfo request; |
| 1504 request.method = "GET"; | 1456 request.method = "GET"; |
| 1505 request.url = GURL("http://www.google.com/"); | 1457 request.url = GURL("http://www.google.com/"); |
| 1506 request.load_flags = 0; | 1458 request.load_flags = 0; |
| 1507 | 1459 |
| 1508 SessionDependencies session_deps; | 1460 SpdySessionDependencies session_deps; |
| 1509 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1461 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 1510 | 1462 |
| 1511 MockWrite data_writes1[] = { | 1463 MockWrite data_writes1[] = { |
| 1512 MockWrite("GET / HTTP/1.1\r\n" | 1464 MockWrite("GET / HTTP/1.1\r\n" |
| 1513 "Host: www.google.com\r\n" | 1465 "Host: www.google.com\r\n" |
| 1514 "Connection: keep-alive\r\n\r\n"), | 1466 "Connection: keep-alive\r\n\r\n"), |
| 1515 | 1467 |
| 1516 // After calling trans->RestartWithAuth(), this is the request we should | 1468 // After calling trans->RestartWithAuth(), this is the request we should |
| 1517 // be issuing -- the final header line contains the credentials. | 1469 // be issuing -- the final header line contains the credentials. |
| 1518 MockWrite("GET / HTTP/1.1\r\n" | 1470 MockWrite("GET / HTTP/1.1\r\n" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1538 // If there is a regression where we disconnect a Keep-Alive | 1490 // If there is a regression where we disconnect a Keep-Alive |
| 1539 // connection during an auth roundtrip, we'll end up reading this. | 1491 // connection during an auth roundtrip, we'll end up reading this. |
| 1540 MockRead data_reads2[] = { | 1492 MockRead data_reads2[] = { |
| 1541 MockRead(SYNCHRONOUS, ERR_FAILED), | 1493 MockRead(SYNCHRONOUS, ERR_FAILED), |
| 1542 }; | 1494 }; |
| 1543 | 1495 |
| 1544 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1496 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1545 data_writes1, arraysize(data_writes1)); | 1497 data_writes1, arraysize(data_writes1)); |
| 1546 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1498 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 1547 NULL, 0); | 1499 NULL, 0); |
| 1548 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1500 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 1549 session_deps.socket_factory.AddSocketDataProvider(&data2); | 1501 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 1550 | 1502 |
| 1551 TestCompletionCallback callback1; | 1503 TestCompletionCallback callback1; |
| 1552 | 1504 |
| 1553 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1505 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1554 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 1506 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 1555 EXPECT_EQ(ERR_IO_PENDING, rv); | 1507 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1556 | 1508 |
| 1557 rv = callback1.WaitForResult(); | 1509 rv = callback1.WaitForResult(); |
| 1558 EXPECT_EQ(OK, rv); | 1510 EXPECT_EQ(OK, rv); |
| 1559 | 1511 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1577 } | 1529 } |
| 1578 | 1530 |
| 1579 // Test the request-challenge-retry sequence for basic auth, over a keep-alive | 1531 // Test the request-challenge-retry sequence for basic auth, over a keep-alive |
| 1580 // connection and with no response body to drain. | 1532 // connection and with no response body to drain. |
| 1581 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthKeepAliveNoBody) { | 1533 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthKeepAliveNoBody) { |
| 1582 HttpRequestInfo request; | 1534 HttpRequestInfo request; |
| 1583 request.method = "GET"; | 1535 request.method = "GET"; |
| 1584 request.url = GURL("http://www.google.com/"); | 1536 request.url = GURL("http://www.google.com/"); |
| 1585 request.load_flags = 0; | 1537 request.load_flags = 0; |
| 1586 | 1538 |
| 1587 SessionDependencies session_deps; | 1539 SpdySessionDependencies session_deps; |
| 1588 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1540 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 1589 | 1541 |
| 1590 MockWrite data_writes1[] = { | 1542 MockWrite data_writes1[] = { |
| 1591 MockWrite("GET / HTTP/1.1\r\n" | 1543 MockWrite("GET / HTTP/1.1\r\n" |
| 1592 "Host: www.google.com\r\n" | 1544 "Host: www.google.com\r\n" |
| 1593 "Connection: keep-alive\r\n\r\n"), | 1545 "Connection: keep-alive\r\n\r\n"), |
| 1594 | 1546 |
| 1595 // After calling trans->RestartWithAuth(), this is the request we should | 1547 // After calling trans->RestartWithAuth(), this is the request we should |
| 1596 // be issuing -- the final header line contains the credentials. | 1548 // be issuing -- the final header line contains the credentials. |
| 1597 MockWrite("GET / HTTP/1.1\r\n" | 1549 MockWrite("GET / HTTP/1.1\r\n" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1614 | 1566 |
| 1615 // An incorrect reconnect would cause this to be read. | 1567 // An incorrect reconnect would cause this to be read. |
| 1616 MockRead data_reads2[] = { | 1568 MockRead data_reads2[] = { |
| 1617 MockRead(SYNCHRONOUS, ERR_FAILED), | 1569 MockRead(SYNCHRONOUS, ERR_FAILED), |
| 1618 }; | 1570 }; |
| 1619 | 1571 |
| 1620 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1572 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1621 data_writes1, arraysize(data_writes1)); | 1573 data_writes1, arraysize(data_writes1)); |
| 1622 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1574 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 1623 NULL, 0); | 1575 NULL, 0); |
| 1624 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1576 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 1625 session_deps.socket_factory.AddSocketDataProvider(&data2); | 1577 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 1626 | 1578 |
| 1627 TestCompletionCallback callback1; | 1579 TestCompletionCallback callback1; |
| 1628 | 1580 |
| 1629 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1581 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1630 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 1582 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 1631 EXPECT_EQ(ERR_IO_PENDING, rv); | 1583 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1632 | 1584 |
| 1633 rv = callback1.WaitForResult(); | 1585 rv = callback1.WaitForResult(); |
| 1634 EXPECT_EQ(OK, rv); | 1586 EXPECT_EQ(OK, rv); |
| 1635 | 1587 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1653 } | 1605 } |
| 1654 | 1606 |
| 1655 // Test the request-challenge-retry sequence for basic auth, over a keep-alive | 1607 // Test the request-challenge-retry sequence for basic auth, over a keep-alive |
| 1656 // connection and with a large response body to drain. | 1608 // connection and with a large response body to drain. |
| 1657 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthKeepAliveLargeBody) { | 1609 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthKeepAliveLargeBody) { |
| 1658 HttpRequestInfo request; | 1610 HttpRequestInfo request; |
| 1659 request.method = "GET"; | 1611 request.method = "GET"; |
| 1660 request.url = GURL("http://www.google.com/"); | 1612 request.url = GURL("http://www.google.com/"); |
| 1661 request.load_flags = 0; | 1613 request.load_flags = 0; |
| 1662 | 1614 |
| 1663 SessionDependencies session_deps; | 1615 SpdySessionDependencies session_deps; |
| 1664 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1616 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 1665 | 1617 |
| 1666 MockWrite data_writes1[] = { | 1618 MockWrite data_writes1[] = { |
| 1667 MockWrite("GET / HTTP/1.1\r\n" | 1619 MockWrite("GET / HTTP/1.1\r\n" |
| 1668 "Host: www.google.com\r\n" | 1620 "Host: www.google.com\r\n" |
| 1669 "Connection: keep-alive\r\n\r\n"), | 1621 "Connection: keep-alive\r\n\r\n"), |
| 1670 | 1622 |
| 1671 // After calling trans->RestartWithAuth(), this is the request we should | 1623 // After calling trans->RestartWithAuth(), this is the request we should |
| 1672 // be issuing -- the final header line contains the credentials. | 1624 // be issuing -- the final header line contains the credentials. |
| 1673 MockWrite("GET / HTTP/1.1\r\n" | 1625 MockWrite("GET / HTTP/1.1\r\n" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1698 | 1650 |
| 1699 // An incorrect reconnect would cause this to be read. | 1651 // An incorrect reconnect would cause this to be read. |
| 1700 MockRead data_reads2[] = { | 1652 MockRead data_reads2[] = { |
| 1701 MockRead(SYNCHRONOUS, ERR_FAILED), | 1653 MockRead(SYNCHRONOUS, ERR_FAILED), |
| 1702 }; | 1654 }; |
| 1703 | 1655 |
| 1704 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1656 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1705 data_writes1, arraysize(data_writes1)); | 1657 data_writes1, arraysize(data_writes1)); |
| 1706 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1658 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 1707 NULL, 0); | 1659 NULL, 0); |
| 1708 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1660 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 1709 session_deps.socket_factory.AddSocketDataProvider(&data2); | 1661 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 1710 | 1662 |
| 1711 TestCompletionCallback callback1; | 1663 TestCompletionCallback callback1; |
| 1712 | 1664 |
| 1713 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1665 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1714 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 1666 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 1715 EXPECT_EQ(ERR_IO_PENDING, rv); | 1667 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1716 | 1668 |
| 1717 rv = callback1.WaitForResult(); | 1669 rv = callback1.WaitForResult(); |
| 1718 EXPECT_EQ(OK, rv); | 1670 EXPECT_EQ(OK, rv); |
| 1719 | 1671 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1737 } | 1689 } |
| 1738 | 1690 |
| 1739 // Test the request-challenge-retry sequence for basic auth, over a keep-alive | 1691 // Test the request-challenge-retry sequence for basic auth, over a keep-alive |
| 1740 // connection, but the server gets impatient and closes the connection. | 1692 // connection, but the server gets impatient and closes the connection. |
| 1741 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthKeepAliveImpatientServer) { | 1693 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthKeepAliveImpatientServer) { |
| 1742 HttpRequestInfo request; | 1694 HttpRequestInfo request; |
| 1743 request.method = "GET"; | 1695 request.method = "GET"; |
| 1744 request.url = GURL("http://www.google.com/"); | 1696 request.url = GURL("http://www.google.com/"); |
| 1745 request.load_flags = 0; | 1697 request.load_flags = 0; |
| 1746 | 1698 |
| 1747 SessionDependencies session_deps; | 1699 SpdySessionDependencies session_deps; |
| 1748 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1700 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 1749 | 1701 |
| 1750 MockWrite data_writes1[] = { | 1702 MockWrite data_writes1[] = { |
| 1751 MockWrite("GET / HTTP/1.1\r\n" | 1703 MockWrite("GET / HTTP/1.1\r\n" |
| 1752 "Host: www.google.com\r\n" | 1704 "Host: www.google.com\r\n" |
| 1753 "Connection: keep-alive\r\n\r\n"), | 1705 "Connection: keep-alive\r\n\r\n"), |
| 1754 // This simulates the seemingly successful write to a closed connection | 1706 // This simulates the seemingly successful write to a closed connection |
| 1755 // if the bug is not fixed. | 1707 // if the bug is not fixed. |
| 1756 MockWrite("GET / HTTP/1.1\r\n" | 1708 MockWrite("GET / HTTP/1.1\r\n" |
| 1757 "Host: www.google.com\r\n" | 1709 "Host: www.google.com\r\n" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1784 MockRead("HTTP/1.1 200 OK\r\n"), | 1736 MockRead("HTTP/1.1 200 OK\r\n"), |
| 1785 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 1737 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 1786 MockRead("Content-Length: 5\r\n\r\n"), | 1738 MockRead("Content-Length: 5\r\n\r\n"), |
| 1787 MockRead("hello"), | 1739 MockRead("hello"), |
| 1788 }; | 1740 }; |
| 1789 | 1741 |
| 1790 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1742 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1791 data_writes1, arraysize(data_writes1)); | 1743 data_writes1, arraysize(data_writes1)); |
| 1792 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 1744 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 1793 data_writes2, arraysize(data_writes2)); | 1745 data_writes2, arraysize(data_writes2)); |
| 1794 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1746 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 1795 session_deps.socket_factory.AddSocketDataProvider(&data2); | 1747 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 1796 | 1748 |
| 1797 TestCompletionCallback callback1; | 1749 TestCompletionCallback callback1; |
| 1798 | 1750 |
| 1799 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1751 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1800 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 1752 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 1801 EXPECT_EQ(ERR_IO_PENDING, rv); | 1753 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1802 | 1754 |
| 1803 rv = callback1.WaitForResult(); | 1755 rv = callback1.WaitForResult(); |
| 1804 EXPECT_EQ(OK, rv); | 1756 EXPECT_EQ(OK, rv); |
| 1805 | 1757 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1825 // Test the request-challenge-retry sequence for basic auth, over a connection | 1777 // Test the request-challenge-retry sequence for basic auth, over a connection |
| 1826 // that requires a restart when setting up an SSL tunnel. | 1778 // that requires a restart when setting up an SSL tunnel. |
| 1827 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyNoKeepAlive) { | 1779 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyNoKeepAlive) { |
| 1828 HttpRequestInfo request; | 1780 HttpRequestInfo request; |
| 1829 request.method = "GET"; | 1781 request.method = "GET"; |
| 1830 request.url = GURL("https://www.google.com/"); | 1782 request.url = GURL("https://www.google.com/"); |
| 1831 // when the no authentication data flag is set. | 1783 // when the no authentication data flag is set. |
| 1832 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 1784 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
| 1833 | 1785 |
| 1834 // Configure against proxy server "myproxy:70". | 1786 // Configure against proxy server "myproxy:70". |
| 1835 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 1787 SpdySessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 1836 CapturingBoundNetLog log; | 1788 CapturingBoundNetLog log; |
| 1837 session_deps.net_log = log.bound().net_log(); | 1789 session_deps.net_log = log.bound().net_log(); |
| 1838 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1790 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 1839 | 1791 |
| 1840 // Since we have proxy, should try to establish tunnel. | 1792 // Since we have proxy, should try to establish tunnel. |
| 1841 MockWrite data_writes1[] = { | 1793 MockWrite data_writes1[] = { |
| 1842 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 1794 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 1843 "Host: www.google.com\r\n" | 1795 "Host: www.google.com\r\n" |
| 1844 "Proxy-Connection: keep-alive\r\n\r\n"), | 1796 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 1845 | 1797 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1866 MockRead("HTTP/1.1 200 Connection Established\r\n\r\n"), | 1818 MockRead("HTTP/1.1 200 Connection Established\r\n\r\n"), |
| 1867 | 1819 |
| 1868 MockRead("HTTP/1.1 200 OK\r\n"), | 1820 MockRead("HTTP/1.1 200 OK\r\n"), |
| 1869 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 1821 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 1870 MockRead("Content-Length: 5\r\n\r\n"), | 1822 MockRead("Content-Length: 5\r\n\r\n"), |
| 1871 MockRead(SYNCHRONOUS, "hello"), | 1823 MockRead(SYNCHRONOUS, "hello"), |
| 1872 }; | 1824 }; |
| 1873 | 1825 |
| 1874 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1826 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1875 data_writes1, arraysize(data_writes1)); | 1827 data_writes1, arraysize(data_writes1)); |
| 1876 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1828 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 1877 SSLSocketDataProvider ssl(ASYNC, OK); | 1829 SSLSocketDataProvider ssl(ASYNC, OK); |
| 1878 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 1830 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 1879 | 1831 |
| 1880 TestCompletionCallback callback1; | 1832 TestCompletionCallback callback1; |
| 1881 | 1833 |
| 1882 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1834 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1883 | 1835 |
| 1884 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 1836 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 1885 EXPECT_EQ(ERR_IO_PENDING, rv); | 1837 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1886 | 1838 |
| 1887 rv = callback1.WaitForResult(); | 1839 rv = callback1.WaitForResult(); |
| 1888 EXPECT_EQ(OK, rv); | 1840 EXPECT_EQ(OK, rv); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1931 // proxy connection, when setting up an SSL tunnel. | 1883 // proxy connection, when setting up an SSL tunnel. |
| 1932 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyKeepAlive) { | 1884 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyKeepAlive) { |
| 1933 HttpRequestInfo request; | 1885 HttpRequestInfo request; |
| 1934 request.method = "GET"; | 1886 request.method = "GET"; |
| 1935 request.url = GURL("https://www.google.com/"); | 1887 request.url = GURL("https://www.google.com/"); |
| 1936 // Ensure that proxy authentication is attempted even | 1888 // Ensure that proxy authentication is attempted even |
| 1937 // when the no authentication data flag is set. | 1889 // when the no authentication data flag is set. |
| 1938 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 1890 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
| 1939 | 1891 |
| 1940 // Configure against proxy server "myproxy:70". | 1892 // Configure against proxy server "myproxy:70". |
| 1941 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 1893 SpdySessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 1942 CapturingBoundNetLog log; | 1894 CapturingBoundNetLog log; |
| 1943 session_deps.net_log = log.bound().net_log(); | 1895 session_deps.net_log = log.bound().net_log(); |
| 1944 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1896 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 1945 | 1897 |
| 1946 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1898 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 1947 | 1899 |
| 1948 // Since we have proxy, should try to establish tunnel. | 1900 // Since we have proxy, should try to establish tunnel. |
| 1949 MockWrite data_writes1[] = { | 1901 MockWrite data_writes1[] = { |
| 1950 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 1902 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 1951 "Host: www.google.com\r\n" | 1903 "Host: www.google.com\r\n" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1971 // Wrong credentials (wrong password). | 1923 // Wrong credentials (wrong password). |
| 1972 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), | 1924 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), |
| 1973 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 1925 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 1974 MockRead("Content-Length: 10\r\n\r\n"), | 1926 MockRead("Content-Length: 10\r\n\r\n"), |
| 1975 // No response body because the test stops reading here. | 1927 // No response body because the test stops reading here. |
| 1976 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. | 1928 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. |
| 1977 }; | 1929 }; |
| 1978 | 1930 |
| 1979 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 1931 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 1980 data_writes1, arraysize(data_writes1)); | 1932 data_writes1, arraysize(data_writes1)); |
| 1981 session_deps.socket_factory.AddSocketDataProvider(&data1); | 1933 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 1982 | 1934 |
| 1983 TestCompletionCallback callback1; | 1935 TestCompletionCallback callback1; |
| 1984 | 1936 |
| 1985 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 1937 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 1986 EXPECT_EQ(ERR_IO_PENDING, rv); | 1938 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1987 | 1939 |
| 1988 rv = callback1.WaitForResult(); | 1940 rv = callback1.WaitForResult(); |
| 1989 EXPECT_EQ(OK, rv); | 1941 EXPECT_EQ(OK, rv); |
| 1990 net::CapturingNetLog::CapturedEntryList entries; | 1942 net::CapturingNetLog::CapturedEntryList entries; |
| 1991 log.GetEntries(&entries); | 1943 log.GetEntries(&entries); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2032 | 1984 |
| 2033 // Test that we don't read the response body when we fail to establish a tunnel, | 1985 // Test that we don't read the response body when we fail to establish a tunnel, |
| 2034 // even if the user cancels the proxy's auth attempt. | 1986 // even if the user cancels the proxy's auth attempt. |
| 2035 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyCancelTunnel) { | 1987 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyCancelTunnel) { |
| 2036 HttpRequestInfo request; | 1988 HttpRequestInfo request; |
| 2037 request.method = "GET"; | 1989 request.method = "GET"; |
| 2038 request.url = GURL("https://www.google.com/"); | 1990 request.url = GURL("https://www.google.com/"); |
| 2039 request.load_flags = 0; | 1991 request.load_flags = 0; |
| 2040 | 1992 |
| 2041 // Configure against proxy server "myproxy:70". | 1993 // Configure against proxy server "myproxy:70". |
| 2042 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 1994 SpdySessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 2043 | 1995 |
| 2044 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 1996 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2045 | 1997 |
| 2046 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 1998 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2047 | 1999 |
| 2048 // Since we have proxy, should try to establish tunnel. | 2000 // Since we have proxy, should try to establish tunnel. |
| 2049 MockWrite data_writes[] = { | 2001 MockWrite data_writes[] = { |
| 2050 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 2002 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 2051 "Host: www.google.com\r\n" | 2003 "Host: www.google.com\r\n" |
| 2052 "Proxy-Connection: keep-alive\r\n\r\n"), | 2004 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 2053 }; | 2005 }; |
| 2054 | 2006 |
| 2055 // The proxy responds to the connect with a 407. | 2007 // The proxy responds to the connect with a 407. |
| 2056 MockRead data_reads[] = { | 2008 MockRead data_reads[] = { |
| 2057 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), | 2009 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), |
| 2058 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 2010 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 2059 MockRead("Content-Length: 10\r\n\r\n"), | 2011 MockRead("Content-Length: 10\r\n\r\n"), |
| 2060 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. | 2012 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. |
| 2061 }; | 2013 }; |
| 2062 | 2014 |
| 2063 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 2015 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 2064 data_writes, arraysize(data_writes)); | 2016 data_writes, arraysize(data_writes)); |
| 2065 session_deps.socket_factory.AddSocketDataProvider(&data); | 2017 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 2066 | 2018 |
| 2067 TestCompletionCallback callback; | 2019 TestCompletionCallback callback; |
| 2068 | 2020 |
| 2069 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 2021 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 2070 EXPECT_EQ(ERR_IO_PENDING, rv); | 2022 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2071 | 2023 |
| 2072 rv = callback.WaitForResult(); | 2024 rv = callback.WaitForResult(); |
| 2073 EXPECT_EQ(OK, rv); | 2025 EXPECT_EQ(OK, rv); |
| 2074 | 2026 |
| 2075 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2027 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2090 | 2042 |
| 2091 // Test when a server (non-proxy) returns a 407 (proxy-authenticate). | 2043 // Test when a server (non-proxy) returns a 407 (proxy-authenticate). |
| 2092 // The request should fail with ERR_UNEXPECTED_PROXY_AUTH. | 2044 // The request should fail with ERR_UNEXPECTED_PROXY_AUTH. |
| 2093 TEST_F(HttpNetworkTransactionSpdy2Test, UnexpectedProxyAuth) { | 2045 TEST_F(HttpNetworkTransactionSpdy2Test, UnexpectedProxyAuth) { |
| 2094 HttpRequestInfo request; | 2046 HttpRequestInfo request; |
| 2095 request.method = "GET"; | 2047 request.method = "GET"; |
| 2096 request.url = GURL("http://www.google.com/"); | 2048 request.url = GURL("http://www.google.com/"); |
| 2097 request.load_flags = 0; | 2049 request.load_flags = 0; |
| 2098 | 2050 |
| 2099 // We are using a DIRECT connection (i.e. no proxy) for this session. | 2051 // We are using a DIRECT connection (i.e. no proxy) for this session. |
| 2100 SessionDependencies session_deps; | 2052 SpdySessionDependencies session_deps; |
| 2101 scoped_ptr<HttpTransaction> trans( | 2053 scoped_ptr<HttpTransaction> trans( |
| 2102 new HttpNetworkTransaction(CreateSession(&session_deps))); | 2054 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 2103 | 2055 |
| 2104 MockWrite data_writes1[] = { | 2056 MockWrite data_writes1[] = { |
| 2105 MockWrite("GET / HTTP/1.1\r\n" | 2057 MockWrite("GET / HTTP/1.1\r\n" |
| 2106 "Host: www.google.com\r\n" | 2058 "Host: www.google.com\r\n" |
| 2107 "Connection: keep-alive\r\n\r\n"), | 2059 "Connection: keep-alive\r\n\r\n"), |
| 2108 }; | 2060 }; |
| 2109 | 2061 |
| 2110 MockRead data_reads1[] = { | 2062 MockRead data_reads1[] = { |
| 2111 MockRead("HTTP/1.0 407 Proxy Auth required\r\n"), | 2063 MockRead("HTTP/1.0 407 Proxy Auth required\r\n"), |
| 2112 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 2064 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 2113 // Large content-length -- won't matter, as connection will be reset. | 2065 // Large content-length -- won't matter, as connection will be reset. |
| 2114 MockRead("Content-Length: 10000\r\n\r\n"), | 2066 MockRead("Content-Length: 10000\r\n\r\n"), |
| 2115 MockRead(SYNCHRONOUS, ERR_FAILED), | 2067 MockRead(SYNCHRONOUS, ERR_FAILED), |
| 2116 }; | 2068 }; |
| 2117 | 2069 |
| 2118 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2070 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 2119 data_writes1, arraysize(data_writes1)); | 2071 data_writes1, arraysize(data_writes1)); |
| 2120 session_deps.socket_factory.AddSocketDataProvider(&data1); | 2072 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 2121 | 2073 |
| 2122 TestCompletionCallback callback; | 2074 TestCompletionCallback callback; |
| 2123 | 2075 |
| 2124 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 2076 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 2125 EXPECT_EQ(ERR_IO_PENDING, rv); | 2077 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2126 | 2078 |
| 2127 rv = callback.WaitForResult(); | 2079 rv = callback.WaitForResult(); |
| 2128 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); | 2080 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); |
| 2129 } | 2081 } |
| 2130 | 2082 |
| 2131 // Tests when an HTTPS server (non-proxy) returns a 407 (proxy-authentication) | 2083 // Tests when an HTTPS server (non-proxy) returns a 407 (proxy-authentication) |
| 2132 // through a non-authenticating proxy. The request should fail with | 2084 // through a non-authenticating proxy. The request should fail with |
| 2133 // ERR_UNEXPECTED_PROXY_AUTH. | 2085 // ERR_UNEXPECTED_PROXY_AUTH. |
| 2134 // Note that it is impossible to detect if an HTTP server returns a 407 through | 2086 // Note that it is impossible to detect if an HTTP server returns a 407 through |
| 2135 // a non-authenticating proxy - there is nothing to indicate whether the | 2087 // a non-authenticating proxy - there is nothing to indicate whether the |
| 2136 // response came from the proxy or the server, so it is treated as if the proxy | 2088 // response came from the proxy or the server, so it is treated as if the proxy |
| 2137 // issued the challenge. | 2089 // issued the challenge. |
| 2138 TEST_F(HttpNetworkTransactionSpdy2Test, | 2090 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 2139 HttpsServerRequestsProxyAuthThroughProxy) { | 2091 HttpsServerRequestsProxyAuthThroughProxy) { |
| 2140 HttpRequestInfo request; | 2092 HttpRequestInfo request; |
| 2141 request.method = "GET"; | 2093 request.method = "GET"; |
| 2142 request.url = GURL("https://www.google.com/"); | 2094 request.url = GURL("https://www.google.com/"); |
| 2143 | 2095 |
| 2144 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 2096 SpdySessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 2145 CapturingBoundNetLog log; | 2097 CapturingBoundNetLog log; |
| 2146 session_deps.net_log = log.bound().net_log(); | 2098 session_deps.net_log = log.bound().net_log(); |
| 2147 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2099 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2148 | 2100 |
| 2149 // Since we have proxy, should try to establish tunnel. | 2101 // Since we have proxy, should try to establish tunnel. |
| 2150 MockWrite data_writes1[] = { | 2102 MockWrite data_writes1[] = { |
| 2151 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 2103 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 2152 "Host: www.google.com\r\n" | 2104 "Host: www.google.com\r\n" |
| 2153 "Proxy-Connection: keep-alive\r\n\r\n"), | 2105 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 2154 | 2106 |
| 2155 MockWrite("GET / HTTP/1.1\r\n" | 2107 MockWrite("GET / HTTP/1.1\r\n" |
| 2156 "Host: www.google.com\r\n" | 2108 "Host: www.google.com\r\n" |
| 2157 "Connection: keep-alive\r\n\r\n"), | 2109 "Connection: keep-alive\r\n\r\n"), |
| 2158 }; | 2110 }; |
| 2159 | 2111 |
| 2160 MockRead data_reads1[] = { | 2112 MockRead data_reads1[] = { |
| 2161 MockRead("HTTP/1.1 200 Connection Established\r\n\r\n"), | 2113 MockRead("HTTP/1.1 200 Connection Established\r\n\r\n"), |
| 2162 | 2114 |
| 2163 MockRead("HTTP/1.1 407 Unauthorized\r\n"), | 2115 MockRead("HTTP/1.1 407 Unauthorized\r\n"), |
| 2164 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 2116 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 2165 MockRead("\r\n"), | 2117 MockRead("\r\n"), |
| 2166 MockRead(SYNCHRONOUS, OK), | 2118 MockRead(SYNCHRONOUS, OK), |
| 2167 }; | 2119 }; |
| 2168 | 2120 |
| 2169 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2121 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 2170 data_writes1, arraysize(data_writes1)); | 2122 data_writes1, arraysize(data_writes1)); |
| 2171 session_deps.socket_factory.AddSocketDataProvider(&data1); | 2123 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 2172 SSLSocketDataProvider ssl(ASYNC, OK); | 2124 SSLSocketDataProvider ssl(ASYNC, OK); |
| 2173 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2125 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 2174 | 2126 |
| 2175 TestCompletionCallback callback1; | 2127 TestCompletionCallback callback1; |
| 2176 | 2128 |
| 2177 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2129 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2178 | 2130 |
| 2179 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2131 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2180 EXPECT_EQ(ERR_IO_PENDING, rv); | 2132 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2181 | 2133 |
| 2182 rv = callback1.WaitForResult(); | 2134 rv = callback1.WaitForResult(); |
| 2183 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); | 2135 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); |
| 2184 net::CapturingNetLog::CapturedEntryList entries; | 2136 net::CapturingNetLog::CapturedEntryList entries; |
| 2185 log.GetEntries(&entries); | 2137 log.GetEntries(&entries); |
| 2186 size_t pos = ExpectLogContainsSomewhere( | 2138 size_t pos = ExpectLogContainsSomewhere( |
| 2187 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 2139 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 2188 NetLog::PHASE_NONE); | 2140 NetLog::PHASE_NONE); |
| 2189 ExpectLogContainsSomewhere( | 2141 ExpectLogContainsSomewhere( |
| 2190 entries, pos, | 2142 entries, pos, |
| 2191 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 2143 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 2192 NetLog::PHASE_NONE); | 2144 NetLog::PHASE_NONE); |
| 2193 } | 2145 } |
| 2194 | 2146 |
| 2195 // Test a simple get through an HTTPS Proxy. | 2147 // Test a simple get through an HTTPS Proxy. |
| 2196 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxyGet) { | 2148 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxyGet) { |
| 2197 HttpRequestInfo request; | 2149 HttpRequestInfo request; |
| 2198 request.method = "GET"; | 2150 request.method = "GET"; |
| 2199 request.url = GURL("http://www.google.com/"); | 2151 request.url = GURL("http://www.google.com/"); |
| 2200 | 2152 |
| 2201 // Configure against https proxy server "proxy:70". | 2153 // Configure against https proxy server "proxy:70". |
| 2202 SessionDependencies session_deps(ProxyService::CreateFixed( | 2154 SpdySessionDependencies session_deps(ProxyService::CreateFixed( |
| 2203 "https://proxy:70")); | 2155 "https://proxy:70")); |
| 2204 CapturingBoundNetLog log; | 2156 CapturingBoundNetLog log; |
| 2205 session_deps.net_log = log.bound().net_log(); | 2157 session_deps.net_log = log.bound().net_log(); |
| 2206 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2158 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2207 | 2159 |
| 2208 // Since we have proxy, should use full url | 2160 // Since we have proxy, should use full url |
| 2209 MockWrite data_writes1[] = { | 2161 MockWrite data_writes1[] = { |
| 2210 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" | 2162 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" |
| 2211 "Host: www.google.com\r\n" | 2163 "Host: www.google.com\r\n" |
| 2212 "Proxy-Connection: keep-alive\r\n\r\n"), | 2164 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 2213 }; | 2165 }; |
| 2214 | 2166 |
| 2215 MockRead data_reads1[] = { | 2167 MockRead data_reads1[] = { |
| 2216 MockRead("HTTP/1.1 200 OK\r\n"), | 2168 MockRead("HTTP/1.1 200 OK\r\n"), |
| 2217 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 2169 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 2218 MockRead("Content-Length: 100\r\n\r\n"), | 2170 MockRead("Content-Length: 100\r\n\r\n"), |
| 2219 MockRead(SYNCHRONOUS, OK), | 2171 MockRead(SYNCHRONOUS, OK), |
| 2220 }; | 2172 }; |
| 2221 | 2173 |
| 2222 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2174 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 2223 data_writes1, arraysize(data_writes1)); | 2175 data_writes1, arraysize(data_writes1)); |
| 2224 session_deps.socket_factory.AddSocketDataProvider(&data1); | 2176 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 2225 SSLSocketDataProvider ssl(ASYNC, OK); | 2177 SSLSocketDataProvider ssl(ASYNC, OK); |
| 2226 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2178 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 2227 | 2179 |
| 2228 TestCompletionCallback callback1; | 2180 TestCompletionCallback callback1; |
| 2229 | 2181 |
| 2230 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2182 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2231 | 2183 |
| 2232 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2184 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2233 EXPECT_EQ(ERR_IO_PENDING, rv); | 2185 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2234 | 2186 |
| 2235 rv = callback1.WaitForResult(); | 2187 rv = callback1.WaitForResult(); |
| 2236 EXPECT_EQ(OK, rv); | 2188 EXPECT_EQ(OK, rv); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2248 } | 2200 } |
| 2249 | 2201 |
| 2250 // Test a SPDY get through an HTTPS Proxy. | 2202 // Test a SPDY get through an HTTPS Proxy. |
| 2251 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyGet) { | 2203 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyGet) { |
| 2252 HttpRequestInfo request; | 2204 HttpRequestInfo request; |
| 2253 request.method = "GET"; | 2205 request.method = "GET"; |
| 2254 request.url = GURL("http://www.google.com/"); | 2206 request.url = GURL("http://www.google.com/"); |
| 2255 request.load_flags = 0; | 2207 request.load_flags = 0; |
| 2256 | 2208 |
| 2257 // Configure against https proxy server "proxy:70". | 2209 // Configure against https proxy server "proxy:70". |
| 2258 SessionDependencies session_deps(ProxyService::CreateFixed( | 2210 SpdySessionDependencies session_deps(ProxyService::CreateFixed( |
| 2259 "https://proxy:70")); | 2211 "https://proxy:70")); |
| 2260 CapturingBoundNetLog log; | 2212 CapturingBoundNetLog log; |
| 2261 session_deps.net_log = log.bound().net_log(); | 2213 session_deps.net_log = log.bound().net_log(); |
| 2262 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2214 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2263 | 2215 |
| 2264 // fetch http://www.google.com/ via SPDY | 2216 // fetch http://www.google.com/ via SPDY |
| 2265 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST, | 2217 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST, |
| 2266 false)); | 2218 false)); |
| 2267 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 2219 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
| 2268 | 2220 |
| 2269 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 2221 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 2270 scoped_ptr<SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); | 2222 scoped_ptr<SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); |
| 2271 MockRead spdy_reads[] = { | 2223 MockRead spdy_reads[] = { |
| 2272 CreateMockRead(*resp), | 2224 CreateMockRead(*resp), |
| 2273 CreateMockRead(*data), | 2225 CreateMockRead(*data), |
| 2274 MockRead(ASYNC, 0, 0), | 2226 MockRead(ASYNC, 0, 0), |
| 2275 }; | 2227 }; |
| 2276 | 2228 |
| 2277 DelayedSocketData spdy_data( | 2229 DelayedSocketData spdy_data( |
| 2278 1, // wait for one write to finish before reading. | 2230 1, // wait for one write to finish before reading. |
| 2279 spdy_reads, arraysize(spdy_reads), | 2231 spdy_reads, arraysize(spdy_reads), |
| 2280 spdy_writes, arraysize(spdy_writes)); | 2232 spdy_writes, arraysize(spdy_writes)); |
| 2281 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 2233 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 2282 | 2234 |
| 2283 SSLSocketDataProvider ssl(ASYNC, OK); | 2235 SSLSocketDataProvider ssl(ASYNC, OK); |
| 2284 ssl.SetNextProto(kProtoSPDY2); | 2236 ssl.SetNextProto(kProtoSPDY2); |
| 2285 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2237 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 2286 | 2238 |
| 2287 TestCompletionCallback callback1; | 2239 TestCompletionCallback callback1; |
| 2288 | 2240 |
| 2289 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2241 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2290 | 2242 |
| 2291 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2243 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2292 EXPECT_EQ(ERR_IO_PENDING, rv); | 2244 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2293 | 2245 |
| 2294 rv = callback1.WaitForResult(); | 2246 rv = callback1.WaitForResult(); |
| 2295 EXPECT_EQ(OK, rv); | 2247 EXPECT_EQ(OK, rv); |
| 2296 | 2248 |
| 2297 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2249 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2298 ASSERT_TRUE(response != NULL); | 2250 ASSERT_TRUE(response != NULL); |
| 2299 ASSERT_TRUE(response->headers != NULL); | 2251 ASSERT_TRUE(response->headers != NULL); |
| 2300 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2252 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 2301 | 2253 |
| 2302 std::string response_data; | 2254 std::string response_data; |
| 2303 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 2255 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 2304 EXPECT_EQ(kUploadData, response_data); | 2256 EXPECT_EQ(kUploadData, response_data); |
| 2305 } | 2257 } |
| 2306 | 2258 |
| 2307 // Test a SPDY get through an HTTPS Proxy. | 2259 // Test a SPDY get through an HTTPS Proxy. |
| 2308 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyGetWithProxyAuth) { | 2260 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyGetWithProxyAuth) { |
| 2309 HttpRequestInfo request; | 2261 HttpRequestInfo request; |
| 2310 request.method = "GET"; | 2262 request.method = "GET"; |
| 2311 request.url = GURL("http://www.google.com/"); | 2263 request.url = GURL("http://www.google.com/"); |
| 2312 request.load_flags = 0; | 2264 request.load_flags = 0; |
| 2313 | 2265 |
| 2314 // Configure against https proxy server "myproxy:70". | 2266 // Configure against https proxy server "myproxy:70". |
| 2315 SessionDependencies session_deps( | 2267 SpdySessionDependencies session_deps( |
| 2316 ProxyService::CreateFixed("https://myproxy:70")); | 2268 ProxyService::CreateFixed("https://myproxy:70")); |
| 2317 CapturingBoundNetLog log; | 2269 CapturingBoundNetLog log; |
| 2318 session_deps.net_log = log.bound().net_log(); | 2270 session_deps.net_log = log.bound().net_log(); |
| 2319 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2271 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2320 | 2272 |
| 2321 // The first request will be a bare GET, the second request will be a | 2273 // The first request will be a bare GET, the second request will be a |
| 2322 // GET with a Proxy-Authorization header. | 2274 // GET with a Proxy-Authorization header. |
| 2323 scoped_ptr<SpdyFrame> req_get( | 2275 scoped_ptr<SpdyFrame> req_get( |
| 2324 ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); | 2276 ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false)); |
| 2325 const char* const kExtraAuthorizationHeaders[] = { | 2277 const char* const kExtraAuthorizationHeaders[] = { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2355 CreateMockRead(*resp_authentication, 2), | 2307 CreateMockRead(*resp_authentication, 2), |
| 2356 CreateMockRead(*body_authentication, 3), | 2308 CreateMockRead(*body_authentication, 3), |
| 2357 CreateMockRead(*resp_data, 5), | 2309 CreateMockRead(*resp_data, 5), |
| 2358 CreateMockRead(*body_data, 6), | 2310 CreateMockRead(*body_data, 6), |
| 2359 MockRead(ASYNC, 0, 7), | 2311 MockRead(ASYNC, 0, 7), |
| 2360 }; | 2312 }; |
| 2361 | 2313 |
| 2362 OrderedSocketData data( | 2314 OrderedSocketData data( |
| 2363 spdy_reads, arraysize(spdy_reads), | 2315 spdy_reads, arraysize(spdy_reads), |
| 2364 spdy_writes, arraysize(spdy_writes)); | 2316 spdy_writes, arraysize(spdy_writes)); |
| 2365 session_deps.socket_factory.AddSocketDataProvider(&data); | 2317 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 2366 | 2318 |
| 2367 SSLSocketDataProvider ssl(ASYNC, OK); | 2319 SSLSocketDataProvider ssl(ASYNC, OK); |
| 2368 ssl.SetNextProto(kProtoSPDY2); | 2320 ssl.SetNextProto(kProtoSPDY2); |
| 2369 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2321 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 2370 | 2322 |
| 2371 TestCompletionCallback callback1; | 2323 TestCompletionCallback callback1; |
| 2372 | 2324 |
| 2373 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2325 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2374 | 2326 |
| 2375 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2327 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2376 EXPECT_EQ(ERR_IO_PENDING, rv); | 2328 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2377 | 2329 |
| 2378 rv = callback1.WaitForResult(); | 2330 rv = callback1.WaitForResult(); |
| 2379 EXPECT_EQ(OK, rv); | 2331 EXPECT_EQ(OK, rv); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2405 } | 2357 } |
| 2406 | 2358 |
| 2407 // Test a SPDY CONNECT through an HTTPS Proxy to an HTTPS (non-SPDY) Server. | 2359 // Test a SPDY CONNECT through an HTTPS Proxy to an HTTPS (non-SPDY) Server. |
| 2408 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectHttps) { | 2360 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectHttps) { |
| 2409 HttpRequestInfo request; | 2361 HttpRequestInfo request; |
| 2410 request.method = "GET"; | 2362 request.method = "GET"; |
| 2411 request.url = GURL("https://www.google.com/"); | 2363 request.url = GURL("https://www.google.com/"); |
| 2412 request.load_flags = 0; | 2364 request.load_flags = 0; |
| 2413 | 2365 |
| 2414 // Configure against https proxy server "proxy:70". | 2366 // Configure against https proxy server "proxy:70". |
| 2415 SessionDependencies session_deps(ProxyService::CreateFixed( | 2367 SpdySessionDependencies session_deps(ProxyService::CreateFixed( |
| 2416 "https://proxy:70")); | 2368 "https://proxy:70")); |
| 2417 CapturingBoundNetLog log; | 2369 CapturingBoundNetLog log; |
| 2418 session_deps.net_log = log.bound().net_log(); | 2370 session_deps.net_log = log.bound().net_log(); |
| 2419 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2371 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2420 | 2372 |
| 2421 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2373 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2422 | 2374 |
| 2423 // CONNECT to www.google.com:443 via SPDY | 2375 // CONNECT to www.google.com:443 via SPDY |
| 2424 scoped_ptr<SpdyFrame> connect(ConstructSpdyConnect(NULL, 0, 1)); | 2376 scoped_ptr<SpdyFrame> connect(ConstructSpdyConnect(NULL, 0, 1)); |
| 2425 // fetch https://www.google.com/ via HTTP | 2377 // fetch https://www.google.com/ via HTTP |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2449 CreateMockRead(*conn_resp, 2, ASYNC), | 2401 CreateMockRead(*conn_resp, 2, ASYNC), |
| 2450 CreateMockRead(*wrapped_get_resp, 4, ASYNC), | 2402 CreateMockRead(*wrapped_get_resp, 4, ASYNC), |
| 2451 CreateMockRead(*wrapped_body, 6, ASYNC), | 2403 CreateMockRead(*wrapped_body, 6, ASYNC), |
| 2452 CreateMockRead(*wrapped_body, 7, ASYNC), | 2404 CreateMockRead(*wrapped_body, 7, ASYNC), |
| 2453 MockRead(ASYNC, 0, 8), | 2405 MockRead(ASYNC, 0, 8), |
| 2454 }; | 2406 }; |
| 2455 | 2407 |
| 2456 OrderedSocketData spdy_data( | 2408 OrderedSocketData spdy_data( |
| 2457 spdy_reads, arraysize(spdy_reads), | 2409 spdy_reads, arraysize(spdy_reads), |
| 2458 spdy_writes, arraysize(spdy_writes)); | 2410 spdy_writes, arraysize(spdy_writes)); |
| 2459 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 2411 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 2460 | 2412 |
| 2461 SSLSocketDataProvider ssl(ASYNC, OK); | 2413 SSLSocketDataProvider ssl(ASYNC, OK); |
| 2462 ssl.SetNextProto(kProtoSPDY2); | 2414 ssl.SetNextProto(kProtoSPDY2); |
| 2463 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2415 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 2464 SSLSocketDataProvider ssl2(ASYNC, OK); | 2416 SSLSocketDataProvider ssl2(ASYNC, OK); |
| 2465 ssl2.was_npn_negotiated = false; | 2417 ssl2.was_npn_negotiated = false; |
| 2466 ssl2.protocol_negotiated = kProtoUnknown; | 2418 ssl2.protocol_negotiated = kProtoUnknown; |
| 2467 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); | 2419 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl2); |
| 2468 | 2420 |
| 2469 TestCompletionCallback callback1; | 2421 TestCompletionCallback callback1; |
| 2470 | 2422 |
| 2471 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2423 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2472 EXPECT_EQ(ERR_IO_PENDING, rv); | 2424 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2473 | 2425 |
| 2474 rv = callback1.WaitForResult(); | 2426 rv = callback1.WaitForResult(); |
| 2475 EXPECT_EQ(OK, rv); | 2427 EXPECT_EQ(OK, rv); |
| 2476 | 2428 |
| 2477 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2429 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2478 ASSERT_TRUE(response != NULL); | 2430 ASSERT_TRUE(response != NULL); |
| 2479 ASSERT_TRUE(response->headers != NULL); | 2431 ASSERT_TRUE(response->headers != NULL); |
| 2480 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2432 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 2481 | 2433 |
| 2482 std::string response_data; | 2434 std::string response_data; |
| 2483 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 2435 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 2484 EXPECT_EQ("1234567890", response_data); | 2436 EXPECT_EQ("1234567890", response_data); |
| 2485 } | 2437 } |
| 2486 | 2438 |
| 2487 // Test a SPDY CONNECT through an HTTPS Proxy to a SPDY server. | 2439 // Test a SPDY CONNECT through an HTTPS Proxy to a SPDY server. |
| 2488 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectSpdy) { | 2440 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectSpdy) { |
| 2489 HttpRequestInfo request; | 2441 HttpRequestInfo request; |
| 2490 request.method = "GET"; | 2442 request.method = "GET"; |
| 2491 request.url = GURL("https://www.google.com/"); | 2443 request.url = GURL("https://www.google.com/"); |
| 2492 request.load_flags = 0; | 2444 request.load_flags = 0; |
| 2493 | 2445 |
| 2494 // Configure against https proxy server "proxy:70". | 2446 // Configure against https proxy server "proxy:70". |
| 2495 SessionDependencies session_deps(ProxyService::CreateFixed( | 2447 SpdySessionDependencies session_deps(ProxyService::CreateFixed( |
| 2496 "https://proxy:70")); | 2448 "https://proxy:70")); |
| 2497 CapturingBoundNetLog log; | 2449 CapturingBoundNetLog log; |
| 2498 session_deps.net_log = log.bound().net_log(); | 2450 session_deps.net_log = log.bound().net_log(); |
| 2499 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2451 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2500 | 2452 |
| 2501 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2453 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2502 | 2454 |
| 2503 // CONNECT to www.google.com:443 via SPDY | 2455 // CONNECT to www.google.com:443 via SPDY |
| 2504 scoped_ptr<SpdyFrame> connect(ConstructSpdyConnect(NULL, 0, 1)); | 2456 scoped_ptr<SpdyFrame> connect(ConstructSpdyConnect(NULL, 0, 1)); |
| 2505 // fetch https://www.google.com/ via SPDY | 2457 // fetch https://www.google.com/ via SPDY |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2527 MockRead spdy_reads[] = { | 2479 MockRead spdy_reads[] = { |
| 2528 CreateMockRead(*conn_resp, 2, ASYNC), | 2480 CreateMockRead(*conn_resp, 2, ASYNC), |
| 2529 CreateMockRead(*wrapped_get_resp, 4, ASYNC), | 2481 CreateMockRead(*wrapped_get_resp, 4, ASYNC), |
| 2530 CreateMockRead(*wrapped_body, 6, ASYNC), | 2482 CreateMockRead(*wrapped_body, 6, ASYNC), |
| 2531 MockRead(ASYNC, 0, 8), | 2483 MockRead(ASYNC, 0, 8), |
| 2532 }; | 2484 }; |
| 2533 | 2485 |
| 2534 OrderedSocketData spdy_data( | 2486 OrderedSocketData spdy_data( |
| 2535 spdy_reads, arraysize(spdy_reads), | 2487 spdy_reads, arraysize(spdy_reads), |
| 2536 spdy_writes, arraysize(spdy_writes)); | 2488 spdy_writes, arraysize(spdy_writes)); |
| 2537 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 2489 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 2538 | 2490 |
| 2539 SSLSocketDataProvider ssl(ASYNC, OK); | 2491 SSLSocketDataProvider ssl(ASYNC, OK); |
| 2540 ssl.SetNextProto(kProtoSPDY2); | 2492 ssl.SetNextProto(kProtoSPDY2); |
| 2541 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2493 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 2542 SSLSocketDataProvider ssl2(ASYNC, OK); | 2494 SSLSocketDataProvider ssl2(ASYNC, OK); |
| 2543 ssl2.SetNextProto(kProtoSPDY2); | 2495 ssl2.SetNextProto(kProtoSPDY2); |
| 2544 ssl2.protocol_negotiated = kProtoSPDY2; | 2496 ssl2.protocol_negotiated = kProtoSPDY2; |
| 2545 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); | 2497 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl2); |
| 2546 | 2498 |
| 2547 TestCompletionCallback callback1; | 2499 TestCompletionCallback callback1; |
| 2548 | 2500 |
| 2549 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2501 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2550 EXPECT_EQ(ERR_IO_PENDING, rv); | 2502 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2551 | 2503 |
| 2552 rv = callback1.WaitForResult(); | 2504 rv = callback1.WaitForResult(); |
| 2553 EXPECT_EQ(OK, rv); | 2505 EXPECT_EQ(OK, rv); |
| 2554 | 2506 |
| 2555 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2507 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2556 ASSERT_TRUE(response != NULL); | 2508 ASSERT_TRUE(response != NULL); |
| 2557 ASSERT_TRUE(response->headers != NULL); | 2509 ASSERT_TRUE(response->headers != NULL); |
| 2558 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 2510 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 2559 | 2511 |
| 2560 std::string response_data; | 2512 std::string response_data; |
| 2561 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 2513 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 2562 EXPECT_EQ(kUploadData, response_data); | 2514 EXPECT_EQ(kUploadData, response_data); |
| 2563 } | 2515 } |
| 2564 | 2516 |
| 2565 // Test a SPDY CONNECT failure through an HTTPS Proxy. | 2517 // Test a SPDY CONNECT failure through an HTTPS Proxy. |
| 2566 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectFailure) { | 2518 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxySpdyConnectFailure) { |
| 2567 HttpRequestInfo request; | 2519 HttpRequestInfo request; |
| 2568 request.method = "GET"; | 2520 request.method = "GET"; |
| 2569 request.url = GURL("https://www.google.com/"); | 2521 request.url = GURL("https://www.google.com/"); |
| 2570 request.load_flags = 0; | 2522 request.load_flags = 0; |
| 2571 | 2523 |
| 2572 // Configure against https proxy server "proxy:70". | 2524 // Configure against https proxy server "proxy:70". |
| 2573 SessionDependencies session_deps(ProxyService::CreateFixed( | 2525 SpdySessionDependencies session_deps(ProxyService::CreateFixed( |
| 2574 "https://proxy:70")); | 2526 "https://proxy:70")); |
| 2575 CapturingBoundNetLog log; | 2527 CapturingBoundNetLog log; |
| 2576 session_deps.net_log = log.bound().net_log(); | 2528 session_deps.net_log = log.bound().net_log(); |
| 2577 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2529 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2578 | 2530 |
| 2579 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2531 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2580 | 2532 |
| 2581 // CONNECT to www.google.com:443 via SPDY | 2533 // CONNECT to www.google.com:443 via SPDY |
| 2582 scoped_ptr<SpdyFrame> connect(ConstructSpdyConnect(NULL, 0, 1)); | 2534 scoped_ptr<SpdyFrame> connect(ConstructSpdyConnect(NULL, 0, 1)); |
| 2583 scoped_ptr<SpdyFrame> get(ConstructSpdyRstStream(1, CANCEL)); | 2535 scoped_ptr<SpdyFrame> get(ConstructSpdyRstStream(1, CANCEL)); |
| 2584 | 2536 |
| 2585 MockWrite spdy_writes[] = { | 2537 MockWrite spdy_writes[] = { |
| 2586 CreateMockWrite(*connect, 1), | 2538 CreateMockWrite(*connect, 1), |
| 2587 CreateMockWrite(*get, 3), | 2539 CreateMockWrite(*get, 3), |
| 2588 }; | 2540 }; |
| 2589 | 2541 |
| 2590 scoped_ptr<SpdyFrame> resp(ConstructSpdySynReplyError(1)); | 2542 scoped_ptr<SpdyFrame> resp(ConstructSpdySynReplyError(1)); |
| 2591 scoped_ptr<SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); | 2543 scoped_ptr<SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); |
| 2592 MockRead spdy_reads[] = { | 2544 MockRead spdy_reads[] = { |
| 2593 CreateMockRead(*resp, 2, ASYNC), | 2545 CreateMockRead(*resp, 2, ASYNC), |
| 2594 MockRead(ASYNC, 0, 4), | 2546 MockRead(ASYNC, 0, 4), |
| 2595 }; | 2547 }; |
| 2596 | 2548 |
| 2597 OrderedSocketData spdy_data( | 2549 OrderedSocketData spdy_data( |
| 2598 spdy_reads, arraysize(spdy_reads), | 2550 spdy_reads, arraysize(spdy_reads), |
| 2599 spdy_writes, arraysize(spdy_writes)); | 2551 spdy_writes, arraysize(spdy_writes)); |
| 2600 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 2552 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 2601 | 2553 |
| 2602 SSLSocketDataProvider ssl(ASYNC, OK); | 2554 SSLSocketDataProvider ssl(ASYNC, OK); |
| 2603 ssl.SetNextProto(kProtoSPDY2); | 2555 ssl.SetNextProto(kProtoSPDY2); |
| 2604 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2556 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 2605 SSLSocketDataProvider ssl2(ASYNC, OK); | 2557 SSLSocketDataProvider ssl2(ASYNC, OK); |
| 2606 ssl2.SetNextProto(kProtoSPDY2); | 2558 ssl2.SetNextProto(kProtoSPDY2); |
| 2607 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); | 2559 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl2); |
| 2608 | 2560 |
| 2609 TestCompletionCallback callback1; | 2561 TestCompletionCallback callback1; |
| 2610 | 2562 |
| 2611 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2563 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2612 EXPECT_EQ(ERR_IO_PENDING, rv); | 2564 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2613 | 2565 |
| 2614 rv = callback1.WaitForResult(); | 2566 rv = callback1.WaitForResult(); |
| 2615 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); | 2567 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); |
| 2616 | 2568 |
| 2617 // TODO(ttuttle): Anything else to check here? | 2569 // TODO(ttuttle): Anything else to check here? |
| 2618 } | 2570 } |
| 2619 | 2571 |
| 2620 // Test the challenge-response-retry sequence through an HTTPS Proxy | 2572 // Test the challenge-response-retry sequence through an HTTPS Proxy |
| 2621 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxyAuthRetry) { | 2573 TEST_F(HttpNetworkTransactionSpdy2Test, HttpsProxyAuthRetry) { |
| 2622 HttpRequestInfo request; | 2574 HttpRequestInfo request; |
| 2623 request.method = "GET"; | 2575 request.method = "GET"; |
| 2624 request.url = GURL("http://www.google.com/"); | 2576 request.url = GURL("http://www.google.com/"); |
| 2625 // when the no authentication data flag is set. | 2577 // when the no authentication data flag is set. |
| 2626 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 2578 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
| 2627 | 2579 |
| 2628 // Configure against https proxy server "myproxy:70". | 2580 // Configure against https proxy server "myproxy:70". |
| 2629 SessionDependencies session_deps( | 2581 SpdySessionDependencies session_deps( |
| 2630 ProxyService::CreateFixed("https://myproxy:70")); | 2582 ProxyService::CreateFixed("https://myproxy:70")); |
| 2631 CapturingBoundNetLog log; | 2583 CapturingBoundNetLog log; |
| 2632 session_deps.net_log = log.bound().net_log(); | 2584 session_deps.net_log = log.bound().net_log(); |
| 2633 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2585 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2634 | 2586 |
| 2635 // Since we have proxy, should use full url | 2587 // Since we have proxy, should use full url |
| 2636 MockWrite data_writes1[] = { | 2588 MockWrite data_writes1[] = { |
| 2637 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" | 2589 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" |
| 2638 "Host: www.google.com\r\n" | 2590 "Host: www.google.com\r\n" |
| 2639 "Proxy-Connection: keep-alive\r\n\r\n"), | 2591 "Proxy-Connection: keep-alive\r\n\r\n"), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2656 MockRead("Content-Length: 0\r\n\r\n"), | 2608 MockRead("Content-Length: 0\r\n\r\n"), |
| 2657 | 2609 |
| 2658 MockRead("HTTP/1.1 200 OK\r\n"), | 2610 MockRead("HTTP/1.1 200 OK\r\n"), |
| 2659 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 2611 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 2660 MockRead("Content-Length: 100\r\n\r\n"), | 2612 MockRead("Content-Length: 100\r\n\r\n"), |
| 2661 MockRead(SYNCHRONOUS, OK), | 2613 MockRead(SYNCHRONOUS, OK), |
| 2662 }; | 2614 }; |
| 2663 | 2615 |
| 2664 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2616 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 2665 data_writes1, arraysize(data_writes1)); | 2617 data_writes1, arraysize(data_writes1)); |
| 2666 session_deps.socket_factory.AddSocketDataProvider(&data1); | 2618 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 2667 SSLSocketDataProvider ssl(ASYNC, OK); | 2619 SSLSocketDataProvider ssl(ASYNC, OK); |
| 2668 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 2620 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 2669 | 2621 |
| 2670 TestCompletionCallback callback1; | 2622 TestCompletionCallback callback1; |
| 2671 | 2623 |
| 2672 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2624 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2673 | 2625 |
| 2674 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2626 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2675 EXPECT_EQ(ERR_IO_PENDING, rv); | 2627 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2676 | 2628 |
| 2677 rv = callback1.WaitForResult(); | 2629 rv = callback1.WaitForResult(); |
| 2678 EXPECT_EQ(OK, rv); | 2630 EXPECT_EQ(OK, rv); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2706 } | 2658 } |
| 2707 | 2659 |
| 2708 void HttpNetworkTransactionSpdy2Test::ConnectStatusHelperWithExpectedStatus( | 2660 void HttpNetworkTransactionSpdy2Test::ConnectStatusHelperWithExpectedStatus( |
| 2709 const MockRead& status, int expected_status) { | 2661 const MockRead& status, int expected_status) { |
| 2710 HttpRequestInfo request; | 2662 HttpRequestInfo request; |
| 2711 request.method = "GET"; | 2663 request.method = "GET"; |
| 2712 request.url = GURL("https://www.google.com/"); | 2664 request.url = GURL("https://www.google.com/"); |
| 2713 request.load_flags = 0; | 2665 request.load_flags = 0; |
| 2714 | 2666 |
| 2715 // Configure against proxy server "myproxy:70". | 2667 // Configure against proxy server "myproxy:70". |
| 2716 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 2668 SpdySessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 2717 | 2669 |
| 2718 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 2670 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 2719 | 2671 |
| 2720 // Since we have proxy, should try to establish tunnel. | 2672 // Since we have proxy, should try to establish tunnel. |
| 2721 MockWrite data_writes[] = { | 2673 MockWrite data_writes[] = { |
| 2722 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 2674 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 2723 "Host: www.google.com\r\n" | 2675 "Host: www.google.com\r\n" |
| 2724 "Proxy-Connection: keep-alive\r\n\r\n"), | 2676 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 2725 }; | 2677 }; |
| 2726 | 2678 |
| 2727 MockRead data_reads[] = { | 2679 MockRead data_reads[] = { |
| 2728 status, | 2680 status, |
| 2729 MockRead("Content-Length: 10\r\n\r\n"), | 2681 MockRead("Content-Length: 10\r\n\r\n"), |
| 2730 // No response body because the test stops reading here. | 2682 // No response body because the test stops reading here. |
| 2731 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. | 2683 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. |
| 2732 }; | 2684 }; |
| 2733 | 2685 |
| 2734 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 2686 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 2735 data_writes, arraysize(data_writes)); | 2687 data_writes, arraysize(data_writes)); |
| 2736 session_deps.socket_factory.AddSocketDataProvider(&data); | 2688 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 2737 | 2689 |
| 2738 TestCompletionCallback callback; | 2690 TestCompletionCallback callback; |
| 2739 | 2691 |
| 2740 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 2692 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 2741 | 2693 |
| 2742 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 2694 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 2743 EXPECT_EQ(ERR_IO_PENDING, rv); | 2695 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2744 | 2696 |
| 2745 rv = callback.WaitForResult(); | 2697 rv = callback.WaitForResult(); |
| 2746 EXPECT_EQ(expected_status, rv); | 2698 EXPECT_EQ(expected_status, rv); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2918 | 2870 |
| 2919 // Test the flow when both the proxy server AND origin server require | 2871 // Test the flow when both the proxy server AND origin server require |
| 2920 // authentication. Again, this uses basic auth for both since that is | 2872 // authentication. Again, this uses basic auth for both since that is |
| 2921 // the simplest to mock. | 2873 // the simplest to mock. |
| 2922 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyThenServer) { | 2874 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyThenServer) { |
| 2923 HttpRequestInfo request; | 2875 HttpRequestInfo request; |
| 2924 request.method = "GET"; | 2876 request.method = "GET"; |
| 2925 request.url = GURL("http://www.google.com/"); | 2877 request.url = GURL("http://www.google.com/"); |
| 2926 request.load_flags = 0; | 2878 request.load_flags = 0; |
| 2927 | 2879 |
| 2928 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 2880 SpdySessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 2929 | 2881 |
| 2930 // Configure against proxy server "myproxy:70". | 2882 // Configure against proxy server "myproxy:70". |
| 2931 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( | 2883 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( |
| 2932 CreateSession(&session_deps))); | 2884 CreateSession(&session_deps))); |
| 2933 | 2885 |
| 2934 MockWrite data_writes1[] = { | 2886 MockWrite data_writes1[] = { |
| 2935 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" | 2887 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" |
| 2936 "Host: www.google.com\r\n" | 2888 "Host: www.google.com\r\n" |
| 2937 "Proxy-Connection: keep-alive\r\n\r\n"), | 2889 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 2938 }; | 2890 }; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2989 MockRead("Content-Length: 100\r\n\r\n"), | 2941 MockRead("Content-Length: 100\r\n\r\n"), |
| 2990 MockRead(SYNCHRONOUS, OK), | 2942 MockRead(SYNCHRONOUS, OK), |
| 2991 }; | 2943 }; |
| 2992 | 2944 |
| 2993 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 2945 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 2994 data_writes1, arraysize(data_writes1)); | 2946 data_writes1, arraysize(data_writes1)); |
| 2995 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 2947 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 2996 data_writes2, arraysize(data_writes2)); | 2948 data_writes2, arraysize(data_writes2)); |
| 2997 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), | 2949 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), |
| 2998 data_writes3, arraysize(data_writes3)); | 2950 data_writes3, arraysize(data_writes3)); |
| 2999 session_deps.socket_factory.AddSocketDataProvider(&data1); | 2951 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 3000 session_deps.socket_factory.AddSocketDataProvider(&data2); | 2952 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 3001 session_deps.socket_factory.AddSocketDataProvider(&data3); | 2953 session_deps.socket_factory->AddSocketDataProvider(&data3); |
| 3002 | 2954 |
| 3003 TestCompletionCallback callback1; | 2955 TestCompletionCallback callback1; |
| 3004 | 2956 |
| 3005 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 2957 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 3006 EXPECT_EQ(ERR_IO_PENDING, rv); | 2958 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3007 | 2959 |
| 3008 rv = callback1.WaitForResult(); | 2960 rv = callback1.WaitForResult(); |
| 3009 EXPECT_EQ(OK, rv); | 2961 EXPECT_EQ(OK, rv); |
| 3010 | 2962 |
| 3011 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2963 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3049 | 3001 |
| 3050 // Enter the correct password and authenticate successfully. | 3002 // Enter the correct password and authenticate successfully. |
| 3051 TEST_F(HttpNetworkTransactionSpdy2Test, NTLMAuth1) { | 3003 TEST_F(HttpNetworkTransactionSpdy2Test, NTLMAuth1) { |
| 3052 HttpRequestInfo request; | 3004 HttpRequestInfo request; |
| 3053 request.method = "GET"; | 3005 request.method = "GET"; |
| 3054 request.url = GURL("http://172.22.68.17/kids/login.aspx"); | 3006 request.url = GURL("http://172.22.68.17/kids/login.aspx"); |
| 3055 request.load_flags = 0; | 3007 request.load_flags = 0; |
| 3056 | 3008 |
| 3057 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom1, | 3009 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom1, |
| 3058 MockGetHostName); | 3010 MockGetHostName); |
| 3059 SessionDependencies session_deps; | 3011 SpdySessionDependencies session_deps; |
| 3060 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3012 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 3061 | 3013 |
| 3062 MockWrite data_writes1[] = { | 3014 MockWrite data_writes1[] = { |
| 3063 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" | 3015 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" |
| 3064 "Host: 172.22.68.17\r\n" | 3016 "Host: 172.22.68.17\r\n" |
| 3065 "Connection: keep-alive\r\n\r\n"), | 3017 "Connection: keep-alive\r\n\r\n"), |
| 3066 }; | 3018 }; |
| 3067 | 3019 |
| 3068 MockRead data_reads1[] = { | 3020 MockRead data_reads1[] = { |
| 3069 MockRead("HTTP/1.1 401 Access Denied\r\n"), | 3021 MockRead("HTTP/1.1 401 Access Denied\r\n"), |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3121 MockRead("Content-Type: text/html; charset=utf-8\r\n"), | 3073 MockRead("Content-Type: text/html; charset=utf-8\r\n"), |
| 3122 MockRead("Content-Length: 13\r\n\r\n"), | 3074 MockRead("Content-Length: 13\r\n\r\n"), |
| 3123 MockRead("Please Login\r\n"), | 3075 MockRead("Please Login\r\n"), |
| 3124 MockRead(SYNCHRONOUS, OK), | 3076 MockRead(SYNCHRONOUS, OK), |
| 3125 }; | 3077 }; |
| 3126 | 3078 |
| 3127 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3079 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 3128 data_writes1, arraysize(data_writes1)); | 3080 data_writes1, arraysize(data_writes1)); |
| 3129 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 3081 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 3130 data_writes2, arraysize(data_writes2)); | 3082 data_writes2, arraysize(data_writes2)); |
| 3131 session_deps.socket_factory.AddSocketDataProvider(&data1); | 3083 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 3132 session_deps.socket_factory.AddSocketDataProvider(&data2); | 3084 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 3133 | 3085 |
| 3134 TestCompletionCallback callback1; | 3086 TestCompletionCallback callback1; |
| 3135 | 3087 |
| 3136 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 3088 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 3137 | 3089 |
| 3138 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 3090 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 3139 EXPECT_EQ(ERR_IO_PENDING, rv); | 3091 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3140 | 3092 |
| 3141 rv = callback1.WaitForResult(); | 3093 rv = callback1.WaitForResult(); |
| 3142 EXPECT_EQ(OK, rv); | 3094 EXPECT_EQ(OK, rv); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3178 | 3130 |
| 3179 // Enter a wrong password, and then the correct one. | 3131 // Enter a wrong password, and then the correct one. |
| 3180 TEST_F(HttpNetworkTransactionSpdy2Test, NTLMAuth2) { | 3132 TEST_F(HttpNetworkTransactionSpdy2Test, NTLMAuth2) { |
| 3181 HttpRequestInfo request; | 3133 HttpRequestInfo request; |
| 3182 request.method = "GET"; | 3134 request.method = "GET"; |
| 3183 request.url = GURL("http://172.22.68.17/kids/login.aspx"); | 3135 request.url = GURL("http://172.22.68.17/kids/login.aspx"); |
| 3184 request.load_flags = 0; | 3136 request.load_flags = 0; |
| 3185 | 3137 |
| 3186 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom2, | 3138 HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom2, |
| 3187 MockGetHostName); | 3139 MockGetHostName); |
| 3188 SessionDependencies session_deps; | 3140 SpdySessionDependencies session_deps; |
| 3189 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3141 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 3190 | 3142 |
| 3191 MockWrite data_writes1[] = { | 3143 MockWrite data_writes1[] = { |
| 3192 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" | 3144 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" |
| 3193 "Host: 172.22.68.17\r\n" | 3145 "Host: 172.22.68.17\r\n" |
| 3194 "Connection: keep-alive\r\n\r\n"), | 3146 "Connection: keep-alive\r\n\r\n"), |
| 3195 }; | 3147 }; |
| 3196 | 3148 |
| 3197 MockRead data_reads1[] = { | 3149 MockRead data_reads1[] = { |
| 3198 MockRead("HTTP/1.1 401 Access Denied\r\n"), | 3150 MockRead("HTTP/1.1 401 Access Denied\r\n"), |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3300 MockRead("Please Login\r\n"), | 3252 MockRead("Please Login\r\n"), |
| 3301 MockRead(SYNCHRONOUS, OK), | 3253 MockRead(SYNCHRONOUS, OK), |
| 3302 }; | 3254 }; |
| 3303 | 3255 |
| 3304 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3256 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 3305 data_writes1, arraysize(data_writes1)); | 3257 data_writes1, arraysize(data_writes1)); |
| 3306 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 3258 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 3307 data_writes2, arraysize(data_writes2)); | 3259 data_writes2, arraysize(data_writes2)); |
| 3308 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), | 3260 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), |
| 3309 data_writes3, arraysize(data_writes3)); | 3261 data_writes3, arraysize(data_writes3)); |
| 3310 session_deps.socket_factory.AddSocketDataProvider(&data1); | 3262 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 3311 session_deps.socket_factory.AddSocketDataProvider(&data2); | 3263 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 3312 session_deps.socket_factory.AddSocketDataProvider(&data3); | 3264 session_deps.socket_factory->AddSocketDataProvider(&data3); |
| 3313 | 3265 |
| 3314 TestCompletionCallback callback1; | 3266 TestCompletionCallback callback1; |
| 3315 | 3267 |
| 3316 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 3268 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 3317 | 3269 |
| 3318 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 3270 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 3319 EXPECT_EQ(ERR_IO_PENDING, rv); | 3271 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3320 | 3272 |
| 3321 rv = callback1.WaitForResult(); | 3273 rv = callback1.WaitForResult(); |
| 3322 EXPECT_EQ(OK, rv); | 3274 EXPECT_EQ(OK, rv); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3378 | 3330 |
| 3379 // Test reading a server response which has only headers, and no body. | 3331 // Test reading a server response which has only headers, and no body. |
| 3380 // After some maximum number of bytes is consumed, the transaction should | 3332 // After some maximum number of bytes is consumed, the transaction should |
| 3381 // fail with ERR_RESPONSE_HEADERS_TOO_BIG. | 3333 // fail with ERR_RESPONSE_HEADERS_TOO_BIG. |
| 3382 TEST_F(HttpNetworkTransactionSpdy2Test, LargeHeadersNoBody) { | 3334 TEST_F(HttpNetworkTransactionSpdy2Test, LargeHeadersNoBody) { |
| 3383 HttpRequestInfo request; | 3335 HttpRequestInfo request; |
| 3384 request.method = "GET"; | 3336 request.method = "GET"; |
| 3385 request.url = GURL("http://www.google.com/"); | 3337 request.url = GURL("http://www.google.com/"); |
| 3386 request.load_flags = 0; | 3338 request.load_flags = 0; |
| 3387 | 3339 |
| 3388 SessionDependencies session_deps; | 3340 SpdySessionDependencies session_deps; |
| 3389 scoped_ptr<HttpTransaction> trans( | 3341 scoped_ptr<HttpTransaction> trans( |
| 3390 new HttpNetworkTransaction(CreateSession(&session_deps))); | 3342 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 3391 | 3343 |
| 3392 // Respond with 300 kb of headers (we should fail after 256 kb). | 3344 // Respond with 300 kb of headers (we should fail after 256 kb). |
| 3393 std::string large_headers_string; | 3345 std::string large_headers_string; |
| 3394 FillLargeHeadersString(&large_headers_string, 300 * 1024); | 3346 FillLargeHeadersString(&large_headers_string, 300 * 1024); |
| 3395 | 3347 |
| 3396 MockRead data_reads[] = { | 3348 MockRead data_reads[] = { |
| 3397 MockRead("HTTP/1.0 200 OK\r\n"), | 3349 MockRead("HTTP/1.0 200 OK\r\n"), |
| 3398 MockRead(ASYNC, large_headers_string.data(), large_headers_string.size()), | 3350 MockRead(ASYNC, large_headers_string.data(), large_headers_string.size()), |
| 3399 MockRead("\r\nBODY"), | 3351 MockRead("\r\nBODY"), |
| 3400 MockRead(SYNCHRONOUS, OK), | 3352 MockRead(SYNCHRONOUS, OK), |
| 3401 }; | 3353 }; |
| 3402 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 3354 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 3403 session_deps.socket_factory.AddSocketDataProvider(&data); | 3355 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 3404 | 3356 |
| 3405 TestCompletionCallback callback; | 3357 TestCompletionCallback callback; |
| 3406 | 3358 |
| 3407 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 3359 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 3408 EXPECT_EQ(ERR_IO_PENDING, rv); | 3360 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3409 | 3361 |
| 3410 rv = callback.WaitForResult(); | 3362 rv = callback.WaitForResult(); |
| 3411 EXPECT_EQ(ERR_RESPONSE_HEADERS_TOO_BIG, rv); | 3363 EXPECT_EQ(ERR_RESPONSE_HEADERS_TOO_BIG, rv); |
| 3412 | 3364 |
| 3413 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3365 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3414 EXPECT_TRUE(response == NULL); | 3366 EXPECT_TRUE(response == NULL); |
| 3415 } | 3367 } |
| 3416 | 3368 |
| 3417 // Make sure that we don't try to reuse a TCPClientSocket when failing to | 3369 // Make sure that we don't try to reuse a TCPClientSocket when failing to |
| 3418 // establish tunnel. | 3370 // establish tunnel. |
| 3419 // http://code.google.com/p/chromium/issues/detail?id=3772 | 3371 // http://code.google.com/p/chromium/issues/detail?id=3772 |
| 3420 TEST_F(HttpNetworkTransactionSpdy2Test, | 3372 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 3421 DontRecycleTransportSocketForSSLTunnel) { | 3373 DontRecycleTransportSocketForSSLTunnel) { |
| 3422 HttpRequestInfo request; | 3374 HttpRequestInfo request; |
| 3423 request.method = "GET"; | 3375 request.method = "GET"; |
| 3424 request.url = GURL("https://www.google.com/"); | 3376 request.url = GURL("https://www.google.com/"); |
| 3425 request.load_flags = 0; | 3377 request.load_flags = 0; |
| 3426 | 3378 |
| 3427 // Configure against proxy server "myproxy:70". | 3379 // Configure against proxy server "myproxy:70". |
| 3428 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 3380 SpdySessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 3429 | 3381 |
| 3430 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3382 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 3431 | 3383 |
| 3432 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 3384 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 3433 | 3385 |
| 3434 // Since we have proxy, should try to establish tunnel. | 3386 // Since we have proxy, should try to establish tunnel. |
| 3435 MockWrite data_writes1[] = { | 3387 MockWrite data_writes1[] = { |
| 3436 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 3388 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 3437 "Host: www.google.com\r\n" | 3389 "Host: www.google.com\r\n" |
| 3438 "Proxy-Connection: keep-alive\r\n\r\n"), | 3390 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 3439 }; | 3391 }; |
| 3440 | 3392 |
| 3441 // The proxy responds to the connect with a 404, using a persistent | 3393 // The proxy responds to the connect with a 404, using a persistent |
| 3442 // connection. Usually a proxy would return 501 (not implemented), | 3394 // connection. Usually a proxy would return 501 (not implemented), |
| 3443 // or 200 (tunnel established). | 3395 // or 200 (tunnel established). |
| 3444 MockRead data_reads1[] = { | 3396 MockRead data_reads1[] = { |
| 3445 MockRead("HTTP/1.1 404 Not Found\r\n"), | 3397 MockRead("HTTP/1.1 404 Not Found\r\n"), |
| 3446 MockRead("Content-Length: 10\r\n\r\n"), | 3398 MockRead("Content-Length: 10\r\n\r\n"), |
| 3447 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. | 3399 MockRead(SYNCHRONOUS, ERR_UNEXPECTED), // Should not be reached. |
| 3448 }; | 3400 }; |
| 3449 | 3401 |
| 3450 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3402 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 3451 data_writes1, arraysize(data_writes1)); | 3403 data_writes1, arraysize(data_writes1)); |
| 3452 session_deps.socket_factory.AddSocketDataProvider(&data1); | 3404 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 3453 | 3405 |
| 3454 TestCompletionCallback callback1; | 3406 TestCompletionCallback callback1; |
| 3455 | 3407 |
| 3456 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 3408 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 3457 EXPECT_EQ(ERR_IO_PENDING, rv); | 3409 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3458 | 3410 |
| 3459 rv = callback1.WaitForResult(); | 3411 rv = callback1.WaitForResult(); |
| 3460 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); | 3412 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); |
| 3461 | 3413 |
| 3462 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3414 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3475 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); | 3427 EXPECT_EQ(0, GetIdleSocketCountInTransportSocketPool(session)); |
| 3476 } | 3428 } |
| 3477 | 3429 |
| 3478 // Make sure that we recycle a socket after reading all of the response body. | 3430 // Make sure that we recycle a socket after reading all of the response body. |
| 3479 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSocket) { | 3431 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSocket) { |
| 3480 HttpRequestInfo request; | 3432 HttpRequestInfo request; |
| 3481 request.method = "GET"; | 3433 request.method = "GET"; |
| 3482 request.url = GURL("http://www.google.com/"); | 3434 request.url = GURL("http://www.google.com/"); |
| 3483 request.load_flags = 0; | 3435 request.load_flags = 0; |
| 3484 | 3436 |
| 3485 SessionDependencies session_deps; | 3437 SpdySessionDependencies session_deps; |
| 3486 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3438 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 3487 | 3439 |
| 3488 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 3440 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 3489 | 3441 |
| 3490 MockRead data_reads[] = { | 3442 MockRead data_reads[] = { |
| 3491 // A part of the response body is received with the response headers. | 3443 // A part of the response body is received with the response headers. |
| 3492 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nhel"), | 3444 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nhel"), |
| 3493 // The rest of the response body is received in two parts. | 3445 // The rest of the response body is received in two parts. |
| 3494 MockRead("lo"), | 3446 MockRead("lo"), |
| 3495 MockRead(" world"), | 3447 MockRead(" world"), |
| 3496 MockRead("junk"), // Should not be read!! | 3448 MockRead("junk"), // Should not be read!! |
| 3497 MockRead(SYNCHRONOUS, OK), | 3449 MockRead(SYNCHRONOUS, OK), |
| 3498 }; | 3450 }; |
| 3499 | 3451 |
| 3500 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 3452 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 3501 session_deps.socket_factory.AddSocketDataProvider(&data); | 3453 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 3502 | 3454 |
| 3503 TestCompletionCallback callback; | 3455 TestCompletionCallback callback; |
| 3504 | 3456 |
| 3505 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 3457 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 3506 EXPECT_EQ(ERR_IO_PENDING, rv); | 3458 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3507 | 3459 |
| 3508 rv = callback.WaitForResult(); | 3460 rv = callback.WaitForResult(); |
| 3509 EXPECT_EQ(OK, rv); | 3461 EXPECT_EQ(OK, rv); |
| 3510 | 3462 |
| 3511 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3463 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3526 // added to the connection pool asynchronously with a PostTask. | 3478 // added to the connection pool asynchronously with a PostTask. |
| 3527 MessageLoop::current()->RunUntilIdle(); | 3479 MessageLoop::current()->RunUntilIdle(); |
| 3528 | 3480 |
| 3529 // We now check to make sure the socket was added back to the pool. | 3481 // We now check to make sure the socket was added back to the pool. |
| 3530 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session)); | 3482 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session)); |
| 3531 } | 3483 } |
| 3532 | 3484 |
| 3533 // Make sure that we recycle a SSL socket after reading all of the response | 3485 // Make sure that we recycle a SSL socket after reading all of the response |
| 3534 // body. | 3486 // body. |
| 3535 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSSLSocket) { | 3487 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSSLSocket) { |
| 3536 SessionDependencies session_deps; | 3488 SpdySessionDependencies session_deps; |
| 3537 HttpRequestInfo request; | 3489 HttpRequestInfo request; |
| 3538 request.method = "GET"; | 3490 request.method = "GET"; |
| 3539 request.url = GURL("https://www.google.com/"); | 3491 request.url = GURL("https://www.google.com/"); |
| 3540 request.load_flags = 0; | 3492 request.load_flags = 0; |
| 3541 | 3493 |
| 3542 MockWrite data_writes[] = { | 3494 MockWrite data_writes[] = { |
| 3543 MockWrite("GET / HTTP/1.1\r\n" | 3495 MockWrite("GET / HTTP/1.1\r\n" |
| 3544 "Host: www.google.com\r\n" | 3496 "Host: www.google.com\r\n" |
| 3545 "Connection: keep-alive\r\n\r\n"), | 3497 "Connection: keep-alive\r\n\r\n"), |
| 3546 }; | 3498 }; |
| 3547 | 3499 |
| 3548 MockRead data_reads[] = { | 3500 MockRead data_reads[] = { |
| 3549 MockRead("HTTP/1.1 200 OK\r\n"), | 3501 MockRead("HTTP/1.1 200 OK\r\n"), |
| 3550 MockRead("Content-Length: 11\r\n\r\n"), | 3502 MockRead("Content-Length: 11\r\n\r\n"), |
| 3551 MockRead("hello world"), | 3503 MockRead("hello world"), |
| 3552 MockRead(SYNCHRONOUS, OK), | 3504 MockRead(SYNCHRONOUS, OK), |
| 3553 }; | 3505 }; |
| 3554 | 3506 |
| 3555 SSLSocketDataProvider ssl(ASYNC, OK); | 3507 SSLSocketDataProvider ssl(ASYNC, OK); |
| 3556 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 3508 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 3557 | 3509 |
| 3558 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 3510 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 3559 data_writes, arraysize(data_writes)); | 3511 data_writes, arraysize(data_writes)); |
| 3560 session_deps.socket_factory.AddSocketDataProvider(&data); | 3512 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 3561 | 3513 |
| 3562 TestCompletionCallback callback; | 3514 TestCompletionCallback callback; |
| 3563 | 3515 |
| 3564 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3516 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 3565 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 3517 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 3566 | 3518 |
| 3567 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 3519 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 3568 | 3520 |
| 3569 EXPECT_EQ(ERR_IO_PENDING, rv); | 3521 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3570 EXPECT_EQ(OK, callback.WaitForResult()); | 3522 EXPECT_EQ(OK, callback.WaitForResult()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3585 // added to the connection pool asynchronously with a PostTask. | 3537 // added to the connection pool asynchronously with a PostTask. |
| 3586 MessageLoop::current()->RunUntilIdle(); | 3538 MessageLoop::current()->RunUntilIdle(); |
| 3587 | 3539 |
| 3588 // We now check to make sure the socket was added back to the pool. | 3540 // We now check to make sure the socket was added back to the pool. |
| 3589 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session)); | 3541 EXPECT_EQ(1, GetIdleSocketCountInSSLSocketPool(session)); |
| 3590 } | 3542 } |
| 3591 | 3543 |
| 3592 // Grab a SSL socket, use it, and put it back into the pool. Then, reuse it | 3544 // Grab a SSL socket, use it, and put it back into the pool. Then, reuse it |
| 3593 // from the pool and make sure that we recover okay. | 3545 // from the pool and make sure that we recover okay. |
| 3594 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleDeadSSLSocket) { | 3546 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleDeadSSLSocket) { |
| 3595 SessionDependencies session_deps; | 3547 SpdySessionDependencies session_deps; |
| 3596 HttpRequestInfo request; | 3548 HttpRequestInfo request; |
| 3597 request.method = "GET"; | 3549 request.method = "GET"; |
| 3598 request.url = GURL("https://www.google.com/"); | 3550 request.url = GURL("https://www.google.com/"); |
| 3599 request.load_flags = 0; | 3551 request.load_flags = 0; |
| 3600 | 3552 |
| 3601 MockWrite data_writes[] = { | 3553 MockWrite data_writes[] = { |
| 3602 MockWrite("GET / HTTP/1.1\r\n" | 3554 MockWrite("GET / HTTP/1.1\r\n" |
| 3603 "Host: www.google.com\r\n" | 3555 "Host: www.google.com\r\n" |
| 3604 "Connection: keep-alive\r\n\r\n"), | 3556 "Connection: keep-alive\r\n\r\n"), |
| 3605 MockWrite("GET / HTTP/1.1\r\n" | 3557 MockWrite("GET / HTTP/1.1\r\n" |
| 3606 "Host: www.google.com\r\n" | 3558 "Host: www.google.com\r\n" |
| 3607 "Connection: keep-alive\r\n\r\n"), | 3559 "Connection: keep-alive\r\n\r\n"), |
| 3608 }; | 3560 }; |
| 3609 | 3561 |
| 3610 MockRead data_reads[] = { | 3562 MockRead data_reads[] = { |
| 3611 MockRead("HTTP/1.1 200 OK\r\n"), | 3563 MockRead("HTTP/1.1 200 OK\r\n"), |
| 3612 MockRead("Content-Length: 11\r\n\r\n"), | 3564 MockRead("Content-Length: 11\r\n\r\n"), |
| 3613 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 3565 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 3614 MockRead("hello world"), | 3566 MockRead("hello world"), |
| 3615 MockRead(ASYNC, 0, 0) // EOF | 3567 MockRead(ASYNC, 0, 0) // EOF |
| 3616 }; | 3568 }; |
| 3617 | 3569 |
| 3618 SSLSocketDataProvider ssl(ASYNC, OK); | 3570 SSLSocketDataProvider ssl(ASYNC, OK); |
| 3619 SSLSocketDataProvider ssl2(ASYNC, OK); | 3571 SSLSocketDataProvider ssl2(ASYNC, OK); |
| 3620 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 3572 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 3621 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl2); | 3573 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl2); |
| 3622 | 3574 |
| 3623 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 3575 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 3624 data_writes, arraysize(data_writes)); | 3576 data_writes, arraysize(data_writes)); |
| 3625 StaticSocketDataProvider data2(data_reads, arraysize(data_reads), | 3577 StaticSocketDataProvider data2(data_reads, arraysize(data_reads), |
| 3626 data_writes, arraysize(data_writes)); | 3578 data_writes, arraysize(data_writes)); |
| 3627 session_deps.socket_factory.AddSocketDataProvider(&data); | 3579 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 3628 session_deps.socket_factory.AddSocketDataProvider(&data2); | 3580 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 3629 | 3581 |
| 3630 TestCompletionCallback callback; | 3582 TestCompletionCallback callback; |
| 3631 | 3583 |
| 3632 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3584 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 3633 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 3585 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 3634 | 3586 |
| 3635 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 3587 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 3636 | 3588 |
| 3637 EXPECT_EQ(ERR_IO_PENDING, rv); | 3589 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3638 EXPECT_EQ(OK, callback.WaitForResult()); | 3590 EXPECT_EQ(OK, callback.WaitForResult()); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3688 // http://crbug.com/9880 | 3640 // http://crbug.com/9880 |
| 3689 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSocketAfterZeroContentLength) { | 3641 TEST_F(HttpNetworkTransactionSpdy2Test, RecycleSocketAfterZeroContentLength) { |
| 3690 HttpRequestInfo request; | 3642 HttpRequestInfo request; |
| 3691 request.method = "GET"; | 3643 request.method = "GET"; |
| 3692 request.url = GURL("http://www.google.com/csi?v=3&s=web&action=&" | 3644 request.url = GURL("http://www.google.com/csi?v=3&s=web&action=&" |
| 3693 "tran=undefined&ei=mAXcSeegAo-SMurloeUN&" | 3645 "tran=undefined&ei=mAXcSeegAo-SMurloeUN&" |
| 3694 "e=17259,18167,19592,19773,19981,20133,20173,20233&" | 3646 "e=17259,18167,19592,19773,19981,20133,20173,20233&" |
| 3695 "rt=prt.2642,ol.2649,xjs.2951"); | 3647 "rt=prt.2642,ol.2649,xjs.2951"); |
| 3696 request.load_flags = 0; | 3648 request.load_flags = 0; |
| 3697 | 3649 |
| 3698 SessionDependencies session_deps; | 3650 SpdySessionDependencies session_deps; |
| 3699 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3651 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 3700 | 3652 |
| 3701 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 3653 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 3702 | 3654 |
| 3703 MockRead data_reads[] = { | 3655 MockRead data_reads[] = { |
| 3704 MockRead("HTTP/1.1 204 No Content\r\n" | 3656 MockRead("HTTP/1.1 204 No Content\r\n" |
| 3705 "Content-Length: 0\r\n" | 3657 "Content-Length: 0\r\n" |
| 3706 "Content-Type: text/html\r\n\r\n"), | 3658 "Content-Type: text/html\r\n\r\n"), |
| 3707 MockRead("junk"), // Should not be read!! | 3659 MockRead("junk"), // Should not be read!! |
| 3708 MockRead(SYNCHRONOUS, OK), | 3660 MockRead(SYNCHRONOUS, OK), |
| 3709 }; | 3661 }; |
| 3710 | 3662 |
| 3711 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 3663 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 3712 session_deps.socket_factory.AddSocketDataProvider(&data); | 3664 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 3713 | 3665 |
| 3714 TestCompletionCallback callback; | 3666 TestCompletionCallback callback; |
| 3715 | 3667 |
| 3716 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 3668 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 3717 EXPECT_EQ(ERR_IO_PENDING, rv); | 3669 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3718 | 3670 |
| 3719 rv = callback.WaitForResult(); | 3671 rv = callback.WaitForResult(); |
| 3720 EXPECT_EQ(OK, rv); | 3672 EXPECT_EQ(OK, rv); |
| 3721 | 3673 |
| 3722 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3674 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3754 request[0].load_flags = 0; | 3706 request[0].load_flags = 0; |
| 3755 // Transaction 2: a POST request. Reuses the socket kept alive from | 3707 // Transaction 2: a POST request. Reuses the socket kept alive from |
| 3756 // transaction 1. The first attempts fails when writing the POST data. | 3708 // transaction 1. The first attempts fails when writing the POST data. |
| 3757 // This causes the transaction to retry with a new socket. The second | 3709 // This causes the transaction to retry with a new socket. The second |
| 3758 // attempt succeeds. | 3710 // attempt succeeds. |
| 3759 request[1].method = "POST"; | 3711 request[1].method = "POST"; |
| 3760 request[1].url = GURL("http://www.google.com/login.cgi"); | 3712 request[1].url = GURL("http://www.google.com/login.cgi"); |
| 3761 request[1].upload_data_stream = &upload_data_stream; | 3713 request[1].upload_data_stream = &upload_data_stream; |
| 3762 request[1].load_flags = 0; | 3714 request[1].load_flags = 0; |
| 3763 | 3715 |
| 3764 SessionDependencies session_deps; | 3716 SpdySessionDependencies session_deps; |
| 3765 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3717 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 3766 | 3718 |
| 3767 // The first socket is used for transaction 1 and the first attempt of | 3719 // The first socket is used for transaction 1 and the first attempt of |
| 3768 // transaction 2. | 3720 // transaction 2. |
| 3769 | 3721 |
| 3770 // The response of transaction 1. | 3722 // The response of transaction 1. |
| 3771 MockRead data_reads1[] = { | 3723 MockRead data_reads1[] = { |
| 3772 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\n"), | 3724 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\n"), |
| 3773 MockRead("hello world"), | 3725 MockRead("hello world"), |
| 3774 MockRead(SYNCHRONOUS, OK), | 3726 MockRead(SYNCHRONOUS, OK), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3792 MockRead(SYNCHRONOUS, OK), | 3744 MockRead(SYNCHRONOUS, OK), |
| 3793 }; | 3745 }; |
| 3794 // The mock write results of the second attempt of transaction 2. | 3746 // The mock write results of the second attempt of transaction 2. |
| 3795 MockWrite data_writes2[] = { | 3747 MockWrite data_writes2[] = { |
| 3796 MockWrite(SYNCHRONOUS, 93), // POST | 3748 MockWrite(SYNCHRONOUS, 93), // POST |
| 3797 MockWrite(SYNCHRONOUS, 3), // POST data | 3749 MockWrite(SYNCHRONOUS, 3), // POST data |
| 3798 }; | 3750 }; |
| 3799 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 3751 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 3800 data_writes2, arraysize(data_writes2)); | 3752 data_writes2, arraysize(data_writes2)); |
| 3801 | 3753 |
| 3802 session_deps.socket_factory.AddSocketDataProvider(&data1); | 3754 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 3803 session_deps.socket_factory.AddSocketDataProvider(&data2); | 3755 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 3804 | 3756 |
| 3805 const char* kExpectedResponseData[] = { | 3757 const char* kExpectedResponseData[] = { |
| 3806 "hello world", "welcome" | 3758 "hello world", "welcome" |
| 3807 }; | 3759 }; |
| 3808 | 3760 |
| 3809 for (int i = 0; i < 2; ++i) { | 3761 for (int i = 0; i < 2; ++i) { |
| 3810 scoped_ptr<HttpTransaction> trans( | 3762 scoped_ptr<HttpTransaction> trans( |
| 3811 new HttpNetworkTransaction(session)); | 3763 new HttpNetworkTransaction(session)); |
| 3812 | 3764 |
| 3813 TestCompletionCallback callback; | 3765 TestCompletionCallback callback; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3833 | 3785 |
| 3834 // Test the request-challenge-retry sequence for basic auth when there is | 3786 // Test the request-challenge-retry sequence for basic auth when there is |
| 3835 // an identity in the URL. The request should be sent as normal, but when | 3787 // an identity in the URL. The request should be sent as normal, but when |
| 3836 // it fails the identity from the URL is used to answer the challenge. | 3788 // it fails the identity from the URL is used to answer the challenge. |
| 3837 TEST_F(HttpNetworkTransactionSpdy2Test, AuthIdentityInURL) { | 3789 TEST_F(HttpNetworkTransactionSpdy2Test, AuthIdentityInURL) { |
| 3838 HttpRequestInfo request; | 3790 HttpRequestInfo request; |
| 3839 request.method = "GET"; | 3791 request.method = "GET"; |
| 3840 request.url = GURL("http://foo:b@r@www.google.com/"); | 3792 request.url = GURL("http://foo:b@r@www.google.com/"); |
| 3841 request.load_flags = LOAD_NORMAL; | 3793 request.load_flags = LOAD_NORMAL; |
| 3842 | 3794 |
| 3843 SessionDependencies session_deps; | 3795 SpdySessionDependencies session_deps; |
| 3844 scoped_ptr<HttpTransaction> trans( | 3796 scoped_ptr<HttpTransaction> trans( |
| 3845 new HttpNetworkTransaction(CreateSession(&session_deps))); | 3797 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 3846 | 3798 |
| 3847 // The password contains an escaped character -- for this test to pass it | 3799 // The password contains an escaped character -- for this test to pass it |
| 3848 // will need to be unescaped by HttpNetworkTransaction. | 3800 // will need to be unescaped by HttpNetworkTransaction. |
| 3849 EXPECT_EQ("b%40r", request.url.password()); | 3801 EXPECT_EQ("b%40r", request.url.password()); |
| 3850 | 3802 |
| 3851 MockWrite data_writes1[] = { | 3803 MockWrite data_writes1[] = { |
| 3852 MockWrite("GET / HTTP/1.1\r\n" | 3804 MockWrite("GET / HTTP/1.1\r\n" |
| 3853 "Host: www.google.com\r\n" | 3805 "Host: www.google.com\r\n" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3873 MockRead data_reads2[] = { | 3825 MockRead data_reads2[] = { |
| 3874 MockRead("HTTP/1.0 200 OK\r\n"), | 3826 MockRead("HTTP/1.0 200 OK\r\n"), |
| 3875 MockRead("Content-Length: 100\r\n\r\n"), | 3827 MockRead("Content-Length: 100\r\n\r\n"), |
| 3876 MockRead(SYNCHRONOUS, OK), | 3828 MockRead(SYNCHRONOUS, OK), |
| 3877 }; | 3829 }; |
| 3878 | 3830 |
| 3879 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3831 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 3880 data_writes1, arraysize(data_writes1)); | 3832 data_writes1, arraysize(data_writes1)); |
| 3881 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 3833 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 3882 data_writes2, arraysize(data_writes2)); | 3834 data_writes2, arraysize(data_writes2)); |
| 3883 session_deps.socket_factory.AddSocketDataProvider(&data1); | 3835 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 3884 session_deps.socket_factory.AddSocketDataProvider(&data2); | 3836 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 3885 | 3837 |
| 3886 TestCompletionCallback callback1; | 3838 TestCompletionCallback callback1; |
| 3887 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 3839 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 3888 EXPECT_EQ(ERR_IO_PENDING, rv); | 3840 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3889 rv = callback1.WaitForResult(); | 3841 rv = callback1.WaitForResult(); |
| 3890 EXPECT_EQ(OK, rv); | 3842 EXPECT_EQ(OK, rv); |
| 3891 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 3843 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 3892 | 3844 |
| 3893 TestCompletionCallback callback2; | 3845 TestCompletionCallback callback2; |
| 3894 rv = trans->RestartWithAuth(AuthCredentials(), callback2.callback()); | 3846 rv = trans->RestartWithAuth(AuthCredentials(), callback2.callback()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3914 // once. | 3866 // once. |
| 3915 TEST_F(HttpNetworkTransactionSpdy2Test, WrongAuthIdentityInURL) { | 3867 TEST_F(HttpNetworkTransactionSpdy2Test, WrongAuthIdentityInURL) { |
| 3916 HttpRequestInfo request; | 3868 HttpRequestInfo request; |
| 3917 request.method = "GET"; | 3869 request.method = "GET"; |
| 3918 // Note: the URL has a username:password in it. The password "baz" is | 3870 // Note: the URL has a username:password in it. The password "baz" is |
| 3919 // wrong (should be "bar"). | 3871 // wrong (should be "bar"). |
| 3920 request.url = GURL("http://foo:baz@www.google.com/"); | 3872 request.url = GURL("http://foo:baz@www.google.com/"); |
| 3921 | 3873 |
| 3922 request.load_flags = LOAD_NORMAL; | 3874 request.load_flags = LOAD_NORMAL; |
| 3923 | 3875 |
| 3924 SessionDependencies session_deps; | 3876 SpdySessionDependencies session_deps; |
| 3925 scoped_ptr<HttpTransaction> trans( | 3877 scoped_ptr<HttpTransaction> trans( |
| 3926 new HttpNetworkTransaction(CreateSession(&session_deps))); | 3878 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 3927 | 3879 |
| 3928 MockWrite data_writes1[] = { | 3880 MockWrite data_writes1[] = { |
| 3929 MockWrite("GET / HTTP/1.1\r\n" | 3881 MockWrite("GET / HTTP/1.1\r\n" |
| 3930 "Host: www.google.com\r\n" | 3882 "Host: www.google.com\r\n" |
| 3931 "Connection: keep-alive\r\n\r\n"), | 3883 "Connection: keep-alive\r\n\r\n"), |
| 3932 }; | 3884 }; |
| 3933 | 3885 |
| 3934 MockRead data_reads1[] = { | 3886 MockRead data_reads1[] = { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3968 MockRead("Content-Length: 100\r\n\r\n"), | 3920 MockRead("Content-Length: 100\r\n\r\n"), |
| 3969 MockRead(SYNCHRONOUS, OK), | 3921 MockRead(SYNCHRONOUS, OK), |
| 3970 }; | 3922 }; |
| 3971 | 3923 |
| 3972 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 3924 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 3973 data_writes1, arraysize(data_writes1)); | 3925 data_writes1, arraysize(data_writes1)); |
| 3974 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 3926 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 3975 data_writes2, arraysize(data_writes2)); | 3927 data_writes2, arraysize(data_writes2)); |
| 3976 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), | 3928 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), |
| 3977 data_writes3, arraysize(data_writes3)); | 3929 data_writes3, arraysize(data_writes3)); |
| 3978 session_deps.socket_factory.AddSocketDataProvider(&data1); | 3930 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 3979 session_deps.socket_factory.AddSocketDataProvider(&data2); | 3931 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 3980 session_deps.socket_factory.AddSocketDataProvider(&data3); | 3932 session_deps.socket_factory->AddSocketDataProvider(&data3); |
| 3981 | 3933 |
| 3982 TestCompletionCallback callback1; | 3934 TestCompletionCallback callback1; |
| 3983 | 3935 |
| 3984 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 3936 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 3985 EXPECT_EQ(ERR_IO_PENDING, rv); | 3937 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 3986 | 3938 |
| 3987 rv = callback1.WaitForResult(); | 3939 rv = callback1.WaitForResult(); |
| 3988 EXPECT_EQ(OK, rv); | 3940 EXPECT_EQ(OK, rv); |
| 3989 | 3941 |
| 3990 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 3942 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4014 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3966 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 4015 | 3967 |
| 4016 EXPECT_EQ(100, response->headers->GetContentLength()); | 3968 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 4017 | 3969 |
| 4018 // Empty the current queue. | 3970 // Empty the current queue. |
| 4019 MessageLoop::current()->RunUntilIdle(); | 3971 MessageLoop::current()->RunUntilIdle(); |
| 4020 } | 3972 } |
| 4021 | 3973 |
| 4022 // Test that previously tried username/passwords for a realm get re-used. | 3974 // Test that previously tried username/passwords for a realm get re-used. |
| 4023 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthCacheAndPreauth) { | 3975 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthCacheAndPreauth) { |
| 4024 SessionDependencies session_deps; | 3976 SpdySessionDependencies session_deps; |
| 4025 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 3977 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 4026 | 3978 |
| 4027 // Transaction 1: authenticate (foo, bar) on MyRealm1 | 3979 // Transaction 1: authenticate (foo, bar) on MyRealm1 |
| 4028 { | 3980 { |
| 4029 HttpRequestInfo request; | 3981 HttpRequestInfo request; |
| 4030 request.method = "GET"; | 3982 request.method = "GET"; |
| 4031 request.url = GURL("http://www.google.com/x/y/z"); | 3983 request.url = GURL("http://www.google.com/x/y/z"); |
| 4032 request.load_flags = 0; | 3984 request.load_flags = 0; |
| 4033 | 3985 |
| 4034 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 3986 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4058 MockRead data_reads2[] = { | 4010 MockRead data_reads2[] = { |
| 4059 MockRead("HTTP/1.0 200 OK\r\n"), | 4011 MockRead("HTTP/1.0 200 OK\r\n"), |
| 4060 MockRead("Content-Length: 100\r\n\r\n"), | 4012 MockRead("Content-Length: 100\r\n\r\n"), |
| 4061 MockRead(SYNCHRONOUS, OK), | 4013 MockRead(SYNCHRONOUS, OK), |
| 4062 }; | 4014 }; |
| 4063 | 4015 |
| 4064 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 4016 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 4065 data_writes1, arraysize(data_writes1)); | 4017 data_writes1, arraysize(data_writes1)); |
| 4066 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 4018 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 4067 data_writes2, arraysize(data_writes2)); | 4019 data_writes2, arraysize(data_writes2)); |
| 4068 session_deps.socket_factory.AddSocketDataProvider(&data1); | 4020 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 4069 session_deps.socket_factory.AddSocketDataProvider(&data2); | 4021 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 4070 | 4022 |
| 4071 TestCompletionCallback callback1; | 4023 TestCompletionCallback callback1; |
| 4072 | 4024 |
| 4073 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 4025 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 4074 EXPECT_EQ(ERR_IO_PENDING, rv); | 4026 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4075 | 4027 |
| 4076 rv = callback1.WaitForResult(); | 4028 rv = callback1.WaitForResult(); |
| 4077 EXPECT_EQ(OK, rv); | 4029 EXPECT_EQ(OK, rv); |
| 4078 | 4030 |
| 4079 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4031 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4137 MockRead data_reads2[] = { | 4089 MockRead data_reads2[] = { |
| 4138 MockRead("HTTP/1.0 200 OK\r\n"), | 4090 MockRead("HTTP/1.0 200 OK\r\n"), |
| 4139 MockRead("Content-Length: 100\r\n\r\n"), | 4091 MockRead("Content-Length: 100\r\n\r\n"), |
| 4140 MockRead(SYNCHRONOUS, OK), | 4092 MockRead(SYNCHRONOUS, OK), |
| 4141 }; | 4093 }; |
| 4142 | 4094 |
| 4143 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 4095 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 4144 data_writes1, arraysize(data_writes1)); | 4096 data_writes1, arraysize(data_writes1)); |
| 4145 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 4097 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 4146 data_writes2, arraysize(data_writes2)); | 4098 data_writes2, arraysize(data_writes2)); |
| 4147 session_deps.socket_factory.AddSocketDataProvider(&data1); | 4099 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 4148 session_deps.socket_factory.AddSocketDataProvider(&data2); | 4100 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 4149 | 4101 |
| 4150 TestCompletionCallback callback1; | 4102 TestCompletionCallback callback1; |
| 4151 | 4103 |
| 4152 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 4104 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 4153 EXPECT_EQ(ERR_IO_PENDING, rv); | 4105 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4154 | 4106 |
| 4155 rv = callback1.WaitForResult(); | 4107 rv = callback1.WaitForResult(); |
| 4156 EXPECT_EQ(OK, rv); | 4108 EXPECT_EQ(OK, rv); |
| 4157 | 4109 |
| 4158 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4110 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4202 | 4154 |
| 4203 // Sever accepts the preemptive authorization | 4155 // Sever accepts the preemptive authorization |
| 4204 MockRead data_reads1[] = { | 4156 MockRead data_reads1[] = { |
| 4205 MockRead("HTTP/1.0 200 OK\r\n"), | 4157 MockRead("HTTP/1.0 200 OK\r\n"), |
| 4206 MockRead("Content-Length: 100\r\n\r\n"), | 4158 MockRead("Content-Length: 100\r\n\r\n"), |
| 4207 MockRead(SYNCHRONOUS, OK), | 4159 MockRead(SYNCHRONOUS, OK), |
| 4208 }; | 4160 }; |
| 4209 | 4161 |
| 4210 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 4162 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 4211 data_writes1, arraysize(data_writes1)); | 4163 data_writes1, arraysize(data_writes1)); |
| 4212 session_deps.socket_factory.AddSocketDataProvider(&data1); | 4164 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 4213 | 4165 |
| 4214 TestCompletionCallback callback1; | 4166 TestCompletionCallback callback1; |
| 4215 | 4167 |
| 4216 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 4168 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 4217 EXPECT_EQ(ERR_IO_PENDING, rv); | 4169 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4218 | 4170 |
| 4219 rv = callback1.WaitForResult(); | 4171 rv = callback1.WaitForResult(); |
| 4220 EXPECT_EQ(OK, rv); | 4172 EXPECT_EQ(OK, rv); |
| 4221 | 4173 |
| 4222 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4174 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4263 MockRead data_reads2[] = { | 4215 MockRead data_reads2[] = { |
| 4264 MockRead("HTTP/1.0 200 OK\r\n"), | 4216 MockRead("HTTP/1.0 200 OK\r\n"), |
| 4265 MockRead("Content-Length: 100\r\n\r\n"), | 4217 MockRead("Content-Length: 100\r\n\r\n"), |
| 4266 MockRead(SYNCHRONOUS, OK), | 4218 MockRead(SYNCHRONOUS, OK), |
| 4267 }; | 4219 }; |
| 4268 | 4220 |
| 4269 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 4221 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 4270 data_writes1, arraysize(data_writes1)); | 4222 data_writes1, arraysize(data_writes1)); |
| 4271 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 4223 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 4272 data_writes2, arraysize(data_writes2)); | 4224 data_writes2, arraysize(data_writes2)); |
| 4273 session_deps.socket_factory.AddSocketDataProvider(&data1); | 4225 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 4274 session_deps.socket_factory.AddSocketDataProvider(&data2); | 4226 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 4275 | 4227 |
| 4276 TestCompletionCallback callback1; | 4228 TestCompletionCallback callback1; |
| 4277 | 4229 |
| 4278 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 4230 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 4279 EXPECT_EQ(ERR_IO_PENDING, rv); | 4231 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4280 | 4232 |
| 4281 rv = callback1.WaitForResult(); | 4233 rv = callback1.WaitForResult(); |
| 4282 EXPECT_EQ(OK, rv); | 4234 EXPECT_EQ(OK, rv); |
| 4283 | 4235 |
| 4284 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 4236 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4351 MockRead("Content-Length: 100\r\n\r\n"), | 4303 MockRead("Content-Length: 100\r\n\r\n"), |
| 4352 MockRead(SYNCHRONOUS, OK), | 4304 MockRead(SYNCHRONOUS, OK), |
| 4353 }; | 4305 }; |
| 4354 | 4306 |
| 4355 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 4307 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 4356 data_writes1, arraysize(data_writes1)); | 4308 data_writes1, arraysize(data_writes1)); |
| 4357 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 4309 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 4358 data_writes2, arraysize(data_writes2)); | 4310 data_writes2, arraysize(data_writes2)); |
| 4359 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), | 4311 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), |
| 4360 data_writes3, arraysize(data_writes3)); | 4312 data_writes3, arraysize(data_writes3)); |
| 4361 session_deps.socket_factory.AddSocketDataProvider(&data1); | 4313 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 4362 session_deps.socket_factory.AddSocketDataProvider(&data2); | 4314 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 4363 session_deps.socket_factory.AddSocketDataProvider(&data3); | 4315 session_deps.socket_factory->AddSocketDataProvider(&data3); |
| 4364 | 4316 |
| 4365 TestCompletionCallback callback1; | 4317 TestCompletionCallback callback1; |
| 4366 | 4318 |
| 4367 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 4319 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 4368 EXPECT_EQ(ERR_IO_PENDING, rv); | 4320 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4369 | 4321 |
| 4370 rv = callback1.WaitForResult(); | 4322 rv = callback1.WaitForResult(); |
| 4371 EXPECT_EQ(OK, rv); | 4323 EXPECT_EQ(OK, rv); |
| 4372 | 4324 |
| 4373 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 4325 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 4394 response = trans->GetResponseInfo(); | 4346 response = trans->GetResponseInfo(); |
| 4395 ASSERT_TRUE(response != NULL); | 4347 ASSERT_TRUE(response != NULL); |
| 4396 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4348 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 4397 EXPECT_EQ(100, response->headers->GetContentLength()); | 4349 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 4398 } | 4350 } |
| 4399 } | 4351 } |
| 4400 | 4352 |
| 4401 // Tests that nonce count increments when multiple auth attempts | 4353 // Tests that nonce count increments when multiple auth attempts |
| 4402 // are started with the same nonce. | 4354 // are started with the same nonce. |
| 4403 TEST_F(HttpNetworkTransactionSpdy2Test, DigestPreAuthNonceCount) { | 4355 TEST_F(HttpNetworkTransactionSpdy2Test, DigestPreAuthNonceCount) { |
| 4404 SessionDependencies session_deps; | 4356 SpdySessionDependencies session_deps; |
| 4405 HttpAuthHandlerDigest::Factory* digest_factory = | 4357 HttpAuthHandlerDigest::Factory* digest_factory = |
| 4406 new HttpAuthHandlerDigest::Factory(); | 4358 new HttpAuthHandlerDigest::Factory(); |
| 4407 HttpAuthHandlerDigest::FixedNonceGenerator* nonce_generator = | 4359 HttpAuthHandlerDigest::FixedNonceGenerator* nonce_generator = |
| 4408 new HttpAuthHandlerDigest::FixedNonceGenerator("0123456789abcdef"); | 4360 new HttpAuthHandlerDigest::FixedNonceGenerator("0123456789abcdef"); |
| 4409 digest_factory->set_nonce_generator(nonce_generator); | 4361 digest_factory->set_nonce_generator(nonce_generator); |
| 4410 session_deps.http_auth_handler_factory.reset(digest_factory); | 4362 session_deps.http_auth_handler_factory.reset(digest_factory); |
| 4411 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 4363 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 4412 | 4364 |
| 4413 // Transaction 1: authenticate (foo, bar) on MyRealm1 | 4365 // Transaction 1: authenticate (foo, bar) on MyRealm1 |
| 4414 { | 4366 { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4446 // Sever accepts the authorization. | 4398 // Sever accepts the authorization. |
| 4447 MockRead data_reads2[] = { | 4399 MockRead data_reads2[] = { |
| 4448 MockRead("HTTP/1.0 200 OK\r\n"), | 4400 MockRead("HTTP/1.0 200 OK\r\n"), |
| 4449 MockRead(SYNCHRONOUS, OK), | 4401 MockRead(SYNCHRONOUS, OK), |
| 4450 }; | 4402 }; |
| 4451 | 4403 |
| 4452 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 4404 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 4453 data_writes1, arraysize(data_writes1)); | 4405 data_writes1, arraysize(data_writes1)); |
| 4454 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 4406 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 4455 data_writes2, arraysize(data_writes2)); | 4407 data_writes2, arraysize(data_writes2)); |
| 4456 session_deps.socket_factory.AddSocketDataProvider(&data1); | 4408 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 4457 session_deps.socket_factory.AddSocketDataProvider(&data2); | 4409 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 4458 | 4410 |
| 4459 TestCompletionCallback callback1; | 4411 TestCompletionCallback callback1; |
| 4460 | 4412 |
| 4461 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 4413 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 4462 EXPECT_EQ(ERR_IO_PENDING, rv); | 4414 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4463 | 4415 |
| 4464 rv = callback1.WaitForResult(); | 4416 rv = callback1.WaitForResult(); |
| 4465 EXPECT_EQ(OK, rv); | 4417 EXPECT_EQ(OK, rv); |
| 4466 | 4418 |
| 4467 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4419 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4509 | 4461 |
| 4510 // Sever accepts the authorization. | 4462 // Sever accepts the authorization. |
| 4511 MockRead data_reads1[] = { | 4463 MockRead data_reads1[] = { |
| 4512 MockRead("HTTP/1.0 200 OK\r\n"), | 4464 MockRead("HTTP/1.0 200 OK\r\n"), |
| 4513 MockRead("Content-Length: 100\r\n\r\n"), | 4465 MockRead("Content-Length: 100\r\n\r\n"), |
| 4514 MockRead(SYNCHRONOUS, OK), | 4466 MockRead(SYNCHRONOUS, OK), |
| 4515 }; | 4467 }; |
| 4516 | 4468 |
| 4517 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 4469 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 4518 data_writes1, arraysize(data_writes1)); | 4470 data_writes1, arraysize(data_writes1)); |
| 4519 session_deps.socket_factory.AddSocketDataProvider(&data1); | 4471 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 4520 | 4472 |
| 4521 TestCompletionCallback callback1; | 4473 TestCompletionCallback callback1; |
| 4522 | 4474 |
| 4523 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 4475 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 4524 EXPECT_EQ(ERR_IO_PENDING, rv); | 4476 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4525 | 4477 |
| 4526 rv = callback1.WaitForResult(); | 4478 rv = callback1.WaitForResult(); |
| 4527 EXPECT_EQ(OK, rv); | 4479 EXPECT_EQ(OK, rv); |
| 4528 | 4480 |
| 4529 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4481 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4530 ASSERT_TRUE(response != NULL); | 4482 ASSERT_TRUE(response != NULL); |
| 4531 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4483 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 4532 } | 4484 } |
| 4533 } | 4485 } |
| 4534 | 4486 |
| 4535 // Test the ResetStateForRestart() private method. | 4487 // Test the ResetStateForRestart() private method. |
| 4536 TEST_F(HttpNetworkTransactionSpdy2Test, ResetStateForRestart) { | 4488 TEST_F(HttpNetworkTransactionSpdy2Test, ResetStateForRestart) { |
| 4537 // Create a transaction (the dependencies aren't important). | 4489 // Create a transaction (the dependencies aren't important). |
| 4538 SessionDependencies session_deps; | 4490 SpdySessionDependencies session_deps; |
| 4539 scoped_ptr<HttpNetworkTransaction> trans( | 4491 scoped_ptr<HttpNetworkTransaction> trans( |
| 4540 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4492 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4541 | 4493 |
| 4542 // Setup some state (which we expect ResetStateForRestart() will clear). | 4494 // Setup some state (which we expect ResetStateForRestart() will clear). |
| 4543 trans->read_buf_ = new IOBuffer(15); | 4495 trans->read_buf_ = new IOBuffer(15); |
| 4544 trans->read_buf_len_ = 15; | 4496 trans->read_buf_len_ = 15; |
| 4545 trans->request_headers_.SetHeader("Authorization", "NTLM"); | 4497 trans->request_headers_.SetHeader("Authorization", "NTLM"); |
| 4546 | 4498 |
| 4547 // Setup state in response_ | 4499 // Setup state in response_ |
| 4548 HttpResponseInfo* response = &trans->response_; | 4500 HttpResponseInfo* response = &trans->response_; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 4575 EXPECT_FALSE(response->vary_data.is_valid()); | 4527 EXPECT_FALSE(response->vary_data.is_valid()); |
| 4576 } | 4528 } |
| 4577 | 4529 |
| 4578 // Test HTTPS connections to a site with a bad certificate | 4530 // Test HTTPS connections to a site with a bad certificate |
| 4579 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSBadCertificate) { | 4531 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSBadCertificate) { |
| 4580 HttpRequestInfo request; | 4532 HttpRequestInfo request; |
| 4581 request.method = "GET"; | 4533 request.method = "GET"; |
| 4582 request.url = GURL("https://www.google.com/"); | 4534 request.url = GURL("https://www.google.com/"); |
| 4583 request.load_flags = 0; | 4535 request.load_flags = 0; |
| 4584 | 4536 |
| 4585 SessionDependencies session_deps; | 4537 SpdySessionDependencies session_deps; |
| 4586 scoped_ptr<HttpTransaction> trans( | 4538 scoped_ptr<HttpTransaction> trans( |
| 4587 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4539 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4588 | 4540 |
| 4589 MockWrite data_writes[] = { | 4541 MockWrite data_writes[] = { |
| 4590 MockWrite("GET / HTTP/1.1\r\n" | 4542 MockWrite("GET / HTTP/1.1\r\n" |
| 4591 "Host: www.google.com\r\n" | 4543 "Host: www.google.com\r\n" |
| 4592 "Connection: keep-alive\r\n\r\n"), | 4544 "Connection: keep-alive\r\n\r\n"), |
| 4593 }; | 4545 }; |
| 4594 | 4546 |
| 4595 MockRead data_reads[] = { | 4547 MockRead data_reads[] = { |
| 4596 MockRead("HTTP/1.0 200 OK\r\n"), | 4548 MockRead("HTTP/1.0 200 OK\r\n"), |
| 4597 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 4549 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 4598 MockRead("Content-Length: 100\r\n\r\n"), | 4550 MockRead("Content-Length: 100\r\n\r\n"), |
| 4599 MockRead(SYNCHRONOUS, OK), | 4551 MockRead(SYNCHRONOUS, OK), |
| 4600 }; | 4552 }; |
| 4601 | 4553 |
| 4602 StaticSocketDataProvider ssl_bad_certificate; | 4554 StaticSocketDataProvider ssl_bad_certificate; |
| 4603 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 4555 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 4604 data_writes, arraysize(data_writes)); | 4556 data_writes, arraysize(data_writes)); |
| 4605 SSLSocketDataProvider ssl_bad(ASYNC, ERR_CERT_AUTHORITY_INVALID); | 4557 SSLSocketDataProvider ssl_bad(ASYNC, ERR_CERT_AUTHORITY_INVALID); |
| 4606 SSLSocketDataProvider ssl(ASYNC, OK); | 4558 SSLSocketDataProvider ssl(ASYNC, OK); |
| 4607 | 4559 |
| 4608 session_deps.socket_factory.AddSocketDataProvider(&ssl_bad_certificate); | 4560 session_deps.socket_factory->AddSocketDataProvider(&ssl_bad_certificate); |
| 4609 session_deps.socket_factory.AddSocketDataProvider(&data); | 4561 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 4610 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_bad); | 4562 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_bad); |
| 4611 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 4563 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 4612 | 4564 |
| 4613 TestCompletionCallback callback; | 4565 TestCompletionCallback callback; |
| 4614 | 4566 |
| 4615 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4567 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4616 EXPECT_EQ(ERR_IO_PENDING, rv); | 4568 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4617 | 4569 |
| 4618 rv = callback.WaitForResult(); | 4570 rv = callback.WaitForResult(); |
| 4619 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); | 4571 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); |
| 4620 | 4572 |
| 4621 rv = trans->RestartIgnoringLastError(callback.callback()); | 4573 rv = trans->RestartIgnoringLastError(callback.callback()); |
| 4622 EXPECT_EQ(ERR_IO_PENDING, rv); | 4574 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4623 | 4575 |
| 4624 rv = callback.WaitForResult(); | 4576 rv = callback.WaitForResult(); |
| 4625 EXPECT_EQ(OK, rv); | 4577 EXPECT_EQ(OK, rv); |
| 4626 | 4578 |
| 4627 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4579 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4628 | 4580 |
| 4629 ASSERT_TRUE(response != NULL); | 4581 ASSERT_TRUE(response != NULL); |
| 4630 EXPECT_EQ(100, response->headers->GetContentLength()); | 4582 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 4631 } | 4583 } |
| 4632 | 4584 |
| 4633 // Test HTTPS connections to a site with a bad certificate, going through a | 4585 // Test HTTPS connections to a site with a bad certificate, going through a |
| 4634 // proxy | 4586 // proxy |
| 4635 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSBadCertificateViaProxy) { | 4587 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSBadCertificateViaProxy) { |
| 4636 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 4588 SpdySessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 4637 | 4589 |
| 4638 HttpRequestInfo request; | 4590 HttpRequestInfo request; |
| 4639 request.method = "GET"; | 4591 request.method = "GET"; |
| 4640 request.url = GURL("https://www.google.com/"); | 4592 request.url = GURL("https://www.google.com/"); |
| 4641 request.load_flags = 0; | 4593 request.load_flags = 0; |
| 4642 | 4594 |
| 4643 MockWrite proxy_writes[] = { | 4595 MockWrite proxy_writes[] = { |
| 4644 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 4596 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 4645 "Host: www.google.com\r\n" | 4597 "Host: www.google.com\r\n" |
| 4646 "Proxy-Connection: keep-alive\r\n\r\n"), | 4598 "Proxy-Connection: keep-alive\r\n\r\n"), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 4669 }; | 4621 }; |
| 4670 | 4622 |
| 4671 StaticSocketDataProvider ssl_bad_certificate( | 4623 StaticSocketDataProvider ssl_bad_certificate( |
| 4672 proxy_reads, arraysize(proxy_reads), | 4624 proxy_reads, arraysize(proxy_reads), |
| 4673 proxy_writes, arraysize(proxy_writes)); | 4625 proxy_writes, arraysize(proxy_writes)); |
| 4674 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 4626 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 4675 data_writes, arraysize(data_writes)); | 4627 data_writes, arraysize(data_writes)); |
| 4676 SSLSocketDataProvider ssl_bad(ASYNC, ERR_CERT_AUTHORITY_INVALID); | 4628 SSLSocketDataProvider ssl_bad(ASYNC, ERR_CERT_AUTHORITY_INVALID); |
| 4677 SSLSocketDataProvider ssl(ASYNC, OK); | 4629 SSLSocketDataProvider ssl(ASYNC, OK); |
| 4678 | 4630 |
| 4679 session_deps.socket_factory.AddSocketDataProvider(&ssl_bad_certificate); | 4631 session_deps.socket_factory->AddSocketDataProvider(&ssl_bad_certificate); |
| 4680 session_deps.socket_factory.AddSocketDataProvider(&data); | 4632 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 4681 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_bad); | 4633 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_bad); |
| 4682 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 4634 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 4683 | 4635 |
| 4684 TestCompletionCallback callback; | 4636 TestCompletionCallback callback; |
| 4685 | 4637 |
| 4686 for (int i = 0; i < 2; i++) { | 4638 for (int i = 0; i < 2; i++) { |
| 4687 session_deps.socket_factory.ResetNextMockIndexes(); | 4639 session_deps.socket_factory->ResetNextMockIndexes(); |
| 4688 | 4640 |
| 4689 scoped_ptr<HttpTransaction> trans( | 4641 scoped_ptr<HttpTransaction> trans( |
| 4690 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4642 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4691 | 4643 |
| 4692 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4644 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4693 EXPECT_EQ(ERR_IO_PENDING, rv); | 4645 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4694 | 4646 |
| 4695 rv = callback.WaitForResult(); | 4647 rv = callback.WaitForResult(); |
| 4696 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); | 4648 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); |
| 4697 | 4649 |
| 4698 rv = trans->RestartIgnoringLastError(callback.callback()); | 4650 rv = trans->RestartIgnoringLastError(callback.callback()); |
| 4699 EXPECT_EQ(ERR_IO_PENDING, rv); | 4651 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4700 | 4652 |
| 4701 rv = callback.WaitForResult(); | 4653 rv = callback.WaitForResult(); |
| 4702 EXPECT_EQ(OK, rv); | 4654 EXPECT_EQ(OK, rv); |
| 4703 | 4655 |
| 4704 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4656 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4705 | 4657 |
| 4706 ASSERT_TRUE(response != NULL); | 4658 ASSERT_TRUE(response != NULL); |
| 4707 EXPECT_EQ(100, response->headers->GetContentLength()); | 4659 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 4708 } | 4660 } |
| 4709 } | 4661 } |
| 4710 | 4662 |
| 4711 | 4663 |
| 4712 // Test HTTPS connections to a site, going through an HTTPS proxy | 4664 // Test HTTPS connections to a site, going through an HTTPS proxy |
| 4713 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSViaHttpsProxy) { | 4665 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSViaHttpsProxy) { |
| 4714 SessionDependencies session_deps(ProxyService::CreateFixed( | 4666 SpdySessionDependencies session_deps(ProxyService::CreateFixed( |
| 4715 "https://proxy:70")); | 4667 "https://proxy:70")); |
| 4716 | 4668 |
| 4717 HttpRequestInfo request; | 4669 HttpRequestInfo request; |
| 4718 request.method = "GET"; | 4670 request.method = "GET"; |
| 4719 request.url = GURL("https://www.google.com/"); | 4671 request.url = GURL("https://www.google.com/"); |
| 4720 request.load_flags = 0; | 4672 request.load_flags = 0; |
| 4721 | 4673 |
| 4722 MockWrite data_writes[] = { | 4674 MockWrite data_writes[] = { |
| 4723 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 4675 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 4724 "Host: www.google.com\r\n" | 4676 "Host: www.google.com\r\n" |
| 4725 "Proxy-Connection: keep-alive\r\n\r\n"), | 4677 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 4726 MockWrite("GET / HTTP/1.1\r\n" | 4678 MockWrite("GET / HTTP/1.1\r\n" |
| 4727 "Host: www.google.com\r\n" | 4679 "Host: www.google.com\r\n" |
| 4728 "Connection: keep-alive\r\n\r\n"), | 4680 "Connection: keep-alive\r\n\r\n"), |
| 4729 }; | 4681 }; |
| 4730 | 4682 |
| 4731 MockRead data_reads[] = { | 4683 MockRead data_reads[] = { |
| 4732 MockRead("HTTP/1.0 200 Connected\r\n\r\n"), | 4684 MockRead("HTTP/1.0 200 Connected\r\n\r\n"), |
| 4733 MockRead("HTTP/1.1 200 OK\r\n"), | 4685 MockRead("HTTP/1.1 200 OK\r\n"), |
| 4734 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 4686 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 4735 MockRead("Content-Length: 100\r\n\r\n"), | 4687 MockRead("Content-Length: 100\r\n\r\n"), |
| 4736 MockRead(SYNCHRONOUS, OK), | 4688 MockRead(SYNCHRONOUS, OK), |
| 4737 }; | 4689 }; |
| 4738 | 4690 |
| 4739 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 4691 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 4740 data_writes, arraysize(data_writes)); | 4692 data_writes, arraysize(data_writes)); |
| 4741 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy | 4693 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy |
| 4742 SSLSocketDataProvider tunnel_ssl(ASYNC, OK); // SSL through the tunnel | 4694 SSLSocketDataProvider tunnel_ssl(ASYNC, OK); // SSL through the tunnel |
| 4743 | 4695 |
| 4744 session_deps.socket_factory.AddSocketDataProvider(&data); | 4696 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 4745 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); | 4697 session_deps.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); |
| 4746 session_deps.socket_factory.AddSSLSocketDataProvider(&tunnel_ssl); | 4698 session_deps.socket_factory->AddSSLSocketDataProvider(&tunnel_ssl); |
| 4747 | 4699 |
| 4748 TestCompletionCallback callback; | 4700 TestCompletionCallback callback; |
| 4749 | 4701 |
| 4750 scoped_ptr<HttpTransaction> trans( | 4702 scoped_ptr<HttpTransaction> trans( |
| 4751 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4703 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4752 | 4704 |
| 4753 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4705 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4754 EXPECT_EQ(ERR_IO_PENDING, rv); | 4706 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4755 | 4707 |
| 4756 rv = callback.WaitForResult(); | 4708 rv = callback.WaitForResult(); |
| 4757 EXPECT_EQ(OK, rv); | 4709 EXPECT_EQ(OK, rv); |
| 4758 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4710 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4759 | 4711 |
| 4760 ASSERT_TRUE(response != NULL); | 4712 ASSERT_TRUE(response != NULL); |
| 4761 | 4713 |
| 4762 EXPECT_TRUE(response->headers->IsKeepAlive()); | 4714 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 4763 EXPECT_EQ(200, response->headers->response_code()); | 4715 EXPECT_EQ(200, response->headers->response_code()); |
| 4764 EXPECT_EQ(100, response->headers->GetContentLength()); | 4716 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 4765 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 4717 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 4766 } | 4718 } |
| 4767 | 4719 |
| 4768 // Test an HTTPS Proxy's ability to redirect a CONNECT request | 4720 // Test an HTTPS Proxy's ability to redirect a CONNECT request |
| 4769 TEST_F(HttpNetworkTransactionSpdy2Test, RedirectOfHttpsConnectViaHttpsProxy) { | 4721 TEST_F(HttpNetworkTransactionSpdy2Test, RedirectOfHttpsConnectViaHttpsProxy) { |
| 4770 SessionDependencies session_deps( | 4722 SpdySessionDependencies session_deps( |
| 4771 ProxyService::CreateFixed("https://proxy:70")); | 4723 ProxyService::CreateFixed("https://proxy:70")); |
| 4772 | 4724 |
| 4773 HttpRequestInfo request; | 4725 HttpRequestInfo request; |
| 4774 request.method = "GET"; | 4726 request.method = "GET"; |
| 4775 request.url = GURL("https://www.google.com/"); | 4727 request.url = GURL("https://www.google.com/"); |
| 4776 request.load_flags = 0; | 4728 request.load_flags = 0; |
| 4777 | 4729 |
| 4778 MockWrite data_writes[] = { | 4730 MockWrite data_writes[] = { |
| 4779 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 4731 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 4780 "Host: www.google.com\r\n" | 4732 "Host: www.google.com\r\n" |
| 4781 "Proxy-Connection: keep-alive\r\n\r\n"), | 4733 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 4782 }; | 4734 }; |
| 4783 | 4735 |
| 4784 MockRead data_reads[] = { | 4736 MockRead data_reads[] = { |
| 4785 MockRead("HTTP/1.1 302 Redirect\r\n"), | 4737 MockRead("HTTP/1.1 302 Redirect\r\n"), |
| 4786 MockRead("Location: http://login.example.com/\r\n"), | 4738 MockRead("Location: http://login.example.com/\r\n"), |
| 4787 MockRead("Content-Length: 0\r\n\r\n"), | 4739 MockRead("Content-Length: 0\r\n\r\n"), |
| 4788 MockRead(SYNCHRONOUS, OK), | 4740 MockRead(SYNCHRONOUS, OK), |
| 4789 }; | 4741 }; |
| 4790 | 4742 |
| 4791 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 4743 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 4792 data_writes, arraysize(data_writes)); | 4744 data_writes, arraysize(data_writes)); |
| 4793 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy | 4745 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy |
| 4794 | 4746 |
| 4795 session_deps.socket_factory.AddSocketDataProvider(&data); | 4747 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 4796 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); | 4748 session_deps.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); |
| 4797 | 4749 |
| 4798 TestCompletionCallback callback; | 4750 TestCompletionCallback callback; |
| 4799 | 4751 |
| 4800 scoped_ptr<HttpTransaction> trans( | 4752 scoped_ptr<HttpTransaction> trans( |
| 4801 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4753 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4802 | 4754 |
| 4803 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4755 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4804 EXPECT_EQ(ERR_IO_PENDING, rv); | 4756 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4805 | 4757 |
| 4806 rv = callback.WaitForResult(); | 4758 rv = callback.WaitForResult(); |
| 4807 EXPECT_EQ(OK, rv); | 4759 EXPECT_EQ(OK, rv); |
| 4808 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4760 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4809 | 4761 |
| 4810 ASSERT_TRUE(response != NULL); | 4762 ASSERT_TRUE(response != NULL); |
| 4811 | 4763 |
| 4812 EXPECT_EQ(302, response->headers->response_code()); | 4764 EXPECT_EQ(302, response->headers->response_code()); |
| 4813 std::string url; | 4765 std::string url; |
| 4814 EXPECT_TRUE(response->headers->IsRedirect(&url)); | 4766 EXPECT_TRUE(response->headers->IsRedirect(&url)); |
| 4815 EXPECT_EQ("http://login.example.com/", url); | 4767 EXPECT_EQ("http://login.example.com/", url); |
| 4816 } | 4768 } |
| 4817 | 4769 |
| 4818 // Test an HTTPS (SPDY) Proxy's ability to redirect a CONNECT request | 4770 // Test an HTTPS (SPDY) Proxy's ability to redirect a CONNECT request |
| 4819 TEST_F(HttpNetworkTransactionSpdy2Test, RedirectOfHttpsConnectViaSpdyProxy) { | 4771 TEST_F(HttpNetworkTransactionSpdy2Test, RedirectOfHttpsConnectViaSpdyProxy) { |
| 4820 SessionDependencies session_deps( | 4772 SpdySessionDependencies session_deps( |
| 4821 ProxyService::CreateFixed("https://proxy:70")); | 4773 ProxyService::CreateFixed("https://proxy:70")); |
| 4822 | 4774 |
| 4823 HttpRequestInfo request; | 4775 HttpRequestInfo request; |
| 4824 request.method = "GET"; | 4776 request.method = "GET"; |
| 4825 request.url = GURL("https://www.google.com/"); | 4777 request.url = GURL("https://www.google.com/"); |
| 4826 request.load_flags = 0; | 4778 request.load_flags = 0; |
| 4827 | 4779 |
| 4828 scoped_ptr<SpdyFrame> conn(ConstructSpdyConnect(NULL, 0, 1)); | 4780 scoped_ptr<SpdyFrame> conn(ConstructSpdyConnect(NULL, 0, 1)); |
| 4829 scoped_ptr<SpdyFrame> goaway(ConstructSpdyRstStream(1, CANCEL)); | 4781 scoped_ptr<SpdyFrame> goaway(ConstructSpdyRstStream(1, CANCEL)); |
| 4830 MockWrite data_writes[] = { | 4782 MockWrite data_writes[] = { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4843 MockRead(ASYNC, 0, 2), // EOF | 4795 MockRead(ASYNC, 0, 2), // EOF |
| 4844 }; | 4796 }; |
| 4845 | 4797 |
| 4846 DelayedSocketData data( | 4798 DelayedSocketData data( |
| 4847 1, // wait for one write to finish before reading. | 4799 1, // wait for one write to finish before reading. |
| 4848 data_reads, arraysize(data_reads), | 4800 data_reads, arraysize(data_reads), |
| 4849 data_writes, arraysize(data_writes)); | 4801 data_writes, arraysize(data_writes)); |
| 4850 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy | 4802 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy |
| 4851 proxy_ssl.SetNextProto(kProtoSPDY2); | 4803 proxy_ssl.SetNextProto(kProtoSPDY2); |
| 4852 | 4804 |
| 4853 session_deps.socket_factory.AddSocketDataProvider(&data); | 4805 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 4854 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); | 4806 session_deps.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); |
| 4855 | 4807 |
| 4856 TestCompletionCallback callback; | 4808 TestCompletionCallback callback; |
| 4857 | 4809 |
| 4858 scoped_ptr<HttpTransaction> trans( | 4810 scoped_ptr<HttpTransaction> trans( |
| 4859 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4811 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4860 | 4812 |
| 4861 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4813 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4862 EXPECT_EQ(ERR_IO_PENDING, rv); | 4814 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4863 | 4815 |
| 4864 rv = callback.WaitForResult(); | 4816 rv = callback.WaitForResult(); |
| 4865 EXPECT_EQ(OK, rv); | 4817 EXPECT_EQ(OK, rv); |
| 4866 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4818 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 4867 | 4819 |
| 4868 ASSERT_TRUE(response != NULL); | 4820 ASSERT_TRUE(response != NULL); |
| 4869 | 4821 |
| 4870 EXPECT_EQ(302, response->headers->response_code()); | 4822 EXPECT_EQ(302, response->headers->response_code()); |
| 4871 std::string url; | 4823 std::string url; |
| 4872 EXPECT_TRUE(response->headers->IsRedirect(&url)); | 4824 EXPECT_TRUE(response->headers->IsRedirect(&url)); |
| 4873 EXPECT_EQ("http://login.example.com/", url); | 4825 EXPECT_EQ("http://login.example.com/", url); |
| 4874 } | 4826 } |
| 4875 | 4827 |
| 4876 // Test that an HTTPS proxy's response to a CONNECT request is filtered. | 4828 // Test that an HTTPS proxy's response to a CONNECT request is filtered. |
| 4877 TEST_F(HttpNetworkTransactionSpdy2Test, | 4829 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 4878 ErrorResponseToHttpsConnectViaHttpsProxy) { | 4830 ErrorResponseToHttpsConnectViaHttpsProxy) { |
| 4879 SessionDependencies session_deps( | 4831 SpdySessionDependencies session_deps( |
| 4880 ProxyService::CreateFixed("https://proxy:70")); | 4832 ProxyService::CreateFixed("https://proxy:70")); |
| 4881 | 4833 |
| 4882 HttpRequestInfo request; | 4834 HttpRequestInfo request; |
| 4883 request.method = "GET"; | 4835 request.method = "GET"; |
| 4884 request.url = GURL("https://www.google.com/"); | 4836 request.url = GURL("https://www.google.com/"); |
| 4885 request.load_flags = 0; | 4837 request.load_flags = 0; |
| 4886 | 4838 |
| 4887 MockWrite data_writes[] = { | 4839 MockWrite data_writes[] = { |
| 4888 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 4840 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 4889 "Host: www.google.com\r\n" | 4841 "Host: www.google.com\r\n" |
| 4890 "Proxy-Connection: keep-alive\r\n\r\n"), | 4842 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 4891 }; | 4843 }; |
| 4892 | 4844 |
| 4893 MockRead data_reads[] = { | 4845 MockRead data_reads[] = { |
| 4894 MockRead("HTTP/1.1 404 Not Found\r\n"), | 4846 MockRead("HTTP/1.1 404 Not Found\r\n"), |
| 4895 MockRead("Content-Length: 23\r\n\r\n"), | 4847 MockRead("Content-Length: 23\r\n\r\n"), |
| 4896 MockRead("The host does not exist"), | 4848 MockRead("The host does not exist"), |
| 4897 MockRead(SYNCHRONOUS, OK), | 4849 MockRead(SYNCHRONOUS, OK), |
| 4898 }; | 4850 }; |
| 4899 | 4851 |
| 4900 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 4852 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 4901 data_writes, arraysize(data_writes)); | 4853 data_writes, arraysize(data_writes)); |
| 4902 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy | 4854 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy |
| 4903 | 4855 |
| 4904 session_deps.socket_factory.AddSocketDataProvider(&data); | 4856 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 4905 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); | 4857 session_deps.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); |
| 4906 | 4858 |
| 4907 TestCompletionCallback callback; | 4859 TestCompletionCallback callback; |
| 4908 | 4860 |
| 4909 scoped_ptr<HttpTransaction> trans( | 4861 scoped_ptr<HttpTransaction> trans( |
| 4910 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4862 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4911 | 4863 |
| 4912 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4864 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4913 EXPECT_EQ(ERR_IO_PENDING, rv); | 4865 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4914 | 4866 |
| 4915 rv = callback.WaitForResult(); | 4867 rv = callback.WaitForResult(); |
| 4916 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); | 4868 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); |
| 4917 | 4869 |
| 4918 // TODO(ttuttle): Anything else to check here? | 4870 // TODO(ttuttle): Anything else to check here? |
| 4919 } | 4871 } |
| 4920 | 4872 |
| 4921 // Test that a SPDY proxy's response to a CONNECT request is filtered. | 4873 // Test that a SPDY proxy's response to a CONNECT request is filtered. |
| 4922 TEST_F(HttpNetworkTransactionSpdy2Test, | 4874 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 4923 ErrorResponseToHttpsConnectViaSpdyProxy) { | 4875 ErrorResponseToHttpsConnectViaSpdyProxy) { |
| 4924 SessionDependencies session_deps( | 4876 SpdySessionDependencies session_deps( |
| 4925 ProxyService::CreateFixed("https://proxy:70")); | 4877 ProxyService::CreateFixed("https://proxy:70")); |
| 4926 | 4878 |
| 4927 HttpRequestInfo request; | 4879 HttpRequestInfo request; |
| 4928 request.method = "GET"; | 4880 request.method = "GET"; |
| 4929 request.url = GURL("https://www.google.com/"); | 4881 request.url = GURL("https://www.google.com/"); |
| 4930 request.load_flags = 0; | 4882 request.load_flags = 0; |
| 4931 | 4883 |
| 4932 scoped_ptr<SpdyFrame> conn(ConstructSpdyConnect(NULL, 0, 1)); | 4884 scoped_ptr<SpdyFrame> conn(ConstructSpdyConnect(NULL, 0, 1)); |
| 4933 scoped_ptr<SpdyFrame> rst(ConstructSpdyRstStream(1, CANCEL)); | 4885 scoped_ptr<SpdyFrame> rst(ConstructSpdyRstStream(1, CANCEL)); |
| 4934 MockWrite data_writes[] = { | 4886 MockWrite data_writes[] = { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4951 MockRead(ASYNC, 0, 4), // EOF | 4903 MockRead(ASYNC, 0, 4), // EOF |
| 4952 }; | 4904 }; |
| 4953 | 4905 |
| 4954 DelayedSocketData data( | 4906 DelayedSocketData data( |
| 4955 1, // wait for one write to finish before reading. | 4907 1, // wait for one write to finish before reading. |
| 4956 data_reads, arraysize(data_reads), | 4908 data_reads, arraysize(data_reads), |
| 4957 data_writes, arraysize(data_writes)); | 4909 data_writes, arraysize(data_writes)); |
| 4958 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy | 4910 SSLSocketDataProvider proxy_ssl(ASYNC, OK); // SSL to the proxy |
| 4959 proxy_ssl.SetNextProto(kProtoSPDY2); | 4911 proxy_ssl.SetNextProto(kProtoSPDY2); |
| 4960 | 4912 |
| 4961 session_deps.socket_factory.AddSocketDataProvider(&data); | 4913 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 4962 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy_ssl); | 4914 session_deps.socket_factory->AddSSLSocketDataProvider(&proxy_ssl); |
| 4963 | 4915 |
| 4964 TestCompletionCallback callback; | 4916 TestCompletionCallback callback; |
| 4965 | 4917 |
| 4966 scoped_ptr<HttpTransaction> trans( | 4918 scoped_ptr<HttpTransaction> trans( |
| 4967 new HttpNetworkTransaction(CreateSession(&session_deps))); | 4919 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 4968 | 4920 |
| 4969 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 4921 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 4970 EXPECT_EQ(ERR_IO_PENDING, rv); | 4922 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 4971 | 4923 |
| 4972 rv = callback.WaitForResult(); | 4924 rv = callback.WaitForResult(); |
| 4973 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); | 4925 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); |
| 4974 | 4926 |
| 4975 // TODO(ttuttle): Anything else to check here? | 4927 // TODO(ttuttle): Anything else to check here? |
| 4976 } | 4928 } |
| 4977 | 4929 |
| 4978 // Test the request-challenge-retry sequence for basic auth, through | 4930 // Test the request-challenge-retry sequence for basic auth, through |
| 4979 // a SPDY proxy over a single SPDY session. | 4931 // a SPDY proxy over a single SPDY session. |
| 4980 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthSpdyProxy) { | 4932 TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthSpdyProxy) { |
| 4981 HttpRequestInfo request; | 4933 HttpRequestInfo request; |
| 4982 request.method = "GET"; | 4934 request.method = "GET"; |
| 4983 request.url = GURL("https://www.google.com/"); | 4935 request.url = GURL("https://www.google.com/"); |
| 4984 // when the no authentication data flag is set. | 4936 // when the no authentication data flag is set. |
| 4985 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; | 4937 request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA; |
| 4986 | 4938 |
| 4987 // Configure against https proxy server "myproxy:70". | 4939 // Configure against https proxy server "myproxy:70". |
| 4988 SessionDependencies session_deps( | 4940 SpdySessionDependencies session_deps( |
| 4989 ProxyService::CreateFixed("https://myproxy:70")); | 4941 ProxyService::CreateFixed("https://myproxy:70")); |
| 4990 CapturingBoundNetLog log; | 4942 CapturingBoundNetLog log; |
| 4991 session_deps.net_log = log.bound().net_log(); | 4943 session_deps.net_log = log.bound().net_log(); |
| 4992 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 4944 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 4993 | 4945 |
| 4994 // Since we have proxy, should try to establish tunnel. | 4946 // Since we have proxy, should try to establish tunnel. |
| 4995 scoped_ptr<SpdyFrame> req(ConstructSpdyConnect(NULL, 0, 1)); | 4947 scoped_ptr<SpdyFrame> req(ConstructSpdyConnect(NULL, 0, 1)); |
| 4996 scoped_ptr<SpdyFrame> rst(ConstructSpdyRstStream(1, CANCEL)); | 4948 scoped_ptr<SpdyFrame> rst(ConstructSpdyRstStream(1, CANCEL)); |
| 4997 | 4949 |
| 4998 // After calling trans->RestartWithAuth(), this is the request we should | 4950 // After calling trans->RestartWithAuth(), this is the request we should |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5047 CreateMockRead(*conn_auth_resp, 2, ASYNC), | 4999 CreateMockRead(*conn_auth_resp, 2, ASYNC), |
| 5048 CreateMockRead(*conn_resp, 6, ASYNC), | 5000 CreateMockRead(*conn_resp, 6, ASYNC), |
| 5049 CreateMockRead(*wrapped_get_resp, 9, ASYNC), | 5001 CreateMockRead(*wrapped_get_resp, 9, ASYNC), |
| 5050 CreateMockRead(*wrapped_body, 10, ASYNC), | 5002 CreateMockRead(*wrapped_body, 10, ASYNC), |
| 5051 MockRead(ASYNC, OK, 11), // EOF. May or may not be read. | 5003 MockRead(ASYNC, OK, 11), // EOF. May or may not be read. |
| 5052 }; | 5004 }; |
| 5053 | 5005 |
| 5054 OrderedSocketData spdy_data( | 5006 OrderedSocketData spdy_data( |
| 5055 spdy_reads, arraysize(spdy_reads), | 5007 spdy_reads, arraysize(spdy_reads), |
| 5056 spdy_writes, arraysize(spdy_writes)); | 5008 spdy_writes, arraysize(spdy_writes)); |
| 5057 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 5009 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 5058 // Negotiate SPDY to the proxy | 5010 // Negotiate SPDY to the proxy |
| 5059 SSLSocketDataProvider proxy(ASYNC, OK); | 5011 SSLSocketDataProvider proxy(ASYNC, OK); |
| 5060 proxy.SetNextProto(kProtoSPDY2); | 5012 proxy.SetNextProto(kProtoSPDY2); |
| 5061 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy); | 5013 session_deps.socket_factory->AddSSLSocketDataProvider(&proxy); |
| 5062 // Vanilla SSL to the server | 5014 // Vanilla SSL to the server |
| 5063 SSLSocketDataProvider server(ASYNC, OK); | 5015 SSLSocketDataProvider server(ASYNC, OK); |
| 5064 session_deps.socket_factory.AddSSLSocketDataProvider(&server); | 5016 session_deps.socket_factory->AddSSLSocketDataProvider(&server); |
| 5065 | 5017 |
| 5066 TestCompletionCallback callback1; | 5018 TestCompletionCallback callback1; |
| 5067 | 5019 |
| 5068 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 5020 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 5069 | 5021 |
| 5070 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 5022 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 5071 EXPECT_EQ(ERR_IO_PENDING, rv); | 5023 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5072 | 5024 |
| 5073 rv = callback1.WaitForResult(); | 5025 rv = callback1.WaitForResult(); |
| 5074 EXPECT_EQ(OK, rv); | 5026 EXPECT_EQ(OK, rv); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5125 0x01, 0x00, 0x00, 0x06, // FIN, length | 5077 0x01, 0x00, 0x00, 0x06, // FIN, length |
| 5126 'p', 'u', 's', 'h', 'e', 'd' // "pushed" | 5078 'p', 'u', 's', 'h', 'e', 'd' // "pushed" |
| 5127 }; | 5079 }; |
| 5128 | 5080 |
| 5129 request.method = "GET"; | 5081 request.method = "GET"; |
| 5130 request.url = GURL("http://www.google.com/"); | 5082 request.url = GURL("http://www.google.com/"); |
| 5131 push_request.method = "GET"; | 5083 push_request.method = "GET"; |
| 5132 push_request.url = GURL("http://www.another-origin.com/foo.dat"); | 5084 push_request.url = GURL("http://www.another-origin.com/foo.dat"); |
| 5133 | 5085 |
| 5134 // Configure against https proxy server "myproxy:70". | 5086 // Configure against https proxy server "myproxy:70". |
| 5135 SessionDependencies session_deps( | 5087 SpdySessionDependencies session_deps( |
| 5136 ProxyService::CreateFixed("https://myproxy:70")); | 5088 ProxyService::CreateFixed("https://myproxy:70")); |
| 5137 CapturingBoundNetLog log; | 5089 CapturingBoundNetLog log; |
| 5138 session_deps.net_log = log.bound().net_log(); | 5090 session_deps.net_log = log.bound().net_log(); |
| 5139 | 5091 |
| 5140 // Enable cross-origin push. | 5092 // Enable cross-origin push. |
| 5141 session_deps.trusted_spdy_proxy = "myproxy:70"; | 5093 session_deps.trusted_spdy_proxy = "myproxy:70"; |
| 5142 | 5094 |
| 5143 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 5095 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 5144 | 5096 |
| 5145 scoped_ptr<SpdyFrame> | 5097 scoped_ptr<SpdyFrame> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5167 CreateMockRead(*stream2_syn, 3, ASYNC), | 5119 CreateMockRead(*stream2_syn, 3, ASYNC), |
| 5168 CreateMockRead(*stream1_body, 4, ASYNC), | 5120 CreateMockRead(*stream1_body, 4, ASYNC), |
| 5169 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), | 5121 MockRead(ASYNC, reinterpret_cast<const char*>(kPushBodyFrame), |
| 5170 arraysize(kPushBodyFrame), 5), | 5122 arraysize(kPushBodyFrame), 5), |
| 5171 MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause | 5123 MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause |
| 5172 }; | 5124 }; |
| 5173 | 5125 |
| 5174 OrderedSocketData spdy_data( | 5126 OrderedSocketData spdy_data( |
| 5175 spdy_reads, arraysize(spdy_reads), | 5127 spdy_reads, arraysize(spdy_reads), |
| 5176 spdy_writes, arraysize(spdy_writes)); | 5128 spdy_writes, arraysize(spdy_writes)); |
| 5177 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 5129 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 5178 // Negotiate SPDY to the proxy | 5130 // Negotiate SPDY to the proxy |
| 5179 SSLSocketDataProvider proxy(ASYNC, OK); | 5131 SSLSocketDataProvider proxy(ASYNC, OK); |
| 5180 proxy.SetNextProto(kProtoSPDY2); | 5132 proxy.SetNextProto(kProtoSPDY2); |
| 5181 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy); | 5133 session_deps.socket_factory->AddSSLSocketDataProvider(&proxy); |
| 5182 | 5134 |
| 5183 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 5135 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 5184 TestCompletionCallback callback; | 5136 TestCompletionCallback callback; |
| 5185 int rv = trans->Start(&request, callback.callback(), log.bound()); | 5137 int rv = trans->Start(&request, callback.callback(), log.bound()); |
| 5186 EXPECT_EQ(ERR_IO_PENDING, rv); | 5138 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5187 | 5139 |
| 5188 rv = callback.WaitForResult(); | 5140 rv = callback.WaitForResult(); |
| 5189 EXPECT_EQ(OK, rv); | 5141 EXPECT_EQ(OK, rv); |
| 5190 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5142 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5191 | 5143 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 5222 } | 5174 } |
| 5223 | 5175 |
| 5224 // Test that an explicitly trusted SPDY proxy cannot push HTTPS content. | 5176 // Test that an explicitly trusted SPDY proxy cannot push HTTPS content. |
| 5225 TEST_F(HttpNetworkTransactionSpdy2Test, CrossOriginProxyPushCorrectness) { | 5177 TEST_F(HttpNetworkTransactionSpdy2Test, CrossOriginProxyPushCorrectness) { |
| 5226 HttpRequestInfo request; | 5178 HttpRequestInfo request; |
| 5227 | 5179 |
| 5228 request.method = "GET"; | 5180 request.method = "GET"; |
| 5229 request.url = GURL("http://www.google.com/"); | 5181 request.url = GURL("http://www.google.com/"); |
| 5230 | 5182 |
| 5231 // Configure against https proxy server "myproxy:70". | 5183 // Configure against https proxy server "myproxy:70". |
| 5232 SessionDependencies session_deps( | 5184 SpdySessionDependencies session_deps( |
| 5233 ProxyService::CreateFixed("https://myproxy:70")); | 5185 ProxyService::CreateFixed("https://myproxy:70")); |
| 5234 CapturingBoundNetLog log; | 5186 CapturingBoundNetLog log; |
| 5235 session_deps.net_log = log.bound().net_log(); | 5187 session_deps.net_log = log.bound().net_log(); |
| 5236 | 5188 |
| 5237 // Enable cross-origin push. | 5189 // Enable cross-origin push. |
| 5238 session_deps.trusted_spdy_proxy = "myproxy:70"; | 5190 session_deps.trusted_spdy_proxy = "myproxy:70"; |
| 5239 | 5191 |
| 5240 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 5192 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 5241 | 5193 |
| 5242 scoped_ptr<SpdyFrame> | 5194 scoped_ptr<SpdyFrame> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 5266 MockRead spdy_reads[] = { | 5218 MockRead spdy_reads[] = { |
| 5267 CreateMockRead(*stream1_reply, 2, ASYNC), | 5219 CreateMockRead(*stream1_reply, 2, ASYNC), |
| 5268 CreateMockRead(*stream2_syn, 3, ASYNC), | 5220 CreateMockRead(*stream2_syn, 3, ASYNC), |
| 5269 CreateMockRead(*stream1_body, 5, ASYNC), | 5221 CreateMockRead(*stream1_body, 5, ASYNC), |
| 5270 MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause | 5222 MockRead(ASYNC, ERR_IO_PENDING, 6), // Force a pause |
| 5271 }; | 5223 }; |
| 5272 | 5224 |
| 5273 OrderedSocketData spdy_data( | 5225 OrderedSocketData spdy_data( |
| 5274 spdy_reads, arraysize(spdy_reads), | 5226 spdy_reads, arraysize(spdy_reads), |
| 5275 spdy_writes, arraysize(spdy_writes)); | 5227 spdy_writes, arraysize(spdy_writes)); |
| 5276 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 5228 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 5277 // Negotiate SPDY to the proxy | 5229 // Negotiate SPDY to the proxy |
| 5278 SSLSocketDataProvider proxy(ASYNC, OK); | 5230 SSLSocketDataProvider proxy(ASYNC, OK); |
| 5279 proxy.SetNextProto(kProtoSPDY2); | 5231 proxy.SetNextProto(kProtoSPDY2); |
| 5280 session_deps.socket_factory.AddSSLSocketDataProvider(&proxy); | 5232 session_deps.socket_factory->AddSSLSocketDataProvider(&proxy); |
| 5281 | 5233 |
| 5282 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 5234 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 5283 TestCompletionCallback callback; | 5235 TestCompletionCallback callback; |
| 5284 int rv = trans->Start(&request, callback.callback(), log.bound()); | 5236 int rv = trans->Start(&request, callback.callback(), log.bound()); |
| 5285 EXPECT_EQ(ERR_IO_PENDING, rv); | 5237 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5286 | 5238 |
| 5287 rv = callback.WaitForResult(); | 5239 rv = callback.WaitForResult(); |
| 5288 EXPECT_EQ(OK, rv); | 5240 EXPECT_EQ(OK, rv); |
| 5289 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5241 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5290 | 5242 |
| 5291 ASSERT_TRUE(response != NULL); | 5243 ASSERT_TRUE(response != NULL); |
| 5292 EXPECT_TRUE(response->headers->IsKeepAlive()); | 5244 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 5293 | 5245 |
| 5294 EXPECT_EQ(200, response->headers->response_code()); | 5246 EXPECT_EQ(200, response->headers->response_code()); |
| 5295 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 5247 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 5296 | 5248 |
| 5297 std::string response_data; | 5249 std::string response_data; |
| 5298 rv = ReadTransaction(trans.get(), &response_data); | 5250 rv = ReadTransaction(trans.get(), &response_data); |
| 5299 EXPECT_EQ(OK, rv); | 5251 EXPECT_EQ(OK, rv); |
| 5300 EXPECT_EQ("hello!", response_data); | 5252 EXPECT_EQ("hello!", response_data); |
| 5301 | 5253 |
| 5302 trans.reset(); | 5254 trans.reset(); |
| 5303 session->CloseAllConnections(); | 5255 session->CloseAllConnections(); |
| 5304 } | 5256 } |
| 5305 | 5257 |
| 5306 // Test HTTPS connections to a site with a bad certificate, going through an | 5258 // Test HTTPS connections to a site with a bad certificate, going through an |
| 5307 // HTTPS proxy | 5259 // HTTPS proxy |
| 5308 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSBadCertificateViaHttpsProxy) { | 5260 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSBadCertificateViaHttpsProxy) { |
| 5309 SessionDependencies session_deps(ProxyService::CreateFixed( | 5261 SpdySessionDependencies session_deps(ProxyService::CreateFixed( |
| 5310 "https://proxy:70")); | 5262 "https://proxy:70")); |
| 5311 | 5263 |
| 5312 HttpRequestInfo request; | 5264 HttpRequestInfo request; |
| 5313 request.method = "GET"; | 5265 request.method = "GET"; |
| 5314 request.url = GURL("https://www.google.com/"); | 5266 request.url = GURL("https://www.google.com/"); |
| 5315 request.load_flags = 0; | 5267 request.load_flags = 0; |
| 5316 | 5268 |
| 5317 // Attempt to fetch the URL from a server with a bad cert | 5269 // Attempt to fetch the URL from a server with a bad cert |
| 5318 MockWrite bad_cert_writes[] = { | 5270 MockWrite bad_cert_writes[] = { |
| 5319 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 5271 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 5346 | 5298 |
| 5347 StaticSocketDataProvider ssl_bad_certificate( | 5299 StaticSocketDataProvider ssl_bad_certificate( |
| 5348 bad_cert_reads, arraysize(bad_cert_reads), | 5300 bad_cert_reads, arraysize(bad_cert_reads), |
| 5349 bad_cert_writes, arraysize(bad_cert_writes)); | 5301 bad_cert_writes, arraysize(bad_cert_writes)); |
| 5350 StaticSocketDataProvider data(good_cert_reads, arraysize(good_cert_reads), | 5302 StaticSocketDataProvider data(good_cert_reads, arraysize(good_cert_reads), |
| 5351 good_data_writes, arraysize(good_data_writes)); | 5303 good_data_writes, arraysize(good_data_writes)); |
| 5352 SSLSocketDataProvider ssl_bad(ASYNC, ERR_CERT_AUTHORITY_INVALID); | 5304 SSLSocketDataProvider ssl_bad(ASYNC, ERR_CERT_AUTHORITY_INVALID); |
| 5353 SSLSocketDataProvider ssl(ASYNC, OK); | 5305 SSLSocketDataProvider ssl(ASYNC, OK); |
| 5354 | 5306 |
| 5355 // SSL to the proxy, then CONNECT request, then SSL with bad certificate | 5307 // SSL to the proxy, then CONNECT request, then SSL with bad certificate |
| 5356 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 5308 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 5357 session_deps.socket_factory.AddSocketDataProvider(&ssl_bad_certificate); | 5309 session_deps.socket_factory->AddSocketDataProvider(&ssl_bad_certificate); |
| 5358 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_bad); | 5310 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_bad); |
| 5359 | 5311 |
| 5360 // SSL to the proxy, then CONNECT request, then valid SSL certificate | 5312 // SSL to the proxy, then CONNECT request, then valid SSL certificate |
| 5361 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 5313 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 5362 session_deps.socket_factory.AddSocketDataProvider(&data); | 5314 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5363 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 5315 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 5364 | 5316 |
| 5365 TestCompletionCallback callback; | 5317 TestCompletionCallback callback; |
| 5366 | 5318 |
| 5367 scoped_ptr<HttpTransaction> trans( | 5319 scoped_ptr<HttpTransaction> trans( |
| 5368 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5320 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5369 | 5321 |
| 5370 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5322 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5371 EXPECT_EQ(ERR_IO_PENDING, rv); | 5323 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5372 | 5324 |
| 5373 rv = callback.WaitForResult(); | 5325 rv = callback.WaitForResult(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5385 EXPECT_EQ(100, response->headers->GetContentLength()); | 5337 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 5386 } | 5338 } |
| 5387 | 5339 |
| 5388 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_UserAgent) { | 5340 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_UserAgent) { |
| 5389 HttpRequestInfo request; | 5341 HttpRequestInfo request; |
| 5390 request.method = "GET"; | 5342 request.method = "GET"; |
| 5391 request.url = GURL("http://www.google.com/"); | 5343 request.url = GURL("http://www.google.com/"); |
| 5392 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, | 5344 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, |
| 5393 "Chromium Ultra Awesome X Edition"); | 5345 "Chromium Ultra Awesome X Edition"); |
| 5394 | 5346 |
| 5395 SessionDependencies session_deps; | 5347 SpdySessionDependencies session_deps; |
| 5396 scoped_ptr<HttpTransaction> trans( | 5348 scoped_ptr<HttpTransaction> trans( |
| 5397 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5349 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5398 | 5350 |
| 5399 MockWrite data_writes[] = { | 5351 MockWrite data_writes[] = { |
| 5400 MockWrite("GET / HTTP/1.1\r\n" | 5352 MockWrite("GET / HTTP/1.1\r\n" |
| 5401 "Host: www.google.com\r\n" | 5353 "Host: www.google.com\r\n" |
| 5402 "Connection: keep-alive\r\n" | 5354 "Connection: keep-alive\r\n" |
| 5403 "User-Agent: Chromium Ultra Awesome X Edition\r\n\r\n"), | 5355 "User-Agent: Chromium Ultra Awesome X Edition\r\n\r\n"), |
| 5404 }; | 5356 }; |
| 5405 | 5357 |
| 5406 // Lastly, the server responds with the actual content. | 5358 // Lastly, the server responds with the actual content. |
| 5407 MockRead data_reads[] = { | 5359 MockRead data_reads[] = { |
| 5408 MockRead("HTTP/1.0 200 OK\r\n"), | 5360 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5409 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5361 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5410 MockRead("Content-Length: 100\r\n\r\n"), | 5362 MockRead("Content-Length: 100\r\n\r\n"), |
| 5411 MockRead(SYNCHRONOUS, OK), | 5363 MockRead(SYNCHRONOUS, OK), |
| 5412 }; | 5364 }; |
| 5413 | 5365 |
| 5414 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5366 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5415 data_writes, arraysize(data_writes)); | 5367 data_writes, arraysize(data_writes)); |
| 5416 session_deps.socket_factory.AddSocketDataProvider(&data); | 5368 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5417 | 5369 |
| 5418 TestCompletionCallback callback; | 5370 TestCompletionCallback callback; |
| 5419 | 5371 |
| 5420 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5372 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5421 EXPECT_EQ(ERR_IO_PENDING, rv); | 5373 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5422 | 5374 |
| 5423 rv = callback.WaitForResult(); | 5375 rv = callback.WaitForResult(); |
| 5424 EXPECT_EQ(OK, rv); | 5376 EXPECT_EQ(OK, rv); |
| 5425 } | 5377 } |
| 5426 | 5378 |
| 5427 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_UserAgentOverTunnel) { | 5379 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_UserAgentOverTunnel) { |
| 5428 HttpRequestInfo request; | 5380 HttpRequestInfo request; |
| 5429 request.method = "GET"; | 5381 request.method = "GET"; |
| 5430 request.url = GURL("https://www.google.com/"); | 5382 request.url = GURL("https://www.google.com/"); |
| 5431 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, | 5383 request.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, |
| 5432 "Chromium Ultra Awesome X Edition"); | 5384 "Chromium Ultra Awesome X Edition"); |
| 5433 | 5385 |
| 5434 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 5386 SpdySessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 5435 scoped_ptr<HttpTransaction> trans( | 5387 scoped_ptr<HttpTransaction> trans( |
| 5436 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5388 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5437 | 5389 |
| 5438 MockWrite data_writes[] = { | 5390 MockWrite data_writes[] = { |
| 5439 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 5391 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 5440 "Host: www.google.com\r\n" | 5392 "Host: www.google.com\r\n" |
| 5441 "Proxy-Connection: keep-alive\r\n" | 5393 "Proxy-Connection: keep-alive\r\n" |
| 5442 "User-Agent: Chromium Ultra Awesome X Edition\r\n\r\n"), | 5394 "User-Agent: Chromium Ultra Awesome X Edition\r\n\r\n"), |
| 5443 }; | 5395 }; |
| 5444 MockRead data_reads[] = { | 5396 MockRead data_reads[] = { |
| 5445 // Return an error, so the transaction stops here (this test isn't | 5397 // Return an error, so the transaction stops here (this test isn't |
| 5446 // interested in the rest). | 5398 // interested in the rest). |
| 5447 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), | 5399 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), |
| 5448 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 5400 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 5449 MockRead("Proxy-Connection: close\r\n\r\n"), | 5401 MockRead("Proxy-Connection: close\r\n\r\n"), |
| 5450 }; | 5402 }; |
| 5451 | 5403 |
| 5452 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5404 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5453 data_writes, arraysize(data_writes)); | 5405 data_writes, arraysize(data_writes)); |
| 5454 session_deps.socket_factory.AddSocketDataProvider(&data); | 5406 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5455 | 5407 |
| 5456 TestCompletionCallback callback; | 5408 TestCompletionCallback callback; |
| 5457 | 5409 |
| 5458 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5410 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5459 EXPECT_EQ(ERR_IO_PENDING, rv); | 5411 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5460 | 5412 |
| 5461 rv = callback.WaitForResult(); | 5413 rv = callback.WaitForResult(); |
| 5462 EXPECT_EQ(OK, rv); | 5414 EXPECT_EQ(OK, rv); |
| 5463 } | 5415 } |
| 5464 | 5416 |
| 5465 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_Referer) { | 5417 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_Referer) { |
| 5466 HttpRequestInfo request; | 5418 HttpRequestInfo request; |
| 5467 request.method = "GET"; | 5419 request.method = "GET"; |
| 5468 request.url = GURL("http://www.google.com/"); | 5420 request.url = GURL("http://www.google.com/"); |
| 5469 request.load_flags = 0; | 5421 request.load_flags = 0; |
| 5470 request.extra_headers.SetHeader(HttpRequestHeaders::kReferer, | 5422 request.extra_headers.SetHeader(HttpRequestHeaders::kReferer, |
| 5471 "http://the.previous.site.com/"); | 5423 "http://the.previous.site.com/"); |
| 5472 | 5424 |
| 5473 SessionDependencies session_deps; | 5425 SpdySessionDependencies session_deps; |
| 5474 scoped_ptr<HttpTransaction> trans( | 5426 scoped_ptr<HttpTransaction> trans( |
| 5475 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5427 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5476 | 5428 |
| 5477 MockWrite data_writes[] = { | 5429 MockWrite data_writes[] = { |
| 5478 MockWrite("GET / HTTP/1.1\r\n" | 5430 MockWrite("GET / HTTP/1.1\r\n" |
| 5479 "Host: www.google.com\r\n" | 5431 "Host: www.google.com\r\n" |
| 5480 "Connection: keep-alive\r\n" | 5432 "Connection: keep-alive\r\n" |
| 5481 "Referer: http://the.previous.site.com/\r\n\r\n"), | 5433 "Referer: http://the.previous.site.com/\r\n\r\n"), |
| 5482 }; | 5434 }; |
| 5483 | 5435 |
| 5484 // Lastly, the server responds with the actual content. | 5436 // Lastly, the server responds with the actual content. |
| 5485 MockRead data_reads[] = { | 5437 MockRead data_reads[] = { |
| 5486 MockRead("HTTP/1.0 200 OK\r\n"), | 5438 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5487 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5439 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5488 MockRead("Content-Length: 100\r\n\r\n"), | 5440 MockRead("Content-Length: 100\r\n\r\n"), |
| 5489 MockRead(SYNCHRONOUS, OK), | 5441 MockRead(SYNCHRONOUS, OK), |
| 5490 }; | 5442 }; |
| 5491 | 5443 |
| 5492 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5444 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5493 data_writes, arraysize(data_writes)); | 5445 data_writes, arraysize(data_writes)); |
| 5494 session_deps.socket_factory.AddSocketDataProvider(&data); | 5446 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5495 | 5447 |
| 5496 TestCompletionCallback callback; | 5448 TestCompletionCallback callback; |
| 5497 | 5449 |
| 5498 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5450 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5499 EXPECT_EQ(ERR_IO_PENDING, rv); | 5451 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5500 | 5452 |
| 5501 rv = callback.WaitForResult(); | 5453 rv = callback.WaitForResult(); |
| 5502 EXPECT_EQ(OK, rv); | 5454 EXPECT_EQ(OK, rv); |
| 5503 } | 5455 } |
| 5504 | 5456 |
| 5505 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_PostContentLengthZero) { | 5457 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_PostContentLengthZero) { |
| 5506 HttpRequestInfo request; | 5458 HttpRequestInfo request; |
| 5507 request.method = "POST"; | 5459 request.method = "POST"; |
| 5508 request.url = GURL("http://www.google.com/"); | 5460 request.url = GURL("http://www.google.com/"); |
| 5509 | 5461 |
| 5510 SessionDependencies session_deps; | 5462 SpdySessionDependencies session_deps; |
| 5511 scoped_ptr<HttpTransaction> trans( | 5463 scoped_ptr<HttpTransaction> trans( |
| 5512 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5464 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5513 | 5465 |
| 5514 MockWrite data_writes[] = { | 5466 MockWrite data_writes[] = { |
| 5515 MockWrite("POST / HTTP/1.1\r\n" | 5467 MockWrite("POST / HTTP/1.1\r\n" |
| 5516 "Host: www.google.com\r\n" | 5468 "Host: www.google.com\r\n" |
| 5517 "Connection: keep-alive\r\n" | 5469 "Connection: keep-alive\r\n" |
| 5518 "Content-Length: 0\r\n\r\n"), | 5470 "Content-Length: 0\r\n\r\n"), |
| 5519 }; | 5471 }; |
| 5520 | 5472 |
| 5521 // Lastly, the server responds with the actual content. | 5473 // Lastly, the server responds with the actual content. |
| 5522 MockRead data_reads[] = { | 5474 MockRead data_reads[] = { |
| 5523 MockRead("HTTP/1.0 200 OK\r\n"), | 5475 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5524 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5476 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5525 MockRead("Content-Length: 100\r\n\r\n"), | 5477 MockRead("Content-Length: 100\r\n\r\n"), |
| 5526 MockRead(SYNCHRONOUS, OK), | 5478 MockRead(SYNCHRONOUS, OK), |
| 5527 }; | 5479 }; |
| 5528 | 5480 |
| 5529 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5481 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5530 data_writes, arraysize(data_writes)); | 5482 data_writes, arraysize(data_writes)); |
| 5531 session_deps.socket_factory.AddSocketDataProvider(&data); | 5483 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5532 | 5484 |
| 5533 TestCompletionCallback callback; | 5485 TestCompletionCallback callback; |
| 5534 | 5486 |
| 5535 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5487 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5536 EXPECT_EQ(ERR_IO_PENDING, rv); | 5488 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5537 | 5489 |
| 5538 rv = callback.WaitForResult(); | 5490 rv = callback.WaitForResult(); |
| 5539 EXPECT_EQ(OK, rv); | 5491 EXPECT_EQ(OK, rv); |
| 5540 } | 5492 } |
| 5541 | 5493 |
| 5542 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_PutContentLengthZero) { | 5494 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_PutContentLengthZero) { |
| 5543 HttpRequestInfo request; | 5495 HttpRequestInfo request; |
| 5544 request.method = "PUT"; | 5496 request.method = "PUT"; |
| 5545 request.url = GURL("http://www.google.com/"); | 5497 request.url = GURL("http://www.google.com/"); |
| 5546 | 5498 |
| 5547 SessionDependencies session_deps; | 5499 SpdySessionDependencies session_deps; |
| 5548 scoped_ptr<HttpTransaction> trans( | 5500 scoped_ptr<HttpTransaction> trans( |
| 5549 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5501 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5550 | 5502 |
| 5551 MockWrite data_writes[] = { | 5503 MockWrite data_writes[] = { |
| 5552 MockWrite("PUT / HTTP/1.1\r\n" | 5504 MockWrite("PUT / HTTP/1.1\r\n" |
| 5553 "Host: www.google.com\r\n" | 5505 "Host: www.google.com\r\n" |
| 5554 "Connection: keep-alive\r\n" | 5506 "Connection: keep-alive\r\n" |
| 5555 "Content-Length: 0\r\n\r\n"), | 5507 "Content-Length: 0\r\n\r\n"), |
| 5556 }; | 5508 }; |
| 5557 | 5509 |
| 5558 // Lastly, the server responds with the actual content. | 5510 // Lastly, the server responds with the actual content. |
| 5559 MockRead data_reads[] = { | 5511 MockRead data_reads[] = { |
| 5560 MockRead("HTTP/1.0 200 OK\r\n"), | 5512 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5561 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5513 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5562 MockRead("Content-Length: 100\r\n\r\n"), | 5514 MockRead("Content-Length: 100\r\n\r\n"), |
| 5563 MockRead(SYNCHRONOUS, OK), | 5515 MockRead(SYNCHRONOUS, OK), |
| 5564 }; | 5516 }; |
| 5565 | 5517 |
| 5566 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5518 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5567 data_writes, arraysize(data_writes)); | 5519 data_writes, arraysize(data_writes)); |
| 5568 session_deps.socket_factory.AddSocketDataProvider(&data); | 5520 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5569 | 5521 |
| 5570 TestCompletionCallback callback; | 5522 TestCompletionCallback callback; |
| 5571 | 5523 |
| 5572 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5524 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5573 EXPECT_EQ(ERR_IO_PENDING, rv); | 5525 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5574 | 5526 |
| 5575 rv = callback.WaitForResult(); | 5527 rv = callback.WaitForResult(); |
| 5576 EXPECT_EQ(OK, rv); | 5528 EXPECT_EQ(OK, rv); |
| 5577 } | 5529 } |
| 5578 | 5530 |
| 5579 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_HeadContentLengthZero) { | 5531 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_HeadContentLengthZero) { |
| 5580 HttpRequestInfo request; | 5532 HttpRequestInfo request; |
| 5581 request.method = "HEAD"; | 5533 request.method = "HEAD"; |
| 5582 request.url = GURL("http://www.google.com/"); | 5534 request.url = GURL("http://www.google.com/"); |
| 5583 | 5535 |
| 5584 SessionDependencies session_deps; | 5536 SpdySessionDependencies session_deps; |
| 5585 scoped_ptr<HttpTransaction> trans( | 5537 scoped_ptr<HttpTransaction> trans( |
| 5586 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5538 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5587 | 5539 |
| 5588 MockWrite data_writes[] = { | 5540 MockWrite data_writes[] = { |
| 5589 MockWrite("HEAD / HTTP/1.1\r\n" | 5541 MockWrite("HEAD / HTTP/1.1\r\n" |
| 5590 "Host: www.google.com\r\n" | 5542 "Host: www.google.com\r\n" |
| 5591 "Connection: keep-alive\r\n" | 5543 "Connection: keep-alive\r\n" |
| 5592 "Content-Length: 0\r\n\r\n"), | 5544 "Content-Length: 0\r\n\r\n"), |
| 5593 }; | 5545 }; |
| 5594 | 5546 |
| 5595 // Lastly, the server responds with the actual content. | 5547 // Lastly, the server responds with the actual content. |
| 5596 MockRead data_reads[] = { | 5548 MockRead data_reads[] = { |
| 5597 MockRead("HTTP/1.0 200 OK\r\n"), | 5549 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5598 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5550 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5599 MockRead("Content-Length: 100\r\n\r\n"), | 5551 MockRead("Content-Length: 100\r\n\r\n"), |
| 5600 MockRead(SYNCHRONOUS, OK), | 5552 MockRead(SYNCHRONOUS, OK), |
| 5601 }; | 5553 }; |
| 5602 | 5554 |
| 5603 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5555 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5604 data_writes, arraysize(data_writes)); | 5556 data_writes, arraysize(data_writes)); |
| 5605 session_deps.socket_factory.AddSocketDataProvider(&data); | 5557 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5606 | 5558 |
| 5607 TestCompletionCallback callback; | 5559 TestCompletionCallback callback; |
| 5608 | 5560 |
| 5609 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5561 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5610 EXPECT_EQ(ERR_IO_PENDING, rv); | 5562 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5611 | 5563 |
| 5612 rv = callback.WaitForResult(); | 5564 rv = callback.WaitForResult(); |
| 5613 EXPECT_EQ(OK, rv); | 5565 EXPECT_EQ(OK, rv); |
| 5614 } | 5566 } |
| 5615 | 5567 |
| 5616 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_CacheControlNoCache) { | 5568 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_CacheControlNoCache) { |
| 5617 HttpRequestInfo request; | 5569 HttpRequestInfo request; |
| 5618 request.method = "GET"; | 5570 request.method = "GET"; |
| 5619 request.url = GURL("http://www.google.com/"); | 5571 request.url = GURL("http://www.google.com/"); |
| 5620 request.load_flags = LOAD_BYPASS_CACHE; | 5572 request.load_flags = LOAD_BYPASS_CACHE; |
| 5621 | 5573 |
| 5622 SessionDependencies session_deps; | 5574 SpdySessionDependencies session_deps; |
| 5623 scoped_ptr<HttpTransaction> trans( | 5575 scoped_ptr<HttpTransaction> trans( |
| 5624 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5576 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5625 | 5577 |
| 5626 MockWrite data_writes[] = { | 5578 MockWrite data_writes[] = { |
| 5627 MockWrite("GET / HTTP/1.1\r\n" | 5579 MockWrite("GET / HTTP/1.1\r\n" |
| 5628 "Host: www.google.com\r\n" | 5580 "Host: www.google.com\r\n" |
| 5629 "Connection: keep-alive\r\n" | 5581 "Connection: keep-alive\r\n" |
| 5630 "Pragma: no-cache\r\n" | 5582 "Pragma: no-cache\r\n" |
| 5631 "Cache-Control: no-cache\r\n\r\n"), | 5583 "Cache-Control: no-cache\r\n\r\n"), |
| 5632 }; | 5584 }; |
| 5633 | 5585 |
| 5634 // Lastly, the server responds with the actual content. | 5586 // Lastly, the server responds with the actual content. |
| 5635 MockRead data_reads[] = { | 5587 MockRead data_reads[] = { |
| 5636 MockRead("HTTP/1.0 200 OK\r\n"), | 5588 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5637 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5589 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5638 MockRead("Content-Length: 100\r\n\r\n"), | 5590 MockRead("Content-Length: 100\r\n\r\n"), |
| 5639 MockRead(SYNCHRONOUS, OK), | 5591 MockRead(SYNCHRONOUS, OK), |
| 5640 }; | 5592 }; |
| 5641 | 5593 |
| 5642 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5594 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5643 data_writes, arraysize(data_writes)); | 5595 data_writes, arraysize(data_writes)); |
| 5644 session_deps.socket_factory.AddSocketDataProvider(&data); | 5596 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5645 | 5597 |
| 5646 TestCompletionCallback callback; | 5598 TestCompletionCallback callback; |
| 5647 | 5599 |
| 5648 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5600 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5649 EXPECT_EQ(ERR_IO_PENDING, rv); | 5601 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5650 | 5602 |
| 5651 rv = callback.WaitForResult(); | 5603 rv = callback.WaitForResult(); |
| 5652 EXPECT_EQ(OK, rv); | 5604 EXPECT_EQ(OK, rv); |
| 5653 } | 5605 } |
| 5654 | 5606 |
| 5655 TEST_F(HttpNetworkTransactionSpdy2Test, | 5607 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 5656 BuildRequest_CacheControlValidateCache) { | 5608 BuildRequest_CacheControlValidateCache) { |
| 5657 HttpRequestInfo request; | 5609 HttpRequestInfo request; |
| 5658 request.method = "GET"; | 5610 request.method = "GET"; |
| 5659 request.url = GURL("http://www.google.com/"); | 5611 request.url = GURL("http://www.google.com/"); |
| 5660 request.load_flags = LOAD_VALIDATE_CACHE; | 5612 request.load_flags = LOAD_VALIDATE_CACHE; |
| 5661 | 5613 |
| 5662 SessionDependencies session_deps; | 5614 SpdySessionDependencies session_deps; |
| 5663 scoped_ptr<HttpTransaction> trans( | 5615 scoped_ptr<HttpTransaction> trans( |
| 5664 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5616 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5665 | 5617 |
| 5666 MockWrite data_writes[] = { | 5618 MockWrite data_writes[] = { |
| 5667 MockWrite("GET / HTTP/1.1\r\n" | 5619 MockWrite("GET / HTTP/1.1\r\n" |
| 5668 "Host: www.google.com\r\n" | 5620 "Host: www.google.com\r\n" |
| 5669 "Connection: keep-alive\r\n" | 5621 "Connection: keep-alive\r\n" |
| 5670 "Cache-Control: max-age=0\r\n\r\n"), | 5622 "Cache-Control: max-age=0\r\n\r\n"), |
| 5671 }; | 5623 }; |
| 5672 | 5624 |
| 5673 // Lastly, the server responds with the actual content. | 5625 // Lastly, the server responds with the actual content. |
| 5674 MockRead data_reads[] = { | 5626 MockRead data_reads[] = { |
| 5675 MockRead("HTTP/1.0 200 OK\r\n"), | 5627 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5676 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5628 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5677 MockRead("Content-Length: 100\r\n\r\n"), | 5629 MockRead("Content-Length: 100\r\n\r\n"), |
| 5678 MockRead(SYNCHRONOUS, OK), | 5630 MockRead(SYNCHRONOUS, OK), |
| 5679 }; | 5631 }; |
| 5680 | 5632 |
| 5681 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5633 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5682 data_writes, arraysize(data_writes)); | 5634 data_writes, arraysize(data_writes)); |
| 5683 session_deps.socket_factory.AddSocketDataProvider(&data); | 5635 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5684 | 5636 |
| 5685 TestCompletionCallback callback; | 5637 TestCompletionCallback callback; |
| 5686 | 5638 |
| 5687 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5639 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5688 EXPECT_EQ(ERR_IO_PENDING, rv); | 5640 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5689 | 5641 |
| 5690 rv = callback.WaitForResult(); | 5642 rv = callback.WaitForResult(); |
| 5691 EXPECT_EQ(OK, rv); | 5643 EXPECT_EQ(OK, rv); |
| 5692 } | 5644 } |
| 5693 | 5645 |
| 5694 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_ExtraHeaders) { | 5646 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_ExtraHeaders) { |
| 5695 HttpRequestInfo request; | 5647 HttpRequestInfo request; |
| 5696 request.method = "GET"; | 5648 request.method = "GET"; |
| 5697 request.url = GURL("http://www.google.com/"); | 5649 request.url = GURL("http://www.google.com/"); |
| 5698 request.extra_headers.SetHeader("FooHeader", "Bar"); | 5650 request.extra_headers.SetHeader("FooHeader", "Bar"); |
| 5699 | 5651 |
| 5700 SessionDependencies session_deps; | 5652 SpdySessionDependencies session_deps; |
| 5701 scoped_ptr<HttpTransaction> trans( | 5653 scoped_ptr<HttpTransaction> trans( |
| 5702 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5654 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5703 | 5655 |
| 5704 MockWrite data_writes[] = { | 5656 MockWrite data_writes[] = { |
| 5705 MockWrite("GET / HTTP/1.1\r\n" | 5657 MockWrite("GET / HTTP/1.1\r\n" |
| 5706 "Host: www.google.com\r\n" | 5658 "Host: www.google.com\r\n" |
| 5707 "Connection: keep-alive\r\n" | 5659 "Connection: keep-alive\r\n" |
| 5708 "FooHeader: Bar\r\n\r\n"), | 5660 "FooHeader: Bar\r\n\r\n"), |
| 5709 }; | 5661 }; |
| 5710 | 5662 |
| 5711 // Lastly, the server responds with the actual content. | 5663 // Lastly, the server responds with the actual content. |
| 5712 MockRead data_reads[] = { | 5664 MockRead data_reads[] = { |
| 5713 MockRead("HTTP/1.0 200 OK\r\n"), | 5665 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5714 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5666 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5715 MockRead("Content-Length: 100\r\n\r\n"), | 5667 MockRead("Content-Length: 100\r\n\r\n"), |
| 5716 MockRead(SYNCHRONOUS, OK), | 5668 MockRead(SYNCHRONOUS, OK), |
| 5717 }; | 5669 }; |
| 5718 | 5670 |
| 5719 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5671 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5720 data_writes, arraysize(data_writes)); | 5672 data_writes, arraysize(data_writes)); |
| 5721 session_deps.socket_factory.AddSocketDataProvider(&data); | 5673 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5722 | 5674 |
| 5723 TestCompletionCallback callback; | 5675 TestCompletionCallback callback; |
| 5724 | 5676 |
| 5725 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5677 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5726 EXPECT_EQ(ERR_IO_PENDING, rv); | 5678 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5727 | 5679 |
| 5728 rv = callback.WaitForResult(); | 5680 rv = callback.WaitForResult(); |
| 5729 EXPECT_EQ(OK, rv); | 5681 EXPECT_EQ(OK, rv); |
| 5730 } | 5682 } |
| 5731 | 5683 |
| 5732 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_ExtraHeadersStripped) { | 5684 TEST_F(HttpNetworkTransactionSpdy2Test, BuildRequest_ExtraHeadersStripped) { |
| 5733 HttpRequestInfo request; | 5685 HttpRequestInfo request; |
| 5734 request.method = "GET"; | 5686 request.method = "GET"; |
| 5735 request.url = GURL("http://www.google.com/"); | 5687 request.url = GURL("http://www.google.com/"); |
| 5736 request.extra_headers.SetHeader("referer", "www.foo.com"); | 5688 request.extra_headers.SetHeader("referer", "www.foo.com"); |
| 5737 request.extra_headers.SetHeader("hEllo", "Kitty"); | 5689 request.extra_headers.SetHeader("hEllo", "Kitty"); |
| 5738 request.extra_headers.SetHeader("FoO", "bar"); | 5690 request.extra_headers.SetHeader("FoO", "bar"); |
| 5739 | 5691 |
| 5740 SessionDependencies session_deps; | 5692 SpdySessionDependencies session_deps; |
| 5741 scoped_ptr<HttpTransaction> trans( | 5693 scoped_ptr<HttpTransaction> trans( |
| 5742 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5694 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5743 | 5695 |
| 5744 MockWrite data_writes[] = { | 5696 MockWrite data_writes[] = { |
| 5745 MockWrite("GET / HTTP/1.1\r\n" | 5697 MockWrite("GET / HTTP/1.1\r\n" |
| 5746 "Host: www.google.com\r\n" | 5698 "Host: www.google.com\r\n" |
| 5747 "Connection: keep-alive\r\n" | 5699 "Connection: keep-alive\r\n" |
| 5748 "referer: www.foo.com\r\n" | 5700 "referer: www.foo.com\r\n" |
| 5749 "hEllo: Kitty\r\n" | 5701 "hEllo: Kitty\r\n" |
| 5750 "FoO: bar\r\n\r\n"), | 5702 "FoO: bar\r\n\r\n"), |
| 5751 }; | 5703 }; |
| 5752 | 5704 |
| 5753 // Lastly, the server responds with the actual content. | 5705 // Lastly, the server responds with the actual content. |
| 5754 MockRead data_reads[] = { | 5706 MockRead data_reads[] = { |
| 5755 MockRead("HTTP/1.0 200 OK\r\n"), | 5707 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5756 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 5708 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 5757 MockRead("Content-Length: 100\r\n\r\n"), | 5709 MockRead("Content-Length: 100\r\n\r\n"), |
| 5758 MockRead(SYNCHRONOUS, OK), | 5710 MockRead(SYNCHRONOUS, OK), |
| 5759 }; | 5711 }; |
| 5760 | 5712 |
| 5761 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5713 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5762 data_writes, arraysize(data_writes)); | 5714 data_writes, arraysize(data_writes)); |
| 5763 session_deps.socket_factory.AddSocketDataProvider(&data); | 5715 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5764 | 5716 |
| 5765 TestCompletionCallback callback; | 5717 TestCompletionCallback callback; |
| 5766 | 5718 |
| 5767 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5719 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5768 EXPECT_EQ(ERR_IO_PENDING, rv); | 5720 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5769 | 5721 |
| 5770 rv = callback.WaitForResult(); | 5722 rv = callback.WaitForResult(); |
| 5771 EXPECT_EQ(OK, rv); | 5723 EXPECT_EQ(OK, rv); |
| 5772 } | 5724 } |
| 5773 | 5725 |
| 5774 TEST_F(HttpNetworkTransactionSpdy2Test, SOCKS4_HTTP_GET) { | 5726 TEST_F(HttpNetworkTransactionSpdy2Test, SOCKS4_HTTP_GET) { |
| 5775 HttpRequestInfo request; | 5727 HttpRequestInfo request; |
| 5776 request.method = "GET"; | 5728 request.method = "GET"; |
| 5777 request.url = GURL("http://www.google.com/"); | 5729 request.url = GURL("http://www.google.com/"); |
| 5778 request.load_flags = 0; | 5730 request.load_flags = 0; |
| 5779 | 5731 |
| 5780 SessionDependencies session_deps( | 5732 SpdySessionDependencies session_deps( |
| 5781 ProxyService::CreateFixed("socks4://myproxy:1080")); | 5733 ProxyService::CreateFixed("socks4://myproxy:1080")); |
| 5782 | 5734 |
| 5783 scoped_ptr<HttpTransaction> trans( | 5735 scoped_ptr<HttpTransaction> trans( |
| 5784 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5736 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5785 | 5737 |
| 5786 char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 }; | 5738 char write_buffer[] = { 0x04, 0x01, 0x00, 0x50, 127, 0, 0, 1, 0 }; |
| 5787 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; | 5739 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; |
| 5788 | 5740 |
| 5789 MockWrite data_writes[] = { | 5741 MockWrite data_writes[] = { |
| 5790 MockWrite(ASYNC, write_buffer, arraysize(write_buffer)), | 5742 MockWrite(ASYNC, write_buffer, arraysize(write_buffer)), |
| 5791 MockWrite("GET / HTTP/1.1\r\n" | 5743 MockWrite("GET / HTTP/1.1\r\n" |
| 5792 "Host: www.google.com\r\n" | 5744 "Host: www.google.com\r\n" |
| 5793 "Connection: keep-alive\r\n\r\n") | 5745 "Connection: keep-alive\r\n\r\n") |
| 5794 }; | 5746 }; |
| 5795 | 5747 |
| 5796 MockRead data_reads[] = { | 5748 MockRead data_reads[] = { |
| 5797 MockRead(ASYNC, read_buffer, arraysize(read_buffer)), | 5749 MockRead(ASYNC, read_buffer, arraysize(read_buffer)), |
| 5798 MockRead("HTTP/1.0 200 OK\r\n"), | 5750 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5799 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), | 5751 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), |
| 5800 MockRead("Payload"), | 5752 MockRead("Payload"), |
| 5801 MockRead(SYNCHRONOUS, OK) | 5753 MockRead(SYNCHRONOUS, OK) |
| 5802 }; | 5754 }; |
| 5803 | 5755 |
| 5804 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5756 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5805 data_writes, arraysize(data_writes)); | 5757 data_writes, arraysize(data_writes)); |
| 5806 session_deps.socket_factory.AddSocketDataProvider(&data); | 5758 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5807 | 5759 |
| 5808 TestCompletionCallback callback; | 5760 TestCompletionCallback callback; |
| 5809 | 5761 |
| 5810 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5762 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5811 EXPECT_EQ(ERR_IO_PENDING, rv); | 5763 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5812 | 5764 |
| 5813 rv = callback.WaitForResult(); | 5765 rv = callback.WaitForResult(); |
| 5814 EXPECT_EQ(OK, rv); | 5766 EXPECT_EQ(OK, rv); |
| 5815 | 5767 |
| 5816 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5768 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5817 ASSERT_TRUE(response != NULL); | 5769 ASSERT_TRUE(response != NULL); |
| 5818 | 5770 |
| 5819 std::string response_text; | 5771 std::string response_text; |
| 5820 rv = ReadTransaction(trans.get(), &response_text); | 5772 rv = ReadTransaction(trans.get(), &response_text); |
| 5821 EXPECT_EQ(OK, rv); | 5773 EXPECT_EQ(OK, rv); |
| 5822 EXPECT_EQ("Payload", response_text); | 5774 EXPECT_EQ("Payload", response_text); |
| 5823 } | 5775 } |
| 5824 | 5776 |
| 5825 TEST_F(HttpNetworkTransactionSpdy2Test, SOCKS4_SSL_GET) { | 5777 TEST_F(HttpNetworkTransactionSpdy2Test, SOCKS4_SSL_GET) { |
| 5826 HttpRequestInfo request; | 5778 HttpRequestInfo request; |
| 5827 request.method = "GET"; | 5779 request.method = "GET"; |
| 5828 request.url = GURL("https://www.google.com/"); | 5780 request.url = GURL("https://www.google.com/"); |
| 5829 request.load_flags = 0; | 5781 request.load_flags = 0; |
| 5830 | 5782 |
| 5831 SessionDependencies session_deps( | 5783 SpdySessionDependencies session_deps( |
| 5832 ProxyService::CreateFixed("socks4://myproxy:1080")); | 5784 ProxyService::CreateFixed("socks4://myproxy:1080")); |
| 5833 | 5785 |
| 5834 scoped_ptr<HttpTransaction> trans( | 5786 scoped_ptr<HttpTransaction> trans( |
| 5835 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5787 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5836 | 5788 |
| 5837 unsigned char write_buffer[] = { 0x04, 0x01, 0x01, 0xBB, 127, 0, 0, 1, 0 }; | 5789 unsigned char write_buffer[] = { 0x04, 0x01, 0x01, 0xBB, 127, 0, 0, 1, 0 }; |
| 5838 unsigned char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; | 5790 unsigned char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; |
| 5839 | 5791 |
| 5840 MockWrite data_writes[] = { | 5792 MockWrite data_writes[] = { |
| 5841 MockWrite(ASYNC, reinterpret_cast<char*>(write_buffer), | 5793 MockWrite(ASYNC, reinterpret_cast<char*>(write_buffer), |
| 5842 arraysize(write_buffer)), | 5794 arraysize(write_buffer)), |
| 5843 MockWrite("GET / HTTP/1.1\r\n" | 5795 MockWrite("GET / HTTP/1.1\r\n" |
| 5844 "Host: www.google.com\r\n" | 5796 "Host: www.google.com\r\n" |
| 5845 "Connection: keep-alive\r\n\r\n") | 5797 "Connection: keep-alive\r\n\r\n") |
| 5846 }; | 5798 }; |
| 5847 | 5799 |
| 5848 MockRead data_reads[] = { | 5800 MockRead data_reads[] = { |
| 5849 MockRead(ASYNC, reinterpret_cast<char*>(read_buffer), | 5801 MockRead(ASYNC, reinterpret_cast<char*>(read_buffer), |
| 5850 arraysize(read_buffer)), | 5802 arraysize(read_buffer)), |
| 5851 MockRead("HTTP/1.0 200 OK\r\n"), | 5803 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5852 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), | 5804 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), |
| 5853 MockRead("Payload"), | 5805 MockRead("Payload"), |
| 5854 MockRead(SYNCHRONOUS, OK) | 5806 MockRead(SYNCHRONOUS, OK) |
| 5855 }; | 5807 }; |
| 5856 | 5808 |
| 5857 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5809 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5858 data_writes, arraysize(data_writes)); | 5810 data_writes, arraysize(data_writes)); |
| 5859 session_deps.socket_factory.AddSocketDataProvider(&data); | 5811 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5860 | 5812 |
| 5861 SSLSocketDataProvider ssl(ASYNC, OK); | 5813 SSLSocketDataProvider ssl(ASYNC, OK); |
| 5862 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 5814 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 5863 | 5815 |
| 5864 TestCompletionCallback callback; | 5816 TestCompletionCallback callback; |
| 5865 | 5817 |
| 5866 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5818 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5867 EXPECT_EQ(ERR_IO_PENDING, rv); | 5819 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5868 | 5820 |
| 5869 rv = callback.WaitForResult(); | 5821 rv = callback.WaitForResult(); |
| 5870 EXPECT_EQ(OK, rv); | 5822 EXPECT_EQ(OK, rv); |
| 5871 | 5823 |
| 5872 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5824 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5873 ASSERT_TRUE(response != NULL); | 5825 ASSERT_TRUE(response != NULL); |
| 5874 | 5826 |
| 5875 std::string response_text; | 5827 std::string response_text; |
| 5876 rv = ReadTransaction(trans.get(), &response_text); | 5828 rv = ReadTransaction(trans.get(), &response_text); |
| 5877 EXPECT_EQ(OK, rv); | 5829 EXPECT_EQ(OK, rv); |
| 5878 EXPECT_EQ("Payload", response_text); | 5830 EXPECT_EQ("Payload", response_text); |
| 5879 } | 5831 } |
| 5880 | 5832 |
| 5881 TEST_F(HttpNetworkTransactionSpdy2Test, SOCKS5_HTTP_GET) { | 5833 TEST_F(HttpNetworkTransactionSpdy2Test, SOCKS5_HTTP_GET) { |
| 5882 HttpRequestInfo request; | 5834 HttpRequestInfo request; |
| 5883 request.method = "GET"; | 5835 request.method = "GET"; |
| 5884 request.url = GURL("http://www.google.com/"); | 5836 request.url = GURL("http://www.google.com/"); |
| 5885 request.load_flags = 0; | 5837 request.load_flags = 0; |
| 5886 | 5838 |
| 5887 SessionDependencies session_deps( | 5839 SpdySessionDependencies session_deps( |
| 5888 ProxyService::CreateFixed("socks5://myproxy:1080")); | 5840 ProxyService::CreateFixed("socks5://myproxy:1080")); |
| 5889 | 5841 |
| 5890 scoped_ptr<HttpTransaction> trans( | 5842 scoped_ptr<HttpTransaction> trans( |
| 5891 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5843 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5892 | 5844 |
| 5893 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; | 5845 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; |
| 5894 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; | 5846 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; |
| 5895 const char kSOCKS5OkRequest[] = { | 5847 const char kSOCKS5OkRequest[] = { |
| 5896 0x05, // Version | 5848 0x05, // Version |
| 5897 0x01, // Command (CONNECT) | 5849 0x01, // Command (CONNECT) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5917 MockRead(ASYNC, kSOCKS5GreetResponse, arraysize(kSOCKS5GreetResponse)), | 5869 MockRead(ASYNC, kSOCKS5GreetResponse, arraysize(kSOCKS5GreetResponse)), |
| 5918 MockRead(ASYNC, kSOCKS5OkResponse, arraysize(kSOCKS5OkResponse)), | 5870 MockRead(ASYNC, kSOCKS5OkResponse, arraysize(kSOCKS5OkResponse)), |
| 5919 MockRead("HTTP/1.0 200 OK\r\n"), | 5871 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5920 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), | 5872 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), |
| 5921 MockRead("Payload"), | 5873 MockRead("Payload"), |
| 5922 MockRead(SYNCHRONOUS, OK) | 5874 MockRead(SYNCHRONOUS, OK) |
| 5923 }; | 5875 }; |
| 5924 | 5876 |
| 5925 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5877 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5926 data_writes, arraysize(data_writes)); | 5878 data_writes, arraysize(data_writes)); |
| 5927 session_deps.socket_factory.AddSocketDataProvider(&data); | 5879 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5928 | 5880 |
| 5929 TestCompletionCallback callback; | 5881 TestCompletionCallback callback; |
| 5930 | 5882 |
| 5931 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5883 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 5932 EXPECT_EQ(ERR_IO_PENDING, rv); | 5884 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 5933 | 5885 |
| 5934 rv = callback.WaitForResult(); | 5886 rv = callback.WaitForResult(); |
| 5935 EXPECT_EQ(OK, rv); | 5887 EXPECT_EQ(OK, rv); |
| 5936 | 5888 |
| 5937 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5889 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 5938 ASSERT_TRUE(response != NULL); | 5890 ASSERT_TRUE(response != NULL); |
| 5939 | 5891 |
| 5940 std::string response_text; | 5892 std::string response_text; |
| 5941 rv = ReadTransaction(trans.get(), &response_text); | 5893 rv = ReadTransaction(trans.get(), &response_text); |
| 5942 EXPECT_EQ(OK, rv); | 5894 EXPECT_EQ(OK, rv); |
| 5943 EXPECT_EQ("Payload", response_text); | 5895 EXPECT_EQ("Payload", response_text); |
| 5944 } | 5896 } |
| 5945 | 5897 |
| 5946 TEST_F(HttpNetworkTransactionSpdy2Test, SOCKS5_SSL_GET) { | 5898 TEST_F(HttpNetworkTransactionSpdy2Test, SOCKS5_SSL_GET) { |
| 5947 HttpRequestInfo request; | 5899 HttpRequestInfo request; |
| 5948 request.method = "GET"; | 5900 request.method = "GET"; |
| 5949 request.url = GURL("https://www.google.com/"); | 5901 request.url = GURL("https://www.google.com/"); |
| 5950 request.load_flags = 0; | 5902 request.load_flags = 0; |
| 5951 | 5903 |
| 5952 SessionDependencies session_deps( | 5904 SpdySessionDependencies session_deps( |
| 5953 ProxyService::CreateFixed("socks5://myproxy:1080")); | 5905 ProxyService::CreateFixed("socks5://myproxy:1080")); |
| 5954 | 5906 |
| 5955 scoped_ptr<HttpTransaction> trans( | 5907 scoped_ptr<HttpTransaction> trans( |
| 5956 new HttpNetworkTransaction(CreateSession(&session_deps))); | 5908 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 5957 | 5909 |
| 5958 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; | 5910 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; |
| 5959 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; | 5911 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; |
| 5960 const unsigned char kSOCKS5OkRequest[] = { | 5912 const unsigned char kSOCKS5OkRequest[] = { |
| 5961 0x05, // Version | 5913 0x05, // Version |
| 5962 0x01, // Command (CONNECT) | 5914 0x01, // Command (CONNECT) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5984 MockRead(ASYNC, kSOCKS5GreetResponse, arraysize(kSOCKS5GreetResponse)), | 5936 MockRead(ASYNC, kSOCKS5GreetResponse, arraysize(kSOCKS5GreetResponse)), |
| 5985 MockRead(ASYNC, kSOCKS5OkResponse, arraysize(kSOCKS5OkResponse)), | 5937 MockRead(ASYNC, kSOCKS5OkResponse, arraysize(kSOCKS5OkResponse)), |
| 5986 MockRead("HTTP/1.0 200 OK\r\n"), | 5938 MockRead("HTTP/1.0 200 OK\r\n"), |
| 5987 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), | 5939 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), |
| 5988 MockRead("Payload"), | 5940 MockRead("Payload"), |
| 5989 MockRead(SYNCHRONOUS, OK) | 5941 MockRead(SYNCHRONOUS, OK) |
| 5990 }; | 5942 }; |
| 5991 | 5943 |
| 5992 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 5944 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 5993 data_writes, arraysize(data_writes)); | 5945 data_writes, arraysize(data_writes)); |
| 5994 session_deps.socket_factory.AddSocketDataProvider(&data); | 5946 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 5995 | 5947 |
| 5996 SSLSocketDataProvider ssl(ASYNC, OK); | 5948 SSLSocketDataProvider ssl(ASYNC, OK); |
| 5997 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 5949 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 5998 | 5950 |
| 5999 TestCompletionCallback callback; | 5951 TestCompletionCallback callback; |
| 6000 | 5952 |
| 6001 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 5953 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6002 EXPECT_EQ(ERR_IO_PENDING, rv); | 5954 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6003 | 5955 |
| 6004 rv = callback.WaitForResult(); | 5956 rv = callback.WaitForResult(); |
| 6005 EXPECT_EQ(OK, rv); | 5957 EXPECT_EQ(OK, rv); |
| 6006 | 5958 |
| 6007 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5959 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6018 // Tests that for connection endpoints the group names are correctly set. | 5970 // Tests that for connection endpoints the group names are correctly set. |
| 6019 | 5971 |
| 6020 struct GroupNameTest { | 5972 struct GroupNameTest { |
| 6021 std::string proxy_server; | 5973 std::string proxy_server; |
| 6022 std::string url; | 5974 std::string url; |
| 6023 std::string expected_group_name; | 5975 std::string expected_group_name; |
| 6024 bool ssl; | 5976 bool ssl; |
| 6025 }; | 5977 }; |
| 6026 | 5978 |
| 6027 scoped_refptr<HttpNetworkSession> SetupSessionForGroupNameTests( | 5979 scoped_refptr<HttpNetworkSession> SetupSessionForGroupNameTests( |
| 6028 SessionDependencies* session_deps) { | 5980 SpdySessionDependencies* session_deps) { |
| 6029 scoped_refptr<HttpNetworkSession> session(CreateSession(session_deps)); | 5981 scoped_refptr<HttpNetworkSession> session(CreateSession(session_deps)); |
| 6030 | 5982 |
| 6031 HttpServerProperties* http_server_properties = | 5983 HttpServerProperties* http_server_properties = |
| 6032 session->http_server_properties(); | 5984 session->http_server_properties(); |
| 6033 http_server_properties->SetAlternateProtocol( | 5985 http_server_properties->SetAlternateProtocol( |
| 6034 HostPortPair("host.with.alternate", 80), 443, | 5986 HostPortPair("host.with.alternate", 80), 443, |
| 6035 NPN_SPDY_2); | 5987 NPN_SPDY_2); |
| 6036 | 5988 |
| 6037 return session; | 5989 return session; |
| 6038 } | 5990 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6087 "", // unused | 6039 "", // unused |
| 6088 "http://host.with.alternate/direct", | 6040 "http://host.with.alternate/direct", |
| 6089 "ssl/host.with.alternate:443", | 6041 "ssl/host.with.alternate:443", |
| 6090 true, | 6042 true, |
| 6091 }, | 6043 }, |
| 6092 }; | 6044 }; |
| 6093 | 6045 |
| 6094 HttpStreamFactory::set_use_alternate_protocols(true); | 6046 HttpStreamFactory::set_use_alternate_protocols(true); |
| 6095 | 6047 |
| 6096 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 6048 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 6097 SessionDependencies session_deps( | 6049 SpdySessionDependencies session_deps( |
| 6098 ProxyService::CreateFixed(tests[i].proxy_server)); | 6050 ProxyService::CreateFixed(tests[i].proxy_server)); |
| 6099 scoped_refptr<HttpNetworkSession> session( | 6051 scoped_refptr<HttpNetworkSession> session( |
| 6100 SetupSessionForGroupNameTests(&session_deps)); | 6052 SetupSessionForGroupNameTests(&session_deps)); |
| 6101 | 6053 |
| 6102 HttpNetworkSessionPeer peer(session); | 6054 HttpNetworkSessionPeer peer(session); |
| 6103 CaptureGroupNameTransportSocketPool* transport_conn_pool = | 6055 CaptureGroupNameTransportSocketPool* transport_conn_pool = |
| 6104 new CaptureGroupNameTransportSocketPool(NULL, NULL); | 6056 new CaptureGroupNameTransportSocketPool(NULL, NULL); |
| 6105 CaptureGroupNameSSLSocketPool* ssl_conn_pool = | 6057 CaptureGroupNameSSLSocketPool* ssl_conn_pool = |
| 6106 new CaptureGroupNameSSLSocketPool(NULL, NULL); | 6058 new CaptureGroupNameSSLSocketPool(NULL, NULL); |
| 6107 MockClientSocketPoolManager* mock_pool_manager = | 6059 MockClientSocketPoolManager* mock_pool_manager = |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6144 "http_proxy", | 6096 "http_proxy", |
| 6145 "http://host.with.alternate/direct", | 6097 "http://host.with.alternate/direct", |
| 6146 "ssl/host.with.alternate:443", | 6098 "ssl/host.with.alternate:443", |
| 6147 true, | 6099 true, |
| 6148 }, | 6100 }, |
| 6149 }; | 6101 }; |
| 6150 | 6102 |
| 6151 HttpStreamFactory::set_use_alternate_protocols(true); | 6103 HttpStreamFactory::set_use_alternate_protocols(true); |
| 6152 | 6104 |
| 6153 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 6105 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 6154 SessionDependencies session_deps( | 6106 SpdySessionDependencies session_deps( |
| 6155 ProxyService::CreateFixed(tests[i].proxy_server)); | 6107 ProxyService::CreateFixed(tests[i].proxy_server)); |
| 6156 scoped_refptr<HttpNetworkSession> session( | 6108 scoped_refptr<HttpNetworkSession> session( |
| 6157 SetupSessionForGroupNameTests(&session_deps)); | 6109 SetupSessionForGroupNameTests(&session_deps)); |
| 6158 | 6110 |
| 6159 HttpNetworkSessionPeer peer(session); | 6111 HttpNetworkSessionPeer peer(session); |
| 6160 | 6112 |
| 6161 HostPortPair proxy_host("http_proxy", 80); | 6113 HostPortPair proxy_host("http_proxy", 80); |
| 6162 CaptureGroupNameHttpProxySocketPool* http_proxy_pool = | 6114 CaptureGroupNameHttpProxySocketPool* http_proxy_pool = |
| 6163 new CaptureGroupNameHttpProxySocketPool(NULL, NULL); | 6115 new CaptureGroupNameHttpProxySocketPool(NULL, NULL); |
| 6164 CaptureGroupNameSSLSocketPool* ssl_conn_pool = | 6116 CaptureGroupNameSSLSocketPool* ssl_conn_pool = |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6216 "socks4://socks_proxy:1080", | 6168 "socks4://socks_proxy:1080", |
| 6217 "http://host.with.alternate/direct", | 6169 "http://host.with.alternate/direct", |
| 6218 "socks4/ssl/host.with.alternate:443", | 6170 "socks4/ssl/host.with.alternate:443", |
| 6219 true, | 6171 true, |
| 6220 }, | 6172 }, |
| 6221 }; | 6173 }; |
| 6222 | 6174 |
| 6223 HttpStreamFactory::set_use_alternate_protocols(true); | 6175 HttpStreamFactory::set_use_alternate_protocols(true); |
| 6224 | 6176 |
| 6225 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 6177 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 6226 SessionDependencies session_deps( | 6178 SpdySessionDependencies session_deps( |
| 6227 ProxyService::CreateFixed(tests[i].proxy_server)); | 6179 ProxyService::CreateFixed(tests[i].proxy_server)); |
| 6228 scoped_refptr<HttpNetworkSession> session( | 6180 scoped_refptr<HttpNetworkSession> session( |
| 6229 SetupSessionForGroupNameTests(&session_deps)); | 6181 SetupSessionForGroupNameTests(&session_deps)); |
| 6230 | 6182 |
| 6231 HttpNetworkSessionPeer peer(session); | 6183 HttpNetworkSessionPeer peer(session); |
| 6232 | 6184 |
| 6233 HostPortPair proxy_host("socks_proxy", 1080); | 6185 HostPortPair proxy_host("socks_proxy", 1080); |
| 6234 CaptureGroupNameSOCKSSocketPool* socks_conn_pool = | 6186 CaptureGroupNameSOCKSSocketPool* socks_conn_pool = |
| 6235 new CaptureGroupNameSOCKSSocketPool(NULL, NULL); | 6187 new CaptureGroupNameSOCKSSocketPool(NULL, NULL); |
| 6236 CaptureGroupNameSSLSocketPool* ssl_conn_pool = | 6188 CaptureGroupNameSSLSocketPool* ssl_conn_pool = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6255 } | 6207 } |
| 6256 | 6208 |
| 6257 HttpStreamFactory::set_use_alternate_protocols(false); | 6209 HttpStreamFactory::set_use_alternate_protocols(false); |
| 6258 } | 6210 } |
| 6259 | 6211 |
| 6260 TEST_F(HttpNetworkTransactionSpdy2Test, ReconsiderProxyAfterFailedConnection) { | 6212 TEST_F(HttpNetworkTransactionSpdy2Test, ReconsiderProxyAfterFailedConnection) { |
| 6261 HttpRequestInfo request; | 6213 HttpRequestInfo request; |
| 6262 request.method = "GET"; | 6214 request.method = "GET"; |
| 6263 request.url = GURL("http://www.google.com/"); | 6215 request.url = GURL("http://www.google.com/"); |
| 6264 | 6216 |
| 6265 SessionDependencies session_deps( | 6217 SpdySessionDependencies session_deps( |
| 6266 ProxyService::CreateFixed("myproxy:70;foobar:80")); | 6218 ProxyService::CreateFixed("myproxy:70;foobar:80")); |
| 6267 | 6219 |
| 6268 // This simulates failure resolving all hostnames; that means we will fail | 6220 // This simulates failure resolving all hostnames; that means we will fail |
| 6269 // connecting to both proxies (myproxy:70 and foobar:80). | 6221 // connecting to both proxies (myproxy:70 and foobar:80). |
| 6270 session_deps.host_resolver->rules()->AddSimulatedFailure("*"); | 6222 session_deps.host_resolver->rules()->AddSimulatedFailure("*"); |
| 6271 | 6223 |
| 6272 scoped_ptr<HttpTransaction> trans( | 6224 scoped_ptr<HttpTransaction> trans( |
| 6273 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6225 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 6274 | 6226 |
| 6275 TestCompletionCallback callback; | 6227 TestCompletionCallback callback; |
| 6276 | 6228 |
| 6277 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6229 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6278 EXPECT_EQ(ERR_IO_PENDING, rv); | 6230 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6279 | 6231 |
| 6280 rv = callback.WaitForResult(); | 6232 rv = callback.WaitForResult(); |
| 6281 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, rv); | 6233 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, rv); |
| 6282 } | 6234 } |
| 6283 | 6235 |
| 6284 namespace { | 6236 namespace { |
| 6285 | 6237 |
| 6286 // Base test to make sure that when the load flags for a request specify to | 6238 // Base test to make sure that when the load flags for a request specify to |
| 6287 // bypass the cache, the DNS cache is not used. | 6239 // bypass the cache, the DNS cache is not used. |
| 6288 void BypassHostCacheOnRefreshHelper(int load_flags) { | 6240 void BypassHostCacheOnRefreshHelper(int load_flags) { |
| 6289 // Issue a request, asking to bypass the cache(s). | 6241 // Issue a request, asking to bypass the cache(s). |
| 6290 HttpRequestInfo request; | 6242 HttpRequestInfo request; |
| 6291 request.method = "GET"; | 6243 request.method = "GET"; |
| 6292 request.load_flags = load_flags; | 6244 request.load_flags = load_flags; |
| 6293 request.url = GURL("http://www.google.com/"); | 6245 request.url = GURL("http://www.google.com/"); |
| 6294 | 6246 |
| 6295 SessionDependencies session_deps; | 6247 SpdySessionDependencies session_deps; |
| 6296 | 6248 |
| 6297 // Select a host resolver that does caching. | 6249 // Select a host resolver that does caching. |
| 6298 session_deps.host_resolver.reset(new MockCachingHostResolver); | 6250 session_deps.host_resolver.reset(new MockCachingHostResolver); |
| 6299 | 6251 |
| 6300 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( | 6252 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( |
| 6301 CreateSession(&session_deps))); | 6253 CreateSession(&session_deps))); |
| 6302 | 6254 |
| 6303 // Warm up the host cache so it has an entry for "www.google.com". | 6255 // Warm up the host cache so it has an entry for "www.google.com". |
| 6304 AddressList addrlist; | 6256 AddressList addrlist; |
| 6305 TestCompletionCallback callback; | 6257 TestCompletionCallback callback; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 6319 | 6271 |
| 6320 // Inject a failure the next time that "www.google.com" is resolved. This way | 6272 // Inject a failure the next time that "www.google.com" is resolved. This way |
| 6321 // we can tell if the next lookup hit the cache, or the "network". | 6273 // we can tell if the next lookup hit the cache, or the "network". |
| 6322 // (cache --> success, "network" --> failure). | 6274 // (cache --> success, "network" --> failure). |
| 6323 session_deps.host_resolver->rules()->AddSimulatedFailure("www.google.com"); | 6275 session_deps.host_resolver->rules()->AddSimulatedFailure("www.google.com"); |
| 6324 | 6276 |
| 6325 // Connect up a mock socket which will fail with ERR_UNEXPECTED during the | 6277 // Connect up a mock socket which will fail with ERR_UNEXPECTED during the |
| 6326 // first read -- this won't be reached as the host resolution will fail first. | 6278 // first read -- this won't be reached as the host resolution will fail first. |
| 6327 MockRead data_reads[] = { MockRead(SYNCHRONOUS, ERR_UNEXPECTED) }; | 6279 MockRead data_reads[] = { MockRead(SYNCHRONOUS, ERR_UNEXPECTED) }; |
| 6328 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 6280 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 6329 session_deps.socket_factory.AddSocketDataProvider(&data); | 6281 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 6330 | 6282 |
| 6331 // Run the request. | 6283 // Run the request. |
| 6332 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6284 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6333 ASSERT_EQ(ERR_IO_PENDING, rv); | 6285 ASSERT_EQ(ERR_IO_PENDING, rv); |
| 6334 rv = callback.WaitForResult(); | 6286 rv = callback.WaitForResult(); |
| 6335 | 6287 |
| 6336 // If we bypassed the cache, we would have gotten a failure while resolving | 6288 // If we bypassed the cache, we would have gotten a failure while resolving |
| 6337 // "www.google.com". | 6289 // "www.google.com". |
| 6338 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv); | 6290 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv); |
| 6339 } | 6291 } |
| 6340 | 6292 |
| 6341 } // namespace | 6293 } // namespace |
| 6342 | 6294 |
| 6343 // There are multiple load flags that should trigger the host cache bypass. | 6295 // There are multiple load flags that should trigger the host cache bypass. |
| 6344 // Test each in isolation: | 6296 // Test each in isolation: |
| 6345 TEST_F(HttpNetworkTransactionSpdy2Test, BypassHostCacheOnRefresh1) { | 6297 TEST_F(HttpNetworkTransactionSpdy2Test, BypassHostCacheOnRefresh1) { |
| 6346 BypassHostCacheOnRefreshHelper(LOAD_BYPASS_CACHE); | 6298 BypassHostCacheOnRefreshHelper(LOAD_BYPASS_CACHE); |
| 6347 } | 6299 } |
| 6348 | 6300 |
| 6349 TEST_F(HttpNetworkTransactionSpdy2Test, BypassHostCacheOnRefresh2) { | 6301 TEST_F(HttpNetworkTransactionSpdy2Test, BypassHostCacheOnRefresh2) { |
| 6350 BypassHostCacheOnRefreshHelper(LOAD_VALIDATE_CACHE); | 6302 BypassHostCacheOnRefreshHelper(LOAD_VALIDATE_CACHE); |
| 6351 } | 6303 } |
| 6352 | 6304 |
| 6353 TEST_F(HttpNetworkTransactionSpdy2Test, BypassHostCacheOnRefresh3) { | 6305 TEST_F(HttpNetworkTransactionSpdy2Test, BypassHostCacheOnRefresh3) { |
| 6354 BypassHostCacheOnRefreshHelper(LOAD_DISABLE_CACHE); | 6306 BypassHostCacheOnRefreshHelper(LOAD_DISABLE_CACHE); |
| 6355 } | 6307 } |
| 6356 | 6308 |
| 6357 // Make sure we can handle an error when writing the request. | 6309 // Make sure we can handle an error when writing the request. |
| 6358 TEST_F(HttpNetworkTransactionSpdy2Test, RequestWriteError) { | 6310 TEST_F(HttpNetworkTransactionSpdy2Test, RequestWriteError) { |
| 6359 SessionDependencies session_deps; | 6311 SpdySessionDependencies session_deps; |
| 6360 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 6312 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 6361 | 6313 |
| 6362 HttpRequestInfo request; | 6314 HttpRequestInfo request; |
| 6363 request.method = "GET"; | 6315 request.method = "GET"; |
| 6364 request.url = GURL("http://www.foo.com/"); | 6316 request.url = GURL("http://www.foo.com/"); |
| 6365 request.load_flags = 0; | 6317 request.load_flags = 0; |
| 6366 | 6318 |
| 6367 MockWrite write_failure[] = { | 6319 MockWrite write_failure[] = { |
| 6368 MockWrite(ASYNC, ERR_CONNECTION_RESET), | 6320 MockWrite(ASYNC, ERR_CONNECTION_RESET), |
| 6369 }; | 6321 }; |
| 6370 StaticSocketDataProvider data(NULL, 0, | 6322 StaticSocketDataProvider data(NULL, 0, |
| 6371 write_failure, arraysize(write_failure)); | 6323 write_failure, arraysize(write_failure)); |
| 6372 session_deps.socket_factory.AddSocketDataProvider(&data); | 6324 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 6373 | 6325 |
| 6374 TestCompletionCallback callback; | 6326 TestCompletionCallback callback; |
| 6375 | 6327 |
| 6376 scoped_ptr<HttpTransaction> trans( | 6328 scoped_ptr<HttpTransaction> trans( |
| 6377 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6329 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 6378 | 6330 |
| 6379 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6331 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6380 EXPECT_EQ(ERR_IO_PENDING, rv); | 6332 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6381 | 6333 |
| 6382 rv = callback.WaitForResult(); | 6334 rv = callback.WaitForResult(); |
| 6383 EXPECT_EQ(ERR_CONNECTION_RESET, rv); | 6335 EXPECT_EQ(ERR_CONNECTION_RESET, rv); |
| 6384 } | 6336 } |
| 6385 | 6337 |
| 6386 // Check that a connection closed after the start of the headers finishes ok. | 6338 // Check that a connection closed after the start of the headers finishes ok. |
| 6387 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectionClosedAfterStartOfHeaders) { | 6339 TEST_F(HttpNetworkTransactionSpdy2Test, ConnectionClosedAfterStartOfHeaders) { |
| 6388 SessionDependencies session_deps; | 6340 SpdySessionDependencies session_deps; |
| 6389 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 6341 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 6390 | 6342 |
| 6391 HttpRequestInfo request; | 6343 HttpRequestInfo request; |
| 6392 request.method = "GET"; | 6344 request.method = "GET"; |
| 6393 request.url = GURL("http://www.foo.com/"); | 6345 request.url = GURL("http://www.foo.com/"); |
| 6394 request.load_flags = 0; | 6346 request.load_flags = 0; |
| 6395 | 6347 |
| 6396 MockRead data_reads[] = { | 6348 MockRead data_reads[] = { |
| 6397 MockRead("HTTP/1."), | 6349 MockRead("HTTP/1."), |
| 6398 MockRead(SYNCHRONOUS, OK), | 6350 MockRead(SYNCHRONOUS, OK), |
| 6399 }; | 6351 }; |
| 6400 | 6352 |
| 6401 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 6353 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 6402 session_deps.socket_factory.AddSocketDataProvider(&data); | 6354 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 6403 | 6355 |
| 6404 TestCompletionCallback callback; | 6356 TestCompletionCallback callback; |
| 6405 | 6357 |
| 6406 scoped_ptr<HttpTransaction> trans( | 6358 scoped_ptr<HttpTransaction> trans( |
| 6407 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6359 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 6408 | 6360 |
| 6409 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6361 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6410 EXPECT_EQ(ERR_IO_PENDING, rv); | 6362 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6411 | 6363 |
| 6412 rv = callback.WaitForResult(); | 6364 rv = callback.WaitForResult(); |
| 6413 EXPECT_EQ(OK, rv); | 6365 EXPECT_EQ(OK, rv); |
| 6414 | 6366 |
| 6415 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6367 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6416 ASSERT_TRUE(response != NULL); | 6368 ASSERT_TRUE(response != NULL); |
| 6417 | 6369 |
| 6418 EXPECT_TRUE(response->headers != NULL); | 6370 EXPECT_TRUE(response->headers != NULL); |
| 6419 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 6371 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
| 6420 | 6372 |
| 6421 std::string response_data; | 6373 std::string response_data; |
| 6422 rv = ReadTransaction(trans.get(), &response_data); | 6374 rv = ReadTransaction(trans.get(), &response_data); |
| 6423 EXPECT_EQ(OK, rv); | 6375 EXPECT_EQ(OK, rv); |
| 6424 EXPECT_EQ("", response_data); | 6376 EXPECT_EQ("", response_data); |
| 6425 } | 6377 } |
| 6426 | 6378 |
| 6427 // Make sure that a dropped connection while draining the body for auth | 6379 // Make sure that a dropped connection while draining the body for auth |
| 6428 // restart does the right thing. | 6380 // restart does the right thing. |
| 6429 TEST_F(HttpNetworkTransactionSpdy2Test, DrainResetOK) { | 6381 TEST_F(HttpNetworkTransactionSpdy2Test, DrainResetOK) { |
| 6430 SessionDependencies session_deps; | 6382 SpdySessionDependencies session_deps; |
| 6431 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 6383 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 6432 | 6384 |
| 6433 HttpRequestInfo request; | 6385 HttpRequestInfo request; |
| 6434 request.method = "GET"; | 6386 request.method = "GET"; |
| 6435 request.url = GURL("http://www.google.com/"); | 6387 request.url = GURL("http://www.google.com/"); |
| 6436 request.load_flags = 0; | 6388 request.load_flags = 0; |
| 6437 | 6389 |
| 6438 MockWrite data_writes1[] = { | 6390 MockWrite data_writes1[] = { |
| 6439 MockWrite("GET / HTTP/1.1\r\n" | 6391 MockWrite("GET / HTTP/1.1\r\n" |
| 6440 "Host: www.google.com\r\n" | 6392 "Host: www.google.com\r\n" |
| 6441 "Connection: keep-alive\r\n\r\n"), | 6393 "Connection: keep-alive\r\n\r\n"), |
| 6442 }; | 6394 }; |
| 6443 | 6395 |
| 6444 MockRead data_reads1[] = { | 6396 MockRead data_reads1[] = { |
| 6445 MockRead("HTTP/1.1 401 Unauthorized\r\n"), | 6397 MockRead("HTTP/1.1 401 Unauthorized\r\n"), |
| 6446 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 6398 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 6447 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 6399 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 6448 MockRead("Content-Length: 14\r\n\r\n"), | 6400 MockRead("Content-Length: 14\r\n\r\n"), |
| 6449 MockRead("Unauth"), | 6401 MockRead("Unauth"), |
| 6450 MockRead(ASYNC, ERR_CONNECTION_RESET), | 6402 MockRead(ASYNC, ERR_CONNECTION_RESET), |
| 6451 }; | 6403 }; |
| 6452 | 6404 |
| 6453 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 6405 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 6454 data_writes1, arraysize(data_writes1)); | 6406 data_writes1, arraysize(data_writes1)); |
| 6455 session_deps.socket_factory.AddSocketDataProvider(&data1); | 6407 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 6456 | 6408 |
| 6457 // After calling trans->RestartWithAuth(), this is the request we should | 6409 // After calling trans->RestartWithAuth(), this is the request we should |
| 6458 // be issuing -- the final header line contains the credentials. | 6410 // be issuing -- the final header line contains the credentials. |
| 6459 MockWrite data_writes2[] = { | 6411 MockWrite data_writes2[] = { |
| 6460 MockWrite("GET / HTTP/1.1\r\n" | 6412 MockWrite("GET / HTTP/1.1\r\n" |
| 6461 "Host: www.google.com\r\n" | 6413 "Host: www.google.com\r\n" |
| 6462 "Connection: keep-alive\r\n" | 6414 "Connection: keep-alive\r\n" |
| 6463 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), | 6415 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), |
| 6464 }; | 6416 }; |
| 6465 | 6417 |
| 6466 // Lastly, the server responds with the actual content. | 6418 // Lastly, the server responds with the actual content. |
| 6467 MockRead data_reads2[] = { | 6419 MockRead data_reads2[] = { |
| 6468 MockRead("HTTP/1.1 200 OK\r\n"), | 6420 MockRead("HTTP/1.1 200 OK\r\n"), |
| 6469 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 6421 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 6470 MockRead("Content-Length: 100\r\n\r\n"), | 6422 MockRead("Content-Length: 100\r\n\r\n"), |
| 6471 MockRead(SYNCHRONOUS, OK), | 6423 MockRead(SYNCHRONOUS, OK), |
| 6472 }; | 6424 }; |
| 6473 | 6425 |
| 6474 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 6426 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 6475 data_writes2, arraysize(data_writes2)); | 6427 data_writes2, arraysize(data_writes2)); |
| 6476 session_deps.socket_factory.AddSocketDataProvider(&data2); | 6428 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 6477 | 6429 |
| 6478 TestCompletionCallback callback1; | 6430 TestCompletionCallback callback1; |
| 6479 | 6431 |
| 6480 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 6432 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 6481 | 6433 |
| 6482 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 6434 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 6483 EXPECT_EQ(ERR_IO_PENDING, rv); | 6435 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6484 | 6436 |
| 6485 rv = callback1.WaitForResult(); | 6437 rv = callback1.WaitForResult(); |
| 6486 EXPECT_EQ(OK, rv); | 6438 EXPECT_EQ(OK, rv); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 6499 EXPECT_EQ(OK, rv); | 6451 EXPECT_EQ(OK, rv); |
| 6500 | 6452 |
| 6501 response = trans->GetResponseInfo(); | 6453 response = trans->GetResponseInfo(); |
| 6502 ASSERT_TRUE(response != NULL); | 6454 ASSERT_TRUE(response != NULL); |
| 6503 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6455 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 6504 EXPECT_EQ(100, response->headers->GetContentLength()); | 6456 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 6505 } | 6457 } |
| 6506 | 6458 |
| 6507 // Test HTTPS connections going through a proxy that sends extra data. | 6459 // Test HTTPS connections going through a proxy that sends extra data. |
| 6508 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSViaProxyWithExtraData) { | 6460 TEST_F(HttpNetworkTransactionSpdy2Test, HTTPSViaProxyWithExtraData) { |
| 6509 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 6461 SpdySessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 6510 | 6462 |
| 6511 HttpRequestInfo request; | 6463 HttpRequestInfo request; |
| 6512 request.method = "GET"; | 6464 request.method = "GET"; |
| 6513 request.url = GURL("https://www.google.com/"); | 6465 request.url = GURL("https://www.google.com/"); |
| 6514 request.load_flags = 0; | 6466 request.load_flags = 0; |
| 6515 | 6467 |
| 6516 MockRead proxy_reads[] = { | 6468 MockRead proxy_reads[] = { |
| 6517 MockRead("HTTP/1.0 200 Connected\r\n\r\nExtra data"), | 6469 MockRead("HTTP/1.0 200 Connected\r\n\r\nExtra data"), |
| 6518 MockRead(SYNCHRONOUS, OK) | 6470 MockRead(SYNCHRONOUS, OK) |
| 6519 }; | 6471 }; |
| 6520 | 6472 |
| 6521 StaticSocketDataProvider data(proxy_reads, arraysize(proxy_reads), NULL, 0); | 6473 StaticSocketDataProvider data(proxy_reads, arraysize(proxy_reads), NULL, 0); |
| 6522 SSLSocketDataProvider ssl(ASYNC, OK); | 6474 SSLSocketDataProvider ssl(ASYNC, OK); |
| 6523 | 6475 |
| 6524 session_deps.socket_factory.AddSocketDataProvider(&data); | 6476 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 6525 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 6477 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 6526 | 6478 |
| 6527 TestCompletionCallback callback; | 6479 TestCompletionCallback callback; |
| 6528 | 6480 |
| 6529 session_deps.socket_factory.ResetNextMockIndexes(); | 6481 session_deps.socket_factory->ResetNextMockIndexes(); |
| 6530 | 6482 |
| 6531 scoped_ptr<HttpTransaction> trans( | 6483 scoped_ptr<HttpTransaction> trans( |
| 6532 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6484 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 6533 | 6485 |
| 6534 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6486 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6535 EXPECT_EQ(ERR_IO_PENDING, rv); | 6487 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6536 | 6488 |
| 6537 rv = callback.WaitForResult(); | 6489 rv = callback.WaitForResult(); |
| 6538 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); | 6490 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); |
| 6539 } | 6491 } |
| 6540 | 6492 |
| 6541 TEST_F(HttpNetworkTransactionSpdy2Test, LargeContentLengthThenClose) { | 6493 TEST_F(HttpNetworkTransactionSpdy2Test, LargeContentLengthThenClose) { |
| 6542 HttpRequestInfo request; | 6494 HttpRequestInfo request; |
| 6543 request.method = "GET"; | 6495 request.method = "GET"; |
| 6544 request.url = GURL("http://www.google.com/"); | 6496 request.url = GURL("http://www.google.com/"); |
| 6545 request.load_flags = 0; | 6497 request.load_flags = 0; |
| 6546 | 6498 |
| 6547 SessionDependencies session_deps; | 6499 SpdySessionDependencies session_deps; |
| 6548 scoped_ptr<HttpTransaction> trans( | 6500 scoped_ptr<HttpTransaction> trans( |
| 6549 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6501 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 6550 | 6502 |
| 6551 MockRead data_reads[] = { | 6503 MockRead data_reads[] = { |
| 6552 MockRead("HTTP/1.0 200 OK\r\nContent-Length:6719476739\r\n\r\n"), | 6504 MockRead("HTTP/1.0 200 OK\r\nContent-Length:6719476739\r\n\r\n"), |
| 6553 MockRead(SYNCHRONOUS, OK), | 6505 MockRead(SYNCHRONOUS, OK), |
| 6554 }; | 6506 }; |
| 6555 | 6507 |
| 6556 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 6508 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 6557 session_deps.socket_factory.AddSocketDataProvider(&data); | 6509 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 6558 | 6510 |
| 6559 TestCompletionCallback callback; | 6511 TestCompletionCallback callback; |
| 6560 | 6512 |
| 6561 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6513 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6562 EXPECT_EQ(ERR_IO_PENDING, rv); | 6514 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6563 | 6515 |
| 6564 EXPECT_EQ(OK, callback.WaitForResult()); | 6516 EXPECT_EQ(OK, callback.WaitForResult()); |
| 6565 | 6517 |
| 6566 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6518 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 6567 ASSERT_TRUE(response != NULL); | 6519 ASSERT_TRUE(response != NULL); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6584 scoped_refptr<UploadData> upload_data(new UploadData()); | 6536 scoped_refptr<UploadData> upload_data(new UploadData()); |
| 6585 upload_data->AppendFileRange(temp_file_path, 0, kuint64max, base::Time()); | 6537 upload_data->AppendFileRange(temp_file_path, 0, kuint64max, base::Time()); |
| 6586 UploadDataStream upload_data_stream(upload_data); | 6538 UploadDataStream upload_data_stream(upload_data); |
| 6587 | 6539 |
| 6588 HttpRequestInfo request; | 6540 HttpRequestInfo request; |
| 6589 request.method = "POST"; | 6541 request.method = "POST"; |
| 6590 request.url = GURL("http://www.google.com/upload"); | 6542 request.url = GURL("http://www.google.com/upload"); |
| 6591 request.upload_data_stream = &upload_data_stream; | 6543 request.upload_data_stream = &upload_data_stream; |
| 6592 request.load_flags = 0; | 6544 request.load_flags = 0; |
| 6593 | 6545 |
| 6594 SessionDependencies session_deps; | 6546 SpdySessionDependencies session_deps; |
| 6595 scoped_ptr<HttpTransaction> trans( | 6547 scoped_ptr<HttpTransaction> trans( |
| 6596 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6548 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 6597 | 6549 |
| 6598 MockRead data_reads[] = { | 6550 MockRead data_reads[] = { |
| 6599 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | 6551 MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
| 6600 MockRead("hello world"), | 6552 MockRead("hello world"), |
| 6601 MockRead(SYNCHRONOUS, OK), | 6553 MockRead(SYNCHRONOUS, OK), |
| 6602 }; | 6554 }; |
| 6603 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 6555 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 6604 session_deps.socket_factory.AddSocketDataProvider(&data); | 6556 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 6605 | 6557 |
| 6606 TestCompletionCallback callback; | 6558 TestCompletionCallback callback; |
| 6607 | 6559 |
| 6608 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6560 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6609 EXPECT_EQ(ERR_IO_PENDING, rv); | 6561 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6610 | 6562 |
| 6611 rv = callback.WaitForResult(); | 6563 rv = callback.WaitForResult(); |
| 6612 EXPECT_EQ(OK, rv); | 6564 EXPECT_EQ(OK, rv); |
| 6613 | 6565 |
| 6614 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6566 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 6638 UploadDataStream upload_data_stream(upload_data); | 6590 UploadDataStream upload_data_stream(upload_data); |
| 6639 | 6591 |
| 6640 HttpRequestInfo request; | 6592 HttpRequestInfo request; |
| 6641 request.method = "POST"; | 6593 request.method = "POST"; |
| 6642 request.url = GURL("http://www.google.com/upload"); | 6594 request.url = GURL("http://www.google.com/upload"); |
| 6643 request.upload_data_stream = &upload_data_stream; | 6595 request.upload_data_stream = &upload_data_stream; |
| 6644 request.load_flags = 0; | 6596 request.load_flags = 0; |
| 6645 | 6597 |
| 6646 // If we try to upload an unreadable file, the network stack should report | 6598 // If we try to upload an unreadable file, the network stack should report |
| 6647 // the file size as zero and upload zero bytes for that file. | 6599 // the file size as zero and upload zero bytes for that file. |
| 6648 SessionDependencies session_deps; | 6600 SpdySessionDependencies session_deps; |
| 6649 scoped_ptr<HttpTransaction> trans( | 6601 scoped_ptr<HttpTransaction> trans( |
| 6650 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6602 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 6651 | 6603 |
| 6652 MockRead data_reads[] = { | 6604 MockRead data_reads[] = { |
| 6653 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | 6605 MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
| 6654 MockRead(SYNCHRONOUS, OK), | 6606 MockRead(SYNCHRONOUS, OK), |
| 6655 }; | 6607 }; |
| 6656 MockWrite data_writes[] = { | 6608 MockWrite data_writes[] = { |
| 6657 MockWrite("POST /upload HTTP/1.1\r\n" | 6609 MockWrite("POST /upload HTTP/1.1\r\n" |
| 6658 "Host: www.google.com\r\n" | 6610 "Host: www.google.com\r\n" |
| 6659 "Connection: keep-alive\r\n" | 6611 "Connection: keep-alive\r\n" |
| 6660 "Content-Length: 0\r\n\r\n"), | 6612 "Content-Length: 0\r\n\r\n"), |
| 6661 MockWrite(SYNCHRONOUS, OK), | 6613 MockWrite(SYNCHRONOUS, OK), |
| 6662 }; | 6614 }; |
| 6663 StaticSocketDataProvider data(data_reads, arraysize(data_reads), data_writes, | 6615 StaticSocketDataProvider data(data_reads, arraysize(data_reads), data_writes, |
| 6664 arraysize(data_writes)); | 6616 arraysize(data_writes)); |
| 6665 session_deps.socket_factory.AddSocketDataProvider(&data); | 6617 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 6666 | 6618 |
| 6667 TestCompletionCallback callback; | 6619 TestCompletionCallback callback; |
| 6668 | 6620 |
| 6669 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6621 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6670 EXPECT_EQ(ERR_IO_PENDING, rv); | 6622 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6671 | 6623 |
| 6672 rv = callback.WaitForResult(); | 6624 rv = callback.WaitForResult(); |
| 6673 EXPECT_EQ(OK, rv); | 6625 EXPECT_EQ(OK, rv); |
| 6674 | 6626 |
| 6675 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6627 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6691 scoped_refptr<UploadData> upload_data(new UploadData()); | 6643 scoped_refptr<UploadData> upload_data(new UploadData()); |
| 6692 upload_data->AppendFileRange(temp_file, 0, kuint64max, base::Time()); | 6644 upload_data->AppendFileRange(temp_file, 0, kuint64max, base::Time()); |
| 6693 UploadDataStream upload_data_stream(upload_data); | 6645 UploadDataStream upload_data_stream(upload_data); |
| 6694 | 6646 |
| 6695 HttpRequestInfo request; | 6647 HttpRequestInfo request; |
| 6696 request.method = "POST"; | 6648 request.method = "POST"; |
| 6697 request.url = GURL("http://www.google.com/upload"); | 6649 request.url = GURL("http://www.google.com/upload"); |
| 6698 request.upload_data_stream = &upload_data_stream; | 6650 request.upload_data_stream = &upload_data_stream; |
| 6699 request.load_flags = 0; | 6651 request.load_flags = 0; |
| 6700 | 6652 |
| 6701 SessionDependencies session_deps; | 6653 SpdySessionDependencies session_deps; |
| 6702 scoped_ptr<HttpTransaction> trans( | 6654 scoped_ptr<HttpTransaction> trans( |
| 6703 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6655 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 6704 | 6656 |
| 6705 MockRead data_reads[] = { | 6657 MockRead data_reads[] = { |
| 6706 MockRead("HTTP/1.1 401 Unauthorized\r\n"), | 6658 MockRead("HTTP/1.1 401 Unauthorized\r\n"), |
| 6707 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), | 6659 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), |
| 6708 MockRead("Content-Length: 0\r\n\r\n"), // No response body. | 6660 MockRead("Content-Length: 0\r\n\r\n"), // No response body. |
| 6709 | 6661 |
| 6710 MockRead("HTTP/1.1 200 OK\r\n"), | 6662 MockRead("HTTP/1.1 200 OK\r\n"), |
| 6711 MockRead("Content-Length: 0\r\n\r\n"), | 6663 MockRead("Content-Length: 0\r\n\r\n"), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6722 "Host: www.google.com\r\n" | 6674 "Host: www.google.com\r\n" |
| 6723 "Connection: keep-alive\r\n" | 6675 "Connection: keep-alive\r\n" |
| 6724 "Content-Length: 0\r\n" | 6676 "Content-Length: 0\r\n" |
| 6725 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), | 6677 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), |
| 6726 MockWrite(SYNCHRONOUS, unreadable_contents.c_str(), | 6678 MockWrite(SYNCHRONOUS, unreadable_contents.c_str(), |
| 6727 temp_file_contents.length()), | 6679 temp_file_contents.length()), |
| 6728 MockWrite(SYNCHRONOUS, OK), | 6680 MockWrite(SYNCHRONOUS, OK), |
| 6729 }; | 6681 }; |
| 6730 StaticSocketDataProvider data(data_reads, arraysize(data_reads), data_writes, | 6682 StaticSocketDataProvider data(data_reads, arraysize(data_reads), data_writes, |
| 6731 arraysize(data_writes)); | 6683 arraysize(data_writes)); |
| 6732 session_deps.socket_factory.AddSocketDataProvider(&data); | 6684 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 6733 | 6685 |
| 6734 TestCompletionCallback callback1; | 6686 TestCompletionCallback callback1; |
| 6735 | 6687 |
| 6736 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 6688 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| 6737 EXPECT_EQ(ERR_IO_PENDING, rv); | 6689 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6738 | 6690 |
| 6739 rv = callback1.WaitForResult(); | 6691 rv = callback1.WaitForResult(); |
| 6740 EXPECT_EQ(OK, rv); | 6692 EXPECT_EQ(OK, rv); |
| 6741 | 6693 |
| 6742 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6694 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6761 ASSERT_TRUE(response != NULL); | 6713 ASSERT_TRUE(response != NULL); |
| 6762 EXPECT_TRUE(response->headers != NULL); | 6714 EXPECT_TRUE(response->headers != NULL); |
| 6763 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6715 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 6764 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6716 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 6765 | 6717 |
| 6766 file_util::Delete(temp_file, false); | 6718 file_util::Delete(temp_file, false); |
| 6767 } | 6719 } |
| 6768 | 6720 |
| 6769 // Tests that changes to Auth realms are treated like auth rejections. | 6721 // Tests that changes to Auth realms are treated like auth rejections. |
| 6770 TEST_F(HttpNetworkTransactionSpdy2Test, ChangeAuthRealms) { | 6722 TEST_F(HttpNetworkTransactionSpdy2Test, ChangeAuthRealms) { |
| 6771 SessionDependencies session_deps; | 6723 SpdySessionDependencies session_deps; |
| 6772 | 6724 |
| 6773 HttpRequestInfo request; | 6725 HttpRequestInfo request; |
| 6774 request.method = "GET"; | 6726 request.method = "GET"; |
| 6775 request.url = GURL("http://www.google.com/"); | 6727 request.url = GURL("http://www.google.com/"); |
| 6776 request.load_flags = 0; | 6728 request.load_flags = 0; |
| 6777 | 6729 |
| 6778 // First transaction will request a resource and receive a Basic challenge | 6730 // First transaction will request a resource and receive a Basic challenge |
| 6779 // with realm="first_realm". | 6731 // with realm="first_realm". |
| 6780 MockWrite data_writes1[] = { | 6732 MockWrite data_writes1[] = { |
| 6781 MockWrite("GET / HTTP/1.1\r\n" | 6733 MockWrite("GET / HTTP/1.1\r\n" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6837 }; | 6789 }; |
| 6838 | 6790 |
| 6839 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 6791 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 6840 data_writes1, arraysize(data_writes1)); | 6792 data_writes1, arraysize(data_writes1)); |
| 6841 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), | 6793 StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| 6842 data_writes2, arraysize(data_writes2)); | 6794 data_writes2, arraysize(data_writes2)); |
| 6843 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), | 6795 StaticSocketDataProvider data3(data_reads3, arraysize(data_reads3), |
| 6844 data_writes3, arraysize(data_writes3)); | 6796 data_writes3, arraysize(data_writes3)); |
| 6845 StaticSocketDataProvider data4(data_reads4, arraysize(data_reads4), | 6797 StaticSocketDataProvider data4(data_reads4, arraysize(data_reads4), |
| 6846 data_writes4, arraysize(data_writes4)); | 6798 data_writes4, arraysize(data_writes4)); |
| 6847 session_deps.socket_factory.AddSocketDataProvider(&data1); | 6799 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 6848 session_deps.socket_factory.AddSocketDataProvider(&data2); | 6800 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 6849 session_deps.socket_factory.AddSocketDataProvider(&data3); | 6801 session_deps.socket_factory->AddSocketDataProvider(&data3); |
| 6850 session_deps.socket_factory.AddSocketDataProvider(&data4); | 6802 session_deps.socket_factory->AddSocketDataProvider(&data4); |
| 6851 | 6803 |
| 6852 TestCompletionCallback callback1; | 6804 TestCompletionCallback callback1; |
| 6853 | 6805 |
| 6854 scoped_ptr<HttpTransaction> trans( | 6806 scoped_ptr<HttpTransaction> trans( |
| 6855 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6807 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 6856 | 6808 |
| 6857 // Issue the first request with Authorize headers. There should be a | 6809 // Issue the first request with Authorize headers. There should be a |
| 6858 // password prompt for first_realm waiting to be filled in after the | 6810 // password prompt for first_realm waiting to be filled in after the |
| 6859 // transaction completes. | 6811 // transaction completes. |
| 6860 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); | 6812 int rv = trans->Start(&request, callback1.callback(), BoundNetLog()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6916 EXPECT_EQ(OK, rv); | 6868 EXPECT_EQ(OK, rv); |
| 6917 response = trans->GetResponseInfo(); | 6869 response = trans->GetResponseInfo(); |
| 6918 ASSERT_TRUE(response != NULL); | 6870 ASSERT_TRUE(response != NULL); |
| 6919 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6871 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 6920 } | 6872 } |
| 6921 | 6873 |
| 6922 TEST_F(HttpNetworkTransactionSpdy2Test, HonorAlternateProtocolHeader) { | 6874 TEST_F(HttpNetworkTransactionSpdy2Test, HonorAlternateProtocolHeader) { |
| 6923 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 6875 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
| 6924 HttpStreamFactory::set_use_alternate_protocols(true); | 6876 HttpStreamFactory::set_use_alternate_protocols(true); |
| 6925 | 6877 |
| 6926 SessionDependencies session_deps; | 6878 SpdySessionDependencies session_deps; |
| 6927 | 6879 |
| 6928 MockRead data_reads[] = { | 6880 MockRead data_reads[] = { |
| 6929 MockRead("HTTP/1.1 200 OK\r\n"), | 6881 MockRead("HTTP/1.1 200 OK\r\n"), |
| 6930 MockRead(kAlternateProtocolHttpHeader), | 6882 MockRead(kAlternateProtocolHttpHeader), |
| 6931 MockRead("hello world"), | 6883 MockRead("hello world"), |
| 6932 MockRead(SYNCHRONOUS, OK), | 6884 MockRead(SYNCHRONOUS, OK), |
| 6933 }; | 6885 }; |
| 6934 | 6886 |
| 6935 HttpRequestInfo request; | 6887 HttpRequestInfo request; |
| 6936 request.method = "GET"; | 6888 request.method = "GET"; |
| 6937 request.url = GURL("http://www.google.com/"); | 6889 request.url = GURL("http://www.google.com/"); |
| 6938 request.load_flags = 0; | 6890 request.load_flags = 0; |
| 6939 | 6891 |
| 6940 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 6892 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 6941 | 6893 |
| 6942 session_deps.socket_factory.AddSocketDataProvider(&data); | 6894 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 6943 | 6895 |
| 6944 TestCompletionCallback callback; | 6896 TestCompletionCallback callback; |
| 6945 | 6897 |
| 6946 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 6898 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 6947 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 6899 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 6948 | 6900 |
| 6949 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 6901 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 6950 EXPECT_EQ(ERR_IO_PENDING, rv); | 6902 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6951 | 6903 |
| 6952 HostPortPair http_host_port_pair("www.google.com", 80); | 6904 HostPortPair http_host_port_pair("www.google.com", 80); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 6976 expected_alternate.protocol = NPN_SPDY_2; | 6928 expected_alternate.protocol = NPN_SPDY_2; |
| 6977 EXPECT_TRUE(expected_alternate.Equals(alternate)); | 6929 EXPECT_TRUE(expected_alternate.Equals(alternate)); |
| 6978 | 6930 |
| 6979 HttpStreamFactory::set_use_alternate_protocols(false); | 6931 HttpStreamFactory::set_use_alternate_protocols(false); |
| 6980 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); | 6932 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
| 6981 } | 6933 } |
| 6982 | 6934 |
| 6983 TEST_F(HttpNetworkTransactionSpdy2Test, | 6935 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 6984 MarkBrokenAlternateProtocolAndFallback) { | 6936 MarkBrokenAlternateProtocolAndFallback) { |
| 6985 HttpStreamFactory::set_use_alternate_protocols(true); | 6937 HttpStreamFactory::set_use_alternate_protocols(true); |
| 6986 SessionDependencies session_deps; | 6938 SpdySessionDependencies session_deps; |
| 6987 | 6939 |
| 6988 HttpRequestInfo request; | 6940 HttpRequestInfo request; |
| 6989 request.method = "GET"; | 6941 request.method = "GET"; |
| 6990 request.url = GURL("http://www.google.com/"); | 6942 request.url = GURL("http://www.google.com/"); |
| 6991 request.load_flags = 0; | 6943 request.load_flags = 0; |
| 6992 | 6944 |
| 6993 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 6945 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 6994 StaticSocketDataProvider first_data; | 6946 StaticSocketDataProvider first_data; |
| 6995 first_data.set_connect_data(mock_connect); | 6947 first_data.set_connect_data(mock_connect); |
| 6996 session_deps.socket_factory.AddSocketDataProvider(&first_data); | 6948 session_deps.socket_factory->AddSocketDataProvider(&first_data); |
| 6997 | 6949 |
| 6998 MockRead data_reads[] = { | 6950 MockRead data_reads[] = { |
| 6999 MockRead("HTTP/1.1 200 OK\r\n\r\n"), | 6951 MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
| 7000 MockRead("hello world"), | 6952 MockRead("hello world"), |
| 7001 MockRead(ASYNC, OK), | 6953 MockRead(ASYNC, OK), |
| 7002 }; | 6954 }; |
| 7003 StaticSocketDataProvider second_data( | 6955 StaticSocketDataProvider second_data( |
| 7004 data_reads, arraysize(data_reads), NULL, 0); | 6956 data_reads, arraysize(data_reads), NULL, 0); |
| 7005 session_deps.socket_factory.AddSocketDataProvider(&second_data); | 6957 session_deps.socket_factory->AddSocketDataProvider(&second_data); |
| 7006 | 6958 |
| 7007 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 6959 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 7008 | 6960 |
| 7009 HttpServerProperties* http_server_properties = | 6961 HttpServerProperties* http_server_properties = |
| 7010 session->http_server_properties(); | 6962 session->http_server_properties(); |
| 7011 // Port must be < 1024, or the header will be ignored (since initial port was | 6963 // Port must be < 1024, or the header will be ignored (since initial port was |
| 7012 // port 80 (another restricted port). | 6964 // port 80 (another restricted port). |
| 7013 http_server_properties->SetAlternateProtocol( | 6965 http_server_properties->SetAlternateProtocol( |
| 7014 HostPortPair::FromURL(request.url), | 6966 HostPortPair::FromURL(request.url), |
| 7015 666 /* port is ignored by MockConnect anyway */, | 6967 666 /* port is ignored by MockConnect anyway */, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 7040 HttpStreamFactory::set_use_alternate_protocols(false); | 6992 HttpStreamFactory::set_use_alternate_protocols(false); |
| 7041 } | 6993 } |
| 7042 | 6994 |
| 7043 TEST_F(HttpNetworkTransactionSpdy2Test, | 6995 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 7044 AlternateProtocolPortRestrictedBlocked) { | 6996 AlternateProtocolPortRestrictedBlocked) { |
| 7045 // Ensure that we're not allowed to redirect traffic via an alternate | 6997 // Ensure that we're not allowed to redirect traffic via an alternate |
| 7046 // protocol to an unrestricted (port >= 1024) when the original traffic was | 6998 // protocol to an unrestricted (port >= 1024) when the original traffic was |
| 7047 // on a restricted port (port < 1024). Ensure that we can redirect in all | 6999 // on a restricted port (port < 1024). Ensure that we can redirect in all |
| 7048 // other cases. | 7000 // other cases. |
| 7049 HttpStreamFactory::set_use_alternate_protocols(true); | 7001 HttpStreamFactory::set_use_alternate_protocols(true); |
| 7050 SessionDependencies session_deps; | 7002 SpdySessionDependencies session_deps; |
| 7051 | 7003 |
| 7052 HttpRequestInfo restricted_port_request; | 7004 HttpRequestInfo restricted_port_request; |
| 7053 restricted_port_request.method = "GET"; | 7005 restricted_port_request.method = "GET"; |
| 7054 restricted_port_request.url = GURL("http://www.google.com:1023/"); | 7006 restricted_port_request.url = GURL("http://www.google.com:1023/"); |
| 7055 restricted_port_request.load_flags = 0; | 7007 restricted_port_request.load_flags = 0; |
| 7056 | 7008 |
| 7057 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 7009 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 7058 StaticSocketDataProvider first_data; | 7010 StaticSocketDataProvider first_data; |
| 7059 first_data.set_connect_data(mock_connect); | 7011 first_data.set_connect_data(mock_connect); |
| 7060 session_deps.socket_factory.AddSocketDataProvider(&first_data); | 7012 session_deps.socket_factory->AddSocketDataProvider(&first_data); |
| 7061 | 7013 |
| 7062 MockRead data_reads[] = { | 7014 MockRead data_reads[] = { |
| 7063 MockRead("HTTP/1.1 200 OK\r\n\r\n"), | 7015 MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
| 7064 MockRead("hello world"), | 7016 MockRead("hello world"), |
| 7065 MockRead(ASYNC, OK), | 7017 MockRead(ASYNC, OK), |
| 7066 }; | 7018 }; |
| 7067 StaticSocketDataProvider second_data( | 7019 StaticSocketDataProvider second_data( |
| 7068 data_reads, arraysize(data_reads), NULL, 0); | 7020 data_reads, arraysize(data_reads), NULL, 0); |
| 7069 session_deps.socket_factory.AddSocketDataProvider(&second_data); | 7021 session_deps.socket_factory->AddSocketDataProvider(&second_data); |
| 7070 | 7022 |
| 7071 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7023 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 7072 | 7024 |
| 7073 HttpServerProperties* http_server_properties = | 7025 HttpServerProperties* http_server_properties = |
| 7074 session->http_server_properties(); | 7026 session->http_server_properties(); |
| 7075 const int kUnrestrictedAlternatePort = 1024; | 7027 const int kUnrestrictedAlternatePort = 1024; |
| 7076 http_server_properties->SetAlternateProtocol( | 7028 http_server_properties->SetAlternateProtocol( |
| 7077 HostPortPair::FromURL(restricted_port_request.url), | 7029 HostPortPair::FromURL(restricted_port_request.url), |
| 7078 kUnrestrictedAlternatePort, | 7030 kUnrestrictedAlternatePort, |
| 7079 NPN_SPDY_2); | 7031 NPN_SPDY_2); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 7090 HttpStreamFactory::set_use_alternate_protocols(false); | 7042 HttpStreamFactory::set_use_alternate_protocols(false); |
| 7091 } | 7043 } |
| 7092 | 7044 |
| 7093 TEST_F(HttpNetworkTransactionSpdy2Test, | 7045 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 7094 AlternateProtocolPortRestrictedAllowed) { | 7046 AlternateProtocolPortRestrictedAllowed) { |
| 7095 // Ensure that we're not allowed to redirect traffic via an alternate | 7047 // Ensure that we're not allowed to redirect traffic via an alternate |
| 7096 // protocol to an unrestricted (port >= 1024) when the original traffic was | 7048 // protocol to an unrestricted (port >= 1024) when the original traffic was |
| 7097 // on a restricted port (port < 1024). Ensure that we can redirect in all | 7049 // on a restricted port (port < 1024). Ensure that we can redirect in all |
| 7098 // other cases. | 7050 // other cases. |
| 7099 HttpStreamFactory::set_use_alternate_protocols(true); | 7051 HttpStreamFactory::set_use_alternate_protocols(true); |
| 7100 SessionDependencies session_deps; | 7052 SpdySessionDependencies session_deps; |
| 7101 | 7053 |
| 7102 HttpRequestInfo restricted_port_request; | 7054 HttpRequestInfo restricted_port_request; |
| 7103 restricted_port_request.method = "GET"; | 7055 restricted_port_request.method = "GET"; |
| 7104 restricted_port_request.url = GURL("http://www.google.com:1023/"); | 7056 restricted_port_request.url = GURL("http://www.google.com:1023/"); |
| 7105 restricted_port_request.load_flags = 0; | 7057 restricted_port_request.load_flags = 0; |
| 7106 | 7058 |
| 7107 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 7059 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 7108 StaticSocketDataProvider first_data; | 7060 StaticSocketDataProvider first_data; |
| 7109 first_data.set_connect_data(mock_connect); | 7061 first_data.set_connect_data(mock_connect); |
| 7110 session_deps.socket_factory.AddSocketDataProvider(&first_data); | 7062 session_deps.socket_factory->AddSocketDataProvider(&first_data); |
| 7111 | 7063 |
| 7112 MockRead data_reads[] = { | 7064 MockRead data_reads[] = { |
| 7113 MockRead("HTTP/1.1 200 OK\r\n\r\n"), | 7065 MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
| 7114 MockRead("hello world"), | 7066 MockRead("hello world"), |
| 7115 MockRead(ASYNC, OK), | 7067 MockRead(ASYNC, OK), |
| 7116 }; | 7068 }; |
| 7117 StaticSocketDataProvider second_data( | 7069 StaticSocketDataProvider second_data( |
| 7118 data_reads, arraysize(data_reads), NULL, 0); | 7070 data_reads, arraysize(data_reads), NULL, 0); |
| 7119 session_deps.socket_factory.AddSocketDataProvider(&second_data); | 7071 session_deps.socket_factory->AddSocketDataProvider(&second_data); |
| 7120 | 7072 |
| 7121 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7073 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 7122 | 7074 |
| 7123 HttpServerProperties* http_server_properties = | 7075 HttpServerProperties* http_server_properties = |
| 7124 session->http_server_properties(); | 7076 session->http_server_properties(); |
| 7125 const int kRestrictedAlternatePort = 80; | 7077 const int kRestrictedAlternatePort = 80; |
| 7126 http_server_properties->SetAlternateProtocol( | 7078 http_server_properties->SetAlternateProtocol( |
| 7127 HostPortPair::FromURL(restricted_port_request.url), | 7079 HostPortPair::FromURL(restricted_port_request.url), |
| 7128 kRestrictedAlternatePort, | 7080 kRestrictedAlternatePort, |
| 7129 NPN_SPDY_2); | 7081 NPN_SPDY_2); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 7140 HttpStreamFactory::set_use_alternate_protocols(false); | 7092 HttpStreamFactory::set_use_alternate_protocols(false); |
| 7141 } | 7093 } |
| 7142 | 7094 |
| 7143 TEST_F(HttpNetworkTransactionSpdy2Test, | 7095 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 7144 AlternateProtocolPortUnrestrictedAllowed1) { | 7096 AlternateProtocolPortUnrestrictedAllowed1) { |
| 7145 // Ensure that we're not allowed to redirect traffic via an alternate | 7097 // Ensure that we're not allowed to redirect traffic via an alternate |
| 7146 // protocol to an unrestricted (port >= 1024) when the original traffic was | 7098 // protocol to an unrestricted (port >= 1024) when the original traffic was |
| 7147 // on a restricted port (port < 1024). Ensure that we can redirect in all | 7099 // on a restricted port (port < 1024). Ensure that we can redirect in all |
| 7148 // other cases. | 7100 // other cases. |
| 7149 HttpStreamFactory::set_use_alternate_protocols(true); | 7101 HttpStreamFactory::set_use_alternate_protocols(true); |
| 7150 SessionDependencies session_deps; | 7102 SpdySessionDependencies session_deps; |
| 7151 | 7103 |
| 7152 HttpRequestInfo unrestricted_port_request; | 7104 HttpRequestInfo unrestricted_port_request; |
| 7153 unrestricted_port_request.method = "GET"; | 7105 unrestricted_port_request.method = "GET"; |
| 7154 unrestricted_port_request.url = GURL("http://www.google.com:1024/"); | 7106 unrestricted_port_request.url = GURL("http://www.google.com:1024/"); |
| 7155 unrestricted_port_request.load_flags = 0; | 7107 unrestricted_port_request.load_flags = 0; |
| 7156 | 7108 |
| 7157 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 7109 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 7158 StaticSocketDataProvider first_data; | 7110 StaticSocketDataProvider first_data; |
| 7159 first_data.set_connect_data(mock_connect); | 7111 first_data.set_connect_data(mock_connect); |
| 7160 session_deps.socket_factory.AddSocketDataProvider(&first_data); | 7112 session_deps.socket_factory->AddSocketDataProvider(&first_data); |
| 7161 | 7113 |
| 7162 MockRead data_reads[] = { | 7114 MockRead data_reads[] = { |
| 7163 MockRead("HTTP/1.1 200 OK\r\n\r\n"), | 7115 MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
| 7164 MockRead("hello world"), | 7116 MockRead("hello world"), |
| 7165 MockRead(ASYNC, OK), | 7117 MockRead(ASYNC, OK), |
| 7166 }; | 7118 }; |
| 7167 StaticSocketDataProvider second_data( | 7119 StaticSocketDataProvider second_data( |
| 7168 data_reads, arraysize(data_reads), NULL, 0); | 7120 data_reads, arraysize(data_reads), NULL, 0); |
| 7169 session_deps.socket_factory.AddSocketDataProvider(&second_data); | 7121 session_deps.socket_factory->AddSocketDataProvider(&second_data); |
| 7170 | 7122 |
| 7171 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7123 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 7172 | 7124 |
| 7173 HttpServerProperties* http_server_properties = | 7125 HttpServerProperties* http_server_properties = |
| 7174 session->http_server_properties(); | 7126 session->http_server_properties(); |
| 7175 const int kRestrictedAlternatePort = 80; | 7127 const int kRestrictedAlternatePort = 80; |
| 7176 http_server_properties->SetAlternateProtocol( | 7128 http_server_properties->SetAlternateProtocol( |
| 7177 HostPortPair::FromURL(unrestricted_port_request.url), | 7129 HostPortPair::FromURL(unrestricted_port_request.url), |
| 7178 kRestrictedAlternatePort, | 7130 kRestrictedAlternatePort, |
| 7179 NPN_SPDY_2); | 7131 NPN_SPDY_2); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 7190 HttpStreamFactory::set_use_alternate_protocols(false); | 7142 HttpStreamFactory::set_use_alternate_protocols(false); |
| 7191 } | 7143 } |
| 7192 | 7144 |
| 7193 TEST_F(HttpNetworkTransactionSpdy2Test, | 7145 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 7194 AlternateProtocolPortUnrestrictedAllowed2) { | 7146 AlternateProtocolPortUnrestrictedAllowed2) { |
| 7195 // Ensure that we're not allowed to redirect traffic via an alternate | 7147 // Ensure that we're not allowed to redirect traffic via an alternate |
| 7196 // protocol to an unrestricted (port >= 1024) when the original traffic was | 7148 // protocol to an unrestricted (port >= 1024) when the original traffic was |
| 7197 // on a restricted port (port < 1024). Ensure that we can redirect in all | 7149 // on a restricted port (port < 1024). Ensure that we can redirect in all |
| 7198 // other cases. | 7150 // other cases. |
| 7199 HttpStreamFactory::set_use_alternate_protocols(true); | 7151 HttpStreamFactory::set_use_alternate_protocols(true); |
| 7200 SessionDependencies session_deps; | 7152 SpdySessionDependencies session_deps; |
| 7201 | 7153 |
| 7202 HttpRequestInfo unrestricted_port_request; | 7154 HttpRequestInfo unrestricted_port_request; |
| 7203 unrestricted_port_request.method = "GET"; | 7155 unrestricted_port_request.method = "GET"; |
| 7204 unrestricted_port_request.url = GURL("http://www.google.com:1024/"); | 7156 unrestricted_port_request.url = GURL("http://www.google.com:1024/"); |
| 7205 unrestricted_port_request.load_flags = 0; | 7157 unrestricted_port_request.load_flags = 0; |
| 7206 | 7158 |
| 7207 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); | 7159 MockConnect mock_connect(ASYNC, ERR_CONNECTION_REFUSED); |
| 7208 StaticSocketDataProvider first_data; | 7160 StaticSocketDataProvider first_data; |
| 7209 first_data.set_connect_data(mock_connect); | 7161 first_data.set_connect_data(mock_connect); |
| 7210 session_deps.socket_factory.AddSocketDataProvider(&first_data); | 7162 session_deps.socket_factory->AddSocketDataProvider(&first_data); |
| 7211 | 7163 |
| 7212 MockRead data_reads[] = { | 7164 MockRead data_reads[] = { |
| 7213 MockRead("HTTP/1.1 200 OK\r\n\r\n"), | 7165 MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
| 7214 MockRead("hello world"), | 7166 MockRead("hello world"), |
| 7215 MockRead(ASYNC, OK), | 7167 MockRead(ASYNC, OK), |
| 7216 }; | 7168 }; |
| 7217 StaticSocketDataProvider second_data( | 7169 StaticSocketDataProvider second_data( |
| 7218 data_reads, arraysize(data_reads), NULL, 0); | 7170 data_reads, arraysize(data_reads), NULL, 0); |
| 7219 session_deps.socket_factory.AddSocketDataProvider(&second_data); | 7171 session_deps.socket_factory->AddSocketDataProvider(&second_data); |
| 7220 | 7172 |
| 7221 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7173 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 7222 | 7174 |
| 7223 HttpServerProperties* http_server_properties = | 7175 HttpServerProperties* http_server_properties = |
| 7224 session->http_server_properties(); | 7176 session->http_server_properties(); |
| 7225 const int kUnrestrictedAlternatePort = 1024; | 7177 const int kUnrestrictedAlternatePort = 1024; |
| 7226 http_server_properties->SetAlternateProtocol( | 7178 http_server_properties->SetAlternateProtocol( |
| 7227 HostPortPair::FromURL(unrestricted_port_request.url), | 7179 HostPortPair::FromURL(unrestricted_port_request.url), |
| 7228 kUnrestrictedAlternatePort, | 7180 kUnrestrictedAlternatePort, |
| 7229 NPN_SPDY_2); | 7181 NPN_SPDY_2); |
| 7230 | 7182 |
| 7231 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 7183 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 7232 TestCompletionCallback callback; | 7184 TestCompletionCallback callback; |
| 7233 | 7185 |
| 7234 int rv = trans->Start( | 7186 int rv = trans->Start( |
| 7235 &unrestricted_port_request, callback.callback(), BoundNetLog()); | 7187 &unrestricted_port_request, callback.callback(), BoundNetLog()); |
| 7236 EXPECT_EQ(ERR_IO_PENDING, rv); | 7188 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7237 // Valid change to an unrestricted port should pass. | 7189 // Valid change to an unrestricted port should pass. |
| 7238 EXPECT_EQ(OK, callback.WaitForResult()); | 7190 EXPECT_EQ(OK, callback.WaitForResult()); |
| 7239 | 7191 |
| 7240 HttpStreamFactory::set_use_alternate_protocols(false); | 7192 HttpStreamFactory::set_use_alternate_protocols(false); |
| 7241 } | 7193 } |
| 7242 | 7194 |
| 7243 TEST_F(HttpNetworkTransactionSpdy2Test, | 7195 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 7244 AlternateProtocolUnsafeBlocked) { | 7196 AlternateProtocolUnsafeBlocked) { |
| 7245 // Ensure that we're not allowed to redirect traffic via an alternate | 7197 // Ensure that we're not allowed to redirect traffic via an alternate |
| 7246 // protocol to an unsafe port, and that we resume the second | 7198 // protocol to an unsafe port, and that we resume the second |
| 7247 // HttpStreamFactoryImpl::Job once the alternate protocol request fails. | 7199 // HttpStreamFactoryImpl::Job once the alternate protocol request fails. |
| 7248 HttpStreamFactory::set_use_alternate_protocols(true); | 7200 HttpStreamFactory::set_use_alternate_protocols(true); |
| 7249 SessionDependencies session_deps; | 7201 SpdySessionDependencies session_deps; |
| 7250 | 7202 |
| 7251 HttpRequestInfo request; | 7203 HttpRequestInfo request; |
| 7252 request.method = "GET"; | 7204 request.method = "GET"; |
| 7253 request.url = GURL("http://www.google.com/"); | 7205 request.url = GURL("http://www.google.com/"); |
| 7254 request.load_flags = 0; | 7206 request.load_flags = 0; |
| 7255 | 7207 |
| 7256 // The alternate protocol request will error out before we attempt to connect, | 7208 // The alternate protocol request will error out before we attempt to connect, |
| 7257 // so only the standard HTTP request will try to connect. | 7209 // so only the standard HTTP request will try to connect. |
| 7258 MockRead data_reads[] = { | 7210 MockRead data_reads[] = { |
| 7259 MockRead("HTTP/1.1 200 OK\r\n\r\n"), | 7211 MockRead("HTTP/1.1 200 OK\r\n\r\n"), |
| 7260 MockRead("hello world"), | 7212 MockRead("hello world"), |
| 7261 MockRead(ASYNC, OK), | 7213 MockRead(ASYNC, OK), |
| 7262 }; | 7214 }; |
| 7263 StaticSocketDataProvider data( | 7215 StaticSocketDataProvider data( |
| 7264 data_reads, arraysize(data_reads), NULL, 0); | 7216 data_reads, arraysize(data_reads), NULL, 0); |
| 7265 session_deps.socket_factory.AddSocketDataProvider(&data); | 7217 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 7266 | 7218 |
| 7267 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7219 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 7268 | 7220 |
| 7269 HttpServerProperties* http_server_properties = | 7221 HttpServerProperties* http_server_properties = |
| 7270 session->http_server_properties(); | 7222 session->http_server_properties(); |
| 7271 const int kUnsafePort = 7; | 7223 const int kUnsafePort = 7; |
| 7272 http_server_properties->SetAlternateProtocol( | 7224 http_server_properties->SetAlternateProtocol( |
| 7273 HostPortPair::FromURL(request.url), | 7225 HostPortPair::FromURL(request.url), |
| 7274 kUnsafePort, | 7226 kUnsafePort, |
| 7275 NPN_SPDY_2); | 7227 NPN_SPDY_2); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 7291 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7243 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 7292 | 7244 |
| 7293 std::string response_data; | 7245 std::string response_data; |
| 7294 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 7246 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 7295 EXPECT_EQ("hello world", response_data); | 7247 EXPECT_EQ("hello world", response_data); |
| 7296 } | 7248 } |
| 7297 | 7249 |
| 7298 TEST_F(HttpNetworkTransactionSpdy2Test, UseAlternateProtocolForNpnSpdy) { | 7250 TEST_F(HttpNetworkTransactionSpdy2Test, UseAlternateProtocolForNpnSpdy) { |
| 7299 HttpStreamFactory::set_use_alternate_protocols(true); | 7251 HttpStreamFactory::set_use_alternate_protocols(true); |
| 7300 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 7252 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
| 7301 SessionDependencies session_deps; | 7253 SpdySessionDependencies session_deps; |
| 7302 | 7254 |
| 7303 HttpRequestInfo request; | 7255 HttpRequestInfo request; |
| 7304 request.method = "GET"; | 7256 request.method = "GET"; |
| 7305 request.url = GURL("http://www.google.com/"); | 7257 request.url = GURL("http://www.google.com/"); |
| 7306 request.load_flags = 0; | 7258 request.load_flags = 0; |
| 7307 | 7259 |
| 7308 MockRead data_reads[] = { | 7260 MockRead data_reads[] = { |
| 7309 MockRead("HTTP/1.1 200 OK\r\n"), | 7261 MockRead("HTTP/1.1 200 OK\r\n"), |
| 7310 MockRead(kAlternateProtocolHttpHeader), | 7262 MockRead(kAlternateProtocolHttpHeader), |
| 7311 MockRead("hello world"), | 7263 MockRead("hello world"), |
| 7312 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 7264 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 7313 MockRead(ASYNC, OK) | 7265 MockRead(ASYNC, OK) |
| 7314 }; | 7266 }; |
| 7315 | 7267 |
| 7316 StaticSocketDataProvider first_transaction( | 7268 StaticSocketDataProvider first_transaction( |
| 7317 data_reads, arraysize(data_reads), NULL, 0); | 7269 data_reads, arraysize(data_reads), NULL, 0); |
| 7318 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7270 session_deps.socket_factory->AddSocketDataProvider(&first_transaction); |
| 7319 | 7271 |
| 7320 SSLSocketDataProvider ssl(ASYNC, OK); | 7272 SSLSocketDataProvider ssl(ASYNC, OK); |
| 7321 ssl.SetNextProto(kProtoSPDY2); | 7273 ssl.SetNextProto(kProtoSPDY2); |
| 7322 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 7274 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 7323 | 7275 |
| 7324 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 7276 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 7325 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 7277 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
| 7326 | 7278 |
| 7327 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 7279 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 7328 scoped_ptr<SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); | 7280 scoped_ptr<SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); |
| 7329 MockRead spdy_reads[] = { | 7281 MockRead spdy_reads[] = { |
| 7330 CreateMockRead(*resp), | 7282 CreateMockRead(*resp), |
| 7331 CreateMockRead(*data), | 7283 CreateMockRead(*data), |
| 7332 MockRead(ASYNC, 0, 0), | 7284 MockRead(ASYNC, 0, 0), |
| 7333 }; | 7285 }; |
| 7334 | 7286 |
| 7335 DelayedSocketData spdy_data( | 7287 DelayedSocketData spdy_data( |
| 7336 1, // wait for one write to finish before reading. | 7288 1, // wait for one write to finish before reading. |
| 7337 spdy_reads, arraysize(spdy_reads), | 7289 spdy_reads, arraysize(spdy_reads), |
| 7338 spdy_writes, arraysize(spdy_writes)); | 7290 spdy_writes, arraysize(spdy_writes)); |
| 7339 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 7291 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 7340 | 7292 |
| 7341 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 7293 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
| 7342 StaticSocketDataProvider hanging_non_alternate_protocol_socket( | 7294 StaticSocketDataProvider hanging_non_alternate_protocol_socket( |
| 7343 NULL, 0, NULL, 0); | 7295 NULL, 0, NULL, 0); |
| 7344 hanging_non_alternate_protocol_socket.set_connect_data( | 7296 hanging_non_alternate_protocol_socket.set_connect_data( |
| 7345 never_finishing_connect); | 7297 never_finishing_connect); |
| 7346 session_deps.socket_factory.AddSocketDataProvider( | 7298 session_deps.socket_factory->AddSocketDataProvider( |
| 7347 &hanging_non_alternate_protocol_socket); | 7299 &hanging_non_alternate_protocol_socket); |
| 7348 | 7300 |
| 7349 TestCompletionCallback callback; | 7301 TestCompletionCallback callback; |
| 7350 | 7302 |
| 7351 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7303 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 7352 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 7304 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 7353 | 7305 |
| 7354 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7306 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 7355 EXPECT_EQ(ERR_IO_PENDING, rv); | 7307 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7356 EXPECT_EQ(OK, callback.WaitForResult()); | 7308 EXPECT_EQ(OK, callback.WaitForResult()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 7380 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 7332 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 7381 EXPECT_EQ("hello!", response_data); | 7333 EXPECT_EQ("hello!", response_data); |
| 7382 | 7334 |
| 7383 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); | 7335 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
| 7384 HttpStreamFactory::set_use_alternate_protocols(false); | 7336 HttpStreamFactory::set_use_alternate_protocols(false); |
| 7385 } | 7337 } |
| 7386 | 7338 |
| 7387 TEST_F(HttpNetworkTransactionSpdy2Test, AlternateProtocolWithSpdyLateBinding) { | 7339 TEST_F(HttpNetworkTransactionSpdy2Test, AlternateProtocolWithSpdyLateBinding) { |
| 7388 HttpStreamFactory::set_use_alternate_protocols(true); | 7340 HttpStreamFactory::set_use_alternate_protocols(true); |
| 7389 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 7341 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
| 7390 SessionDependencies session_deps; | 7342 SpdySessionDependencies session_deps; |
| 7391 | 7343 |
| 7392 HttpRequestInfo request; | 7344 HttpRequestInfo request; |
| 7393 request.method = "GET"; | 7345 request.method = "GET"; |
| 7394 request.url = GURL("http://www.google.com/"); | 7346 request.url = GURL("http://www.google.com/"); |
| 7395 request.load_flags = 0; | 7347 request.load_flags = 0; |
| 7396 | 7348 |
| 7397 MockRead data_reads[] = { | 7349 MockRead data_reads[] = { |
| 7398 MockRead("HTTP/1.1 200 OK\r\n"), | 7350 MockRead("HTTP/1.1 200 OK\r\n"), |
| 7399 MockRead(kAlternateProtocolHttpHeader), | 7351 MockRead(kAlternateProtocolHttpHeader), |
| 7400 MockRead("hello world"), | 7352 MockRead("hello world"), |
| 7401 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 7353 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 7402 MockRead(ASYNC, OK), | 7354 MockRead(ASYNC, OK), |
| 7403 }; | 7355 }; |
| 7404 | 7356 |
| 7405 StaticSocketDataProvider first_transaction( | 7357 StaticSocketDataProvider first_transaction( |
| 7406 data_reads, arraysize(data_reads), NULL, 0); | 7358 data_reads, arraysize(data_reads), NULL, 0); |
| 7407 // Socket 1 is the HTTP transaction with the Alternate-Protocol header. | 7359 // Socket 1 is the HTTP transaction with the Alternate-Protocol header. |
| 7408 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7360 session_deps.socket_factory->AddSocketDataProvider(&first_transaction); |
| 7409 | 7361 |
| 7410 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 7362 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
| 7411 StaticSocketDataProvider hanging_socket( | 7363 StaticSocketDataProvider hanging_socket( |
| 7412 NULL, 0, NULL, 0); | 7364 NULL, 0, NULL, 0); |
| 7413 hanging_socket.set_connect_data(never_finishing_connect); | 7365 hanging_socket.set_connect_data(never_finishing_connect); |
| 7414 // Socket 2 and 3 are the hanging Alternate-Protocol and | 7366 // Socket 2 and 3 are the hanging Alternate-Protocol and |
| 7415 // non-Alternate-Protocol jobs from the 2nd transaction. | 7367 // non-Alternate-Protocol jobs from the 2nd transaction. |
| 7416 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); | 7368 session_deps.socket_factory->AddSocketDataProvider(&hanging_socket); |
| 7417 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); | 7369 session_deps.socket_factory->AddSocketDataProvider(&hanging_socket); |
| 7418 | 7370 |
| 7419 SSLSocketDataProvider ssl(ASYNC, OK); | 7371 SSLSocketDataProvider ssl(ASYNC, OK); |
| 7420 ssl.SetNextProto(kProtoSPDY2); | 7372 ssl.SetNextProto(kProtoSPDY2); |
| 7421 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 7373 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 7422 | 7374 |
| 7423 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 7375 scoped_ptr<SpdyFrame> req1(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 7424 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); | 7376 scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); |
| 7425 MockWrite spdy_writes[] = { | 7377 MockWrite spdy_writes[] = { |
| 7426 CreateMockWrite(*req1), | 7378 CreateMockWrite(*req1), |
| 7427 CreateMockWrite(*req2), | 7379 CreateMockWrite(*req2), |
| 7428 }; | 7380 }; |
| 7429 scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1)); | 7381 scoped_ptr<SpdyFrame> resp1(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 7430 scoped_ptr<SpdyFrame> data1(ConstructSpdyBodyFrame(1, true)); | 7382 scoped_ptr<SpdyFrame> data1(ConstructSpdyBodyFrame(1, true)); |
| 7431 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); | 7383 scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 7432 scoped_ptr<SpdyFrame> data2(ConstructSpdyBodyFrame(3, true)); | 7384 scoped_ptr<SpdyFrame> data2(ConstructSpdyBodyFrame(3, true)); |
| 7433 MockRead spdy_reads[] = { | 7385 MockRead spdy_reads[] = { |
| 7434 CreateMockRead(*resp1), | 7386 CreateMockRead(*resp1), |
| 7435 CreateMockRead(*data1), | 7387 CreateMockRead(*data1), |
| 7436 CreateMockRead(*resp2), | 7388 CreateMockRead(*resp2), |
| 7437 CreateMockRead(*data2), | 7389 CreateMockRead(*data2), |
| 7438 MockRead(ASYNC, 0, 0), | 7390 MockRead(ASYNC, 0, 0), |
| 7439 }; | 7391 }; |
| 7440 | 7392 |
| 7441 DelayedSocketData spdy_data( | 7393 DelayedSocketData spdy_data( |
| 7442 2, // wait for writes to finish before reading. | 7394 2, // wait for writes to finish before reading. |
| 7443 spdy_reads, arraysize(spdy_reads), | 7395 spdy_reads, arraysize(spdy_reads), |
| 7444 spdy_writes, arraysize(spdy_writes)); | 7396 spdy_writes, arraysize(spdy_writes)); |
| 7445 // Socket 4 is the successful Alternate-Protocol for transaction 3. | 7397 // Socket 4 is the successful Alternate-Protocol for transaction 3. |
| 7446 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 7398 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 7447 | 7399 |
| 7448 // Socket 5 is the unsuccessful non-Alternate-Protocol for transaction 3. | 7400 // Socket 5 is the unsuccessful non-Alternate-Protocol for transaction 3. |
| 7449 session_deps.socket_factory.AddSocketDataProvider(&hanging_socket); | 7401 session_deps.socket_factory->AddSocketDataProvider(&hanging_socket); |
| 7450 | 7402 |
| 7451 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7403 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 7452 TestCompletionCallback callback1; | 7404 TestCompletionCallback callback1; |
| 7453 HttpNetworkTransaction trans1(session); | 7405 HttpNetworkTransaction trans1(session); |
| 7454 | 7406 |
| 7455 int rv = trans1.Start(&request, callback1.callback(), BoundNetLog()); | 7407 int rv = trans1.Start(&request, callback1.callback(), BoundNetLog()); |
| 7456 EXPECT_EQ(ERR_IO_PENDING, rv); | 7408 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7457 EXPECT_EQ(OK, callback1.WaitForResult()); | 7409 EXPECT_EQ(OK, callback1.WaitForResult()); |
| 7458 | 7410 |
| 7459 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 7411 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7496 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); | 7448 ASSERT_EQ(OK, ReadTransaction(&trans3, &response_data)); |
| 7497 EXPECT_EQ("hello!", response_data); | 7449 EXPECT_EQ("hello!", response_data); |
| 7498 | 7450 |
| 7499 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); | 7451 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
| 7500 HttpStreamFactory::set_use_alternate_protocols(false); | 7452 HttpStreamFactory::set_use_alternate_protocols(false); |
| 7501 } | 7453 } |
| 7502 | 7454 |
| 7503 TEST_F(HttpNetworkTransactionSpdy2Test, StallAlternateProtocolForNpnSpdy) { | 7455 TEST_F(HttpNetworkTransactionSpdy2Test, StallAlternateProtocolForNpnSpdy) { |
| 7504 HttpStreamFactory::set_use_alternate_protocols(true); | 7456 HttpStreamFactory::set_use_alternate_protocols(true); |
| 7505 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 7457 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
| 7506 SessionDependencies session_deps; | 7458 SpdySessionDependencies session_deps; |
| 7507 | 7459 |
| 7508 HttpRequestInfo request; | 7460 HttpRequestInfo request; |
| 7509 request.method = "GET"; | 7461 request.method = "GET"; |
| 7510 request.url = GURL("http://www.google.com/"); | 7462 request.url = GURL("http://www.google.com/"); |
| 7511 request.load_flags = 0; | 7463 request.load_flags = 0; |
| 7512 | 7464 |
| 7513 MockRead data_reads[] = { | 7465 MockRead data_reads[] = { |
| 7514 MockRead("HTTP/1.1 200 OK\r\n"), | 7466 MockRead("HTTP/1.1 200 OK\r\n"), |
| 7515 MockRead(kAlternateProtocolHttpHeader), | 7467 MockRead(kAlternateProtocolHttpHeader), |
| 7516 MockRead("hello world"), | 7468 MockRead("hello world"), |
| 7517 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 7469 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 7518 MockRead(ASYNC, OK), | 7470 MockRead(ASYNC, OK), |
| 7519 }; | 7471 }; |
| 7520 | 7472 |
| 7521 StaticSocketDataProvider first_transaction( | 7473 StaticSocketDataProvider first_transaction( |
| 7522 data_reads, arraysize(data_reads), NULL, 0); | 7474 data_reads, arraysize(data_reads), NULL, 0); |
| 7523 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7475 session_deps.socket_factory->AddSocketDataProvider(&first_transaction); |
| 7524 | 7476 |
| 7525 SSLSocketDataProvider ssl(ASYNC, OK); | 7477 SSLSocketDataProvider ssl(ASYNC, OK); |
| 7526 ssl.SetNextProto(kProtoSPDY2); | 7478 ssl.SetNextProto(kProtoSPDY2); |
| 7527 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 7479 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 7528 | 7480 |
| 7529 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 7481 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
| 7530 StaticSocketDataProvider hanging_alternate_protocol_socket( | 7482 StaticSocketDataProvider hanging_alternate_protocol_socket( |
| 7531 NULL, 0, NULL, 0); | 7483 NULL, 0, NULL, 0); |
| 7532 hanging_alternate_protocol_socket.set_connect_data( | 7484 hanging_alternate_protocol_socket.set_connect_data( |
| 7533 never_finishing_connect); | 7485 never_finishing_connect); |
| 7534 session_deps.socket_factory.AddSocketDataProvider( | 7486 session_deps.socket_factory->AddSocketDataProvider( |
| 7535 &hanging_alternate_protocol_socket); | 7487 &hanging_alternate_protocol_socket); |
| 7536 | 7488 |
| 7537 // 2nd request is just a copy of the first one, over HTTP again. | 7489 // 2nd request is just a copy of the first one, over HTTP again. |
| 7538 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7490 session_deps.socket_factory->AddSocketDataProvider(&first_transaction); |
| 7539 | 7491 |
| 7540 TestCompletionCallback callback; | 7492 TestCompletionCallback callback; |
| 7541 | 7493 |
| 7542 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7494 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 7543 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 7495 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 7544 | 7496 |
| 7545 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7497 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 7546 EXPECT_EQ(ERR_IO_PENDING, rv); | 7498 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7547 EXPECT_EQ(OK, callback.WaitForResult()); | 7499 EXPECT_EQ(OK, callback.WaitForResult()); |
| 7548 | 7500 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7628 UseAlternateProtocolForTunneledNpnSpdy) { | 7580 UseAlternateProtocolForTunneledNpnSpdy) { |
| 7629 HttpStreamFactory::set_use_alternate_protocols(true); | 7581 HttpStreamFactory::set_use_alternate_protocols(true); |
| 7630 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 7582 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
| 7631 | 7583 |
| 7632 ProxyConfig proxy_config; | 7584 ProxyConfig proxy_config; |
| 7633 proxy_config.set_auto_detect(true); | 7585 proxy_config.set_auto_detect(true); |
| 7634 proxy_config.set_pac_url(GURL("http://fooproxyurl")); | 7586 proxy_config.set_pac_url(GURL("http://fooproxyurl")); |
| 7635 | 7587 |
| 7636 CapturingProxyResolver* capturing_proxy_resolver = | 7588 CapturingProxyResolver* capturing_proxy_resolver = |
| 7637 new CapturingProxyResolver(); | 7589 new CapturingProxyResolver(); |
| 7638 SessionDependencies session_deps(new ProxyService( | 7590 SpdySessionDependencies session_deps(new ProxyService( |
| 7639 new ProxyConfigServiceFixed(proxy_config), capturing_proxy_resolver, | 7591 new ProxyConfigServiceFixed(proxy_config), capturing_proxy_resolver, |
| 7640 NULL)); | 7592 NULL)); |
| 7641 | 7593 |
| 7642 HttpRequestInfo request; | 7594 HttpRequestInfo request; |
| 7643 request.method = "GET"; | 7595 request.method = "GET"; |
| 7644 request.url = GURL("http://www.google.com/"); | 7596 request.url = GURL("http://www.google.com/"); |
| 7645 request.load_flags = 0; | 7597 request.load_flags = 0; |
| 7646 | 7598 |
| 7647 MockRead data_reads[] = { | 7599 MockRead data_reads[] = { |
| 7648 MockRead("HTTP/1.1 200 OK\r\n"), | 7600 MockRead("HTTP/1.1 200 OK\r\n"), |
| 7649 MockRead(kAlternateProtocolHttpHeader), | 7601 MockRead(kAlternateProtocolHttpHeader), |
| 7650 MockRead("hello world"), | 7602 MockRead("hello world"), |
| 7651 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 7603 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 7652 MockRead(ASYNC, OK), | 7604 MockRead(ASYNC, OK), |
| 7653 }; | 7605 }; |
| 7654 | 7606 |
| 7655 StaticSocketDataProvider first_transaction( | 7607 StaticSocketDataProvider first_transaction( |
| 7656 data_reads, arraysize(data_reads), NULL, 0); | 7608 data_reads, arraysize(data_reads), NULL, 0); |
| 7657 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7609 session_deps.socket_factory->AddSocketDataProvider(&first_transaction); |
| 7658 | 7610 |
| 7659 SSLSocketDataProvider ssl(ASYNC, OK); | 7611 SSLSocketDataProvider ssl(ASYNC, OK); |
| 7660 ssl.SetNextProto(kProtoSPDY2); | 7612 ssl.SetNextProto(kProtoSPDY2); |
| 7661 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 7613 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 7662 | 7614 |
| 7663 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 7615 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 7664 MockWrite spdy_writes[] = { | 7616 MockWrite spdy_writes[] = { |
| 7665 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 7617 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 7666 "Host: www.google.com\r\n" | 7618 "Host: www.google.com\r\n" |
| 7667 "Proxy-Connection: keep-alive\r\n\r\n"), // 0 | 7619 "Proxy-Connection: keep-alive\r\n\r\n"), // 0 |
| 7668 CreateMockWrite(*req) // 3 | 7620 CreateMockWrite(*req) // 3 |
| 7669 }; | 7621 }; |
| 7670 | 7622 |
| 7671 const char kCONNECTResponse[] = "HTTP/1.1 200 Connected\r\n\r\n"; | 7623 const char kCONNECTResponse[] = "HTTP/1.1 200 Connected\r\n\r\n"; |
| 7672 | 7624 |
| 7673 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 7625 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 7674 scoped_ptr<SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); | 7626 scoped_ptr<SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); |
| 7675 MockRead spdy_reads[] = { | 7627 MockRead spdy_reads[] = { |
| 7676 MockRead(ASYNC, kCONNECTResponse, arraysize(kCONNECTResponse) - 1, 1), // 1 | 7628 MockRead(ASYNC, kCONNECTResponse, arraysize(kCONNECTResponse) - 1, 1), // 1 |
| 7677 CreateMockRead(*resp.get(), 4), // 2, 4 | 7629 CreateMockRead(*resp.get(), 4), // 2, 4 |
| 7678 CreateMockRead(*data.get(), 4), // 5 | 7630 CreateMockRead(*data.get(), 4), // 5 |
| 7679 MockRead(ASYNC, 0, 0, 4), // 6 | 7631 MockRead(ASYNC, 0, 0, 4), // 6 |
| 7680 }; | 7632 }; |
| 7681 | 7633 |
| 7682 OrderedSocketData spdy_data( | 7634 OrderedSocketData spdy_data( |
| 7683 spdy_reads, arraysize(spdy_reads), | 7635 spdy_reads, arraysize(spdy_reads), |
| 7684 spdy_writes, arraysize(spdy_writes)); | 7636 spdy_writes, arraysize(spdy_writes)); |
| 7685 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 7637 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 7686 | 7638 |
| 7687 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 7639 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
| 7688 StaticSocketDataProvider hanging_non_alternate_protocol_socket( | 7640 StaticSocketDataProvider hanging_non_alternate_protocol_socket( |
| 7689 NULL, 0, NULL, 0); | 7641 NULL, 0, NULL, 0); |
| 7690 hanging_non_alternate_protocol_socket.set_connect_data( | 7642 hanging_non_alternate_protocol_socket.set_connect_data( |
| 7691 never_finishing_connect); | 7643 never_finishing_connect); |
| 7692 session_deps.socket_factory.AddSocketDataProvider( | 7644 session_deps.socket_factory->AddSocketDataProvider( |
| 7693 &hanging_non_alternate_protocol_socket); | 7645 &hanging_non_alternate_protocol_socket); |
| 7694 | 7646 |
| 7695 TestCompletionCallback callback; | 7647 TestCompletionCallback callback; |
| 7696 | 7648 |
| 7697 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7649 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 7698 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 7650 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 7699 | 7651 |
| 7700 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7652 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 7701 EXPECT_EQ(ERR_IO_PENDING, rv); | 7653 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7702 EXPECT_EQ(OK, callback.WaitForResult()); | 7654 EXPECT_EQ(OK, callback.WaitForResult()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7734 capturing_proxy_resolver->resolved()[1].spec()); | 7686 capturing_proxy_resolver->resolved()[1].spec()); |
| 7735 | 7687 |
| 7736 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); | 7688 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
| 7737 HttpStreamFactory::set_use_alternate_protocols(false); | 7689 HttpStreamFactory::set_use_alternate_protocols(false); |
| 7738 } | 7690 } |
| 7739 | 7691 |
| 7740 TEST_F(HttpNetworkTransactionSpdy2Test, | 7692 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 7741 UseAlternateProtocolForNpnSpdyWithExistingSpdySession) { | 7693 UseAlternateProtocolForNpnSpdyWithExistingSpdySession) { |
| 7742 HttpStreamFactory::set_use_alternate_protocols(true); | 7694 HttpStreamFactory::set_use_alternate_protocols(true); |
| 7743 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 7695 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
| 7744 SessionDependencies session_deps; | 7696 SpdySessionDependencies session_deps; |
| 7745 | 7697 |
| 7746 HttpRequestInfo request; | 7698 HttpRequestInfo request; |
| 7747 request.method = "GET"; | 7699 request.method = "GET"; |
| 7748 request.url = GURL("http://www.google.com/"); | 7700 request.url = GURL("http://www.google.com/"); |
| 7749 request.load_flags = 0; | 7701 request.load_flags = 0; |
| 7750 | 7702 |
| 7751 MockRead data_reads[] = { | 7703 MockRead data_reads[] = { |
| 7752 MockRead("HTTP/1.1 200 OK\r\n"), | 7704 MockRead("HTTP/1.1 200 OK\r\n"), |
| 7753 MockRead(kAlternateProtocolHttpHeader), | 7705 MockRead(kAlternateProtocolHttpHeader), |
| 7754 MockRead("hello world"), | 7706 MockRead("hello world"), |
| 7755 MockRead(ASYNC, OK), | 7707 MockRead(ASYNC, OK), |
| 7756 }; | 7708 }; |
| 7757 | 7709 |
| 7758 StaticSocketDataProvider first_transaction( | 7710 StaticSocketDataProvider first_transaction( |
| 7759 data_reads, arraysize(data_reads), NULL, 0); | 7711 data_reads, arraysize(data_reads), NULL, 0); |
| 7760 session_deps.socket_factory.AddSocketDataProvider(&first_transaction); | 7712 session_deps.socket_factory->AddSocketDataProvider(&first_transaction); |
| 7761 | 7713 |
| 7762 SSLSocketDataProvider ssl(ASYNC, OK); | 7714 SSLSocketDataProvider ssl(ASYNC, OK); |
| 7763 ssl.SetNextProto(kProtoSPDY2); | 7715 ssl.SetNextProto(kProtoSPDY2); |
| 7764 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 7716 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 7765 | 7717 |
| 7766 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 7718 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 7767 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 7719 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
| 7768 | 7720 |
| 7769 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 7721 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 7770 scoped_ptr<SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); | 7722 scoped_ptr<SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); |
| 7771 MockRead spdy_reads[] = { | 7723 MockRead spdy_reads[] = { |
| 7772 CreateMockRead(*resp), | 7724 CreateMockRead(*resp), |
| 7773 CreateMockRead(*data), | 7725 CreateMockRead(*data), |
| 7774 MockRead(ASYNC, 0, 0), | 7726 MockRead(ASYNC, 0, 0), |
| 7775 }; | 7727 }; |
| 7776 | 7728 |
| 7777 DelayedSocketData spdy_data( | 7729 DelayedSocketData spdy_data( |
| 7778 1, // wait for one write to finish before reading. | 7730 1, // wait for one write to finish before reading. |
| 7779 spdy_reads, arraysize(spdy_reads), | 7731 spdy_reads, arraysize(spdy_reads), |
| 7780 spdy_writes, arraysize(spdy_writes)); | 7732 spdy_writes, arraysize(spdy_writes)); |
| 7781 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 7733 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 7782 | 7734 |
| 7783 TestCompletionCallback callback; | 7735 TestCompletionCallback callback; |
| 7784 | 7736 |
| 7785 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 7737 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 7786 | 7738 |
| 7787 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 7739 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 7788 | 7740 |
| 7789 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 7741 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 7790 EXPECT_EQ(ERR_IO_PENDING, rv); | 7742 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7791 EXPECT_EQ(OK, callback.WaitForResult()); | 7743 EXPECT_EQ(OK, callback.WaitForResult()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 7817 session->GetTransportSocketPool( | 7769 session->GetTransportSocketPool( |
| 7818 HttpNetworkSession::NORMAL_SOCKET_POOL), | 7770 HttpNetworkSession::NORMAL_SOCKET_POOL), |
| 7819 BoundNetLog())); | 7771 BoundNetLog())); |
| 7820 EXPECT_EQ(OK, callback.WaitForResult()); | 7772 EXPECT_EQ(OK, callback.WaitForResult()); |
| 7821 | 7773 |
| 7822 SSLConfig ssl_config; | 7774 SSLConfig ssl_config; |
| 7823 session->ssl_config_service()->GetSSLConfig(&ssl_config); | 7775 session->ssl_config_service()->GetSSLConfig(&ssl_config); |
| 7824 scoped_ptr<ClientSocketHandle> ssl_connection(new ClientSocketHandle); | 7776 scoped_ptr<ClientSocketHandle> ssl_connection(new ClientSocketHandle); |
| 7825 SSLClientSocketContext context; | 7777 SSLClientSocketContext context; |
| 7826 context.cert_verifier = session_deps.cert_verifier.get(); | 7778 context.cert_verifier = session_deps.cert_verifier.get(); |
| 7827 ssl_connection->set_socket(session_deps.socket_factory.CreateSSLClientSocket( | 7779 ssl_connection->set_socket(session_deps.socket_factory->CreateSSLClientSocket( |
| 7828 connection.release(), HostPortPair("" , 443), ssl_config, context)); | 7780 connection.release(), HostPortPair("" , 443), ssl_config, context)); |
| 7829 EXPECT_EQ(ERR_IO_PENDING, | 7781 EXPECT_EQ(ERR_IO_PENDING, |
| 7830 ssl_connection->socket()->Connect(callback.callback())); | 7782 ssl_connection->socket()->Connect(callback.callback())); |
| 7831 EXPECT_EQ(OK, callback.WaitForResult()); | 7783 EXPECT_EQ(OK, callback.WaitForResult()); |
| 7832 | 7784 |
| 7833 EXPECT_EQ(OK, spdy_session->InitializeWithSocket(ssl_connection.release(), | 7785 EXPECT_EQ(OK, spdy_session->InitializeWithSocket(ssl_connection.release(), |
| 7834 true, OK)); | 7786 true, OK)); |
| 7835 | 7787 |
| 7836 trans.reset(new HttpNetworkTransaction(session)); | 7788 trans.reset(new HttpNetworkTransaction(session)); |
| 7837 | 7789 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8149 TestRound(kConnectProxyAuth, kProxyConnected, OK, | 8101 TestRound(kConnectProxyAuth, kProxyConnected, OK, |
| 8150 &kGet, &kServerChallenge), | 8102 &kGet, &kServerChallenge), |
| 8151 TestRound(kGetAuth, kSuccess, OK)}}, | 8103 TestRound(kGetAuth, kSuccess, OK)}}, |
| 8152 { kProxy, AUTH_ASYNC, OK, kSecureServer, AUTH_ASYNC, kAuthErr, 3, 1, | 8104 { kProxy, AUTH_ASYNC, OK, kSecureServer, AUTH_ASYNC, kAuthErr, 3, 1, |
| 8153 { TestRound(kConnect, kProxyChallenge, OK), | 8105 { TestRound(kConnect, kProxyChallenge, OK), |
| 8154 TestRound(kConnectProxyAuth, kProxyConnected, OK, | 8106 TestRound(kConnectProxyAuth, kProxyConnected, OK, |
| 8155 &kGet, &kServerChallenge), | 8107 &kGet, &kServerChallenge), |
| 8156 TestRound(kGetAuth, kFailure, kAuthErr)}}, | 8108 TestRound(kGetAuth, kFailure, kAuthErr)}}, |
| 8157 }; | 8109 }; |
| 8158 | 8110 |
| 8159 SessionDependencies session_deps; | 8111 SpdySessionDependencies session_deps; |
| 8160 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_configs); ++i) { | 8112 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_configs); ++i) { |
| 8161 HttpAuthHandlerMock::Factory* auth_factory( | 8113 HttpAuthHandlerMock::Factory* auth_factory( |
| 8162 new HttpAuthHandlerMock::Factory()); | 8114 new HttpAuthHandlerMock::Factory()); |
| 8163 session_deps.http_auth_handler_factory.reset(auth_factory); | 8115 session_deps.http_auth_handler_factory.reset(auth_factory); |
| 8164 const TestConfig& test_config = test_configs[i]; | 8116 const TestConfig& test_config = test_configs[i]; |
| 8165 | 8117 |
| 8166 // Set up authentication handlers as necessary. | 8118 // Set up authentication handlers as necessary. |
| 8167 if (test_config.proxy_auth_timing != AUTH_NONE) { | 8119 if (test_config.proxy_auth_timing != AUTH_NONE) { |
| 8168 for (int n = 0; n < 2; n++) { | 8120 for (int n = 0; n < 2; n++) { |
| 8169 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); | 8121 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8221 | 8173 |
| 8222 MockWrite writes[2]; | 8174 MockWrite writes[2]; |
| 8223 writes[0] = read_write_round.write; | 8175 writes[0] = read_write_round.write; |
| 8224 size_t length_writes = 1; | 8176 size_t length_writes = 1; |
| 8225 if (read_write_round.extra_write) { | 8177 if (read_write_round.extra_write) { |
| 8226 writes[1] = *read_write_round.extra_write; | 8178 writes[1] = *read_write_round.extra_write; |
| 8227 length_writes = 2; | 8179 length_writes = 2; |
| 8228 } | 8180 } |
| 8229 StaticSocketDataProvider data_provider( | 8181 StaticSocketDataProvider data_provider( |
| 8230 reads, length_reads, writes, length_writes); | 8182 reads, length_reads, writes, length_writes); |
| 8231 session_deps.socket_factory.AddSocketDataProvider(&data_provider); | 8183 session_deps.socket_factory->AddSocketDataProvider(&data_provider); |
| 8232 | 8184 |
| 8233 // Add an SSL sequence if necessary. | 8185 // Add an SSL sequence if necessary. |
| 8234 SSLSocketDataProvider ssl_socket_data_provider(SYNCHRONOUS, OK); | 8186 SSLSocketDataProvider ssl_socket_data_provider(SYNCHRONOUS, OK); |
| 8235 if (round >= test_config.first_ssl_round) | 8187 if (round >= test_config.first_ssl_round) |
| 8236 session_deps.socket_factory.AddSSLSocketDataProvider( | 8188 session_deps.socket_factory->AddSSLSocketDataProvider( |
| 8237 &ssl_socket_data_provider); | 8189 &ssl_socket_data_provider); |
| 8238 | 8190 |
| 8239 // Start or restart the transaction. | 8191 // Start or restart the transaction. |
| 8240 TestCompletionCallback callback; | 8192 TestCompletionCallback callback; |
| 8241 int rv; | 8193 int rv; |
| 8242 if (round == 0) { | 8194 if (round == 0) { |
| 8243 rv = trans.Start(&request, callback.callback(), BoundNetLog()); | 8195 rv = trans.Start(&request, callback.callback(), BoundNetLog()); |
| 8244 } else { | 8196 } else { |
| 8245 rv = trans.RestartWithAuth( | 8197 rv = trans.RestartWithAuth( |
| 8246 AuthCredentials(kFoo, kBar), callback.callback()); | 8198 AuthCredentials(kFoo, kBar), callback.callback()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 8262 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 8214 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
| 8263 } else { | 8215 } else { |
| 8264 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 8216 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 8265 } | 8217 } |
| 8266 } | 8218 } |
| 8267 } | 8219 } |
| 8268 } | 8220 } |
| 8269 | 8221 |
| 8270 TEST_F(HttpNetworkTransactionSpdy2Test, MultiRoundAuth) { | 8222 TEST_F(HttpNetworkTransactionSpdy2Test, MultiRoundAuth) { |
| 8271 // Do multi-round authentication and make sure it works correctly. | 8223 // Do multi-round authentication and make sure it works correctly. |
| 8272 SessionDependencies session_deps; | 8224 SpdySessionDependencies session_deps; |
| 8273 HttpAuthHandlerMock::Factory* auth_factory( | 8225 HttpAuthHandlerMock::Factory* auth_factory( |
| 8274 new HttpAuthHandlerMock::Factory()); | 8226 new HttpAuthHandlerMock::Factory()); |
| 8275 session_deps.http_auth_handler_factory.reset(auth_factory); | 8227 session_deps.http_auth_handler_factory.reset(auth_factory); |
| 8276 session_deps.proxy_service.reset(ProxyService::CreateDirect()); | 8228 session_deps.proxy_service.reset(ProxyService::CreateDirect()); |
| 8277 session_deps.host_resolver->rules()->AddRule("www.example.com", "10.0.0.1"); | 8229 session_deps.host_resolver->rules()->AddRule("www.example.com", "10.0.0.1"); |
| 8278 session_deps.host_resolver->set_synchronous_mode(true); | 8230 session_deps.host_resolver->set_synchronous_mode(true); |
| 8279 | 8231 |
| 8280 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); | 8232 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); |
| 8281 auth_handler->set_connection_based(true); | 8233 auth_handler->set_connection_based(true); |
| 8282 std::string auth_challenge = "Mock realm=server"; | 8234 std::string auth_challenge = "Mock realm=server"; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 8299 // Use a TCP Socket Pool with only one connection per group. This is used | 8251 // Use a TCP Socket Pool with only one connection per group. This is used |
| 8300 // to validate that the TCP socket is not released to the pool between | 8252 // to validate that the TCP socket is not released to the pool between |
| 8301 // each round of multi-round authentication. | 8253 // each round of multi-round authentication. |
| 8302 HttpNetworkSessionPeer session_peer(session); | 8254 HttpNetworkSessionPeer session_peer(session); |
| 8303 ClientSocketPoolHistograms transport_pool_histograms("SmallTCP"); | 8255 ClientSocketPoolHistograms transport_pool_histograms("SmallTCP"); |
| 8304 TransportClientSocketPool* transport_pool = new TransportClientSocketPool( | 8256 TransportClientSocketPool* transport_pool = new TransportClientSocketPool( |
| 8305 50, // Max sockets for pool | 8257 50, // Max sockets for pool |
| 8306 1, // Max sockets per group | 8258 1, // Max sockets per group |
| 8307 &transport_pool_histograms, | 8259 &transport_pool_histograms, |
| 8308 session_deps.host_resolver.get(), | 8260 session_deps.host_resolver.get(), |
| 8309 &session_deps.socket_factory, | 8261 session_deps.socket_factory.get(), |
| 8310 session_deps.net_log); | 8262 session_deps.net_log); |
| 8311 MockClientSocketPoolManager* mock_pool_manager = | 8263 MockClientSocketPoolManager* mock_pool_manager = |
| 8312 new MockClientSocketPoolManager; | 8264 new MockClientSocketPoolManager; |
| 8313 mock_pool_manager->SetTransportSocketPool(transport_pool); | 8265 mock_pool_manager->SetTransportSocketPool(transport_pool); |
| 8314 session_peer.SetClientSocketPoolManager(mock_pool_manager); | 8266 session_peer.SetClientSocketPoolManager(mock_pool_manager); |
| 8315 | 8267 |
| 8316 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8268 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 8317 TestCompletionCallback callback; | 8269 TestCompletionCallback callback; |
| 8318 | 8270 |
| 8319 const MockWrite kGet( | 8271 const MockWrite kGet( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8357 kServerChallenge, | 8309 kServerChallenge, |
| 8358 // Third round | 8310 // Third round |
| 8359 kServerChallenge, | 8311 kServerChallenge, |
| 8360 // Fourth round | 8312 // Fourth round |
| 8361 kSuccess, | 8313 kSuccess, |
| 8362 // Competing response | 8314 // Competing response |
| 8363 kSuccess, | 8315 kSuccess, |
| 8364 }; | 8316 }; |
| 8365 StaticSocketDataProvider data_provider(reads, arraysize(reads), | 8317 StaticSocketDataProvider data_provider(reads, arraysize(reads), |
| 8366 writes, arraysize(writes)); | 8318 writes, arraysize(writes)); |
| 8367 session_deps.socket_factory.AddSocketDataProvider(&data_provider); | 8319 session_deps.socket_factory->AddSocketDataProvider(&data_provider); |
| 8368 | 8320 |
| 8369 const char* const kSocketGroup = "www.example.com:80"; | 8321 const char* const kSocketGroup = "www.example.com:80"; |
| 8370 | 8322 |
| 8371 // First round of authentication. | 8323 // First round of authentication. |
| 8372 auth_handler->SetGenerateExpectation(false, OK); | 8324 auth_handler->SetGenerateExpectation(false, OK); |
| 8373 rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8325 rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 8374 if (rv == ERR_IO_PENDING) | 8326 if (rv == ERR_IO_PENDING) |
| 8375 rv = callback.WaitForResult(); | 8327 rv = callback.WaitForResult(); |
| 8376 EXPECT_EQ(OK, rv); | 8328 EXPECT_EQ(OK, rv); |
| 8377 response = trans->GetResponseInfo(); | 8329 response = trans->GetResponseInfo(); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8480 | 8432 |
| 8481 // Test that we restart a connection when we see a decompression failure from | 8433 // Test that we restart a connection when we see a decompression failure from |
| 8482 // the peer during the handshake. (In the real world we'll restart with SSLv3 | 8434 // the peer during the handshake. (In the real world we'll restart with SSLv3 |
| 8483 // and we won't offer DEFLATE in that case.) | 8435 // and we won't offer DEFLATE in that case.) |
| 8484 TEST_F(HttpNetworkTransactionSpdy2Test, RestartAfterTLSDecompressionFailure) { | 8436 TEST_F(HttpNetworkTransactionSpdy2Test, RestartAfterTLSDecompressionFailure) { |
| 8485 HttpRequestInfo request; | 8437 HttpRequestInfo request; |
| 8486 request.method = "GET"; | 8438 request.method = "GET"; |
| 8487 request.url = GURL("https://tlsdecompressionfailure.example.com/"); | 8439 request.url = GURL("https://tlsdecompressionfailure.example.com/"); |
| 8488 request.load_flags = 0; | 8440 request.load_flags = 0; |
| 8489 | 8441 |
| 8490 SessionDependencies session_deps; | 8442 SpdySessionDependencies session_deps; |
| 8491 TLSDecompressionFailureSocketDataProvider socket_data_provider1( | 8443 TLSDecompressionFailureSocketDataProvider socket_data_provider1( |
| 8492 false /* fail all reads */); | 8444 false /* fail all reads */); |
| 8493 TLSDecompressionFailureSocketDataProvider socket_data_provider2(false); | 8445 TLSDecompressionFailureSocketDataProvider socket_data_provider2(false); |
| 8494 SSLSocketDataProvider ssl_socket_data_provider1( | 8446 SSLSocketDataProvider ssl_socket_data_provider1( |
| 8495 SYNCHRONOUS, ERR_SSL_DECOMPRESSION_FAILURE_ALERT); | 8447 SYNCHRONOUS, ERR_SSL_DECOMPRESSION_FAILURE_ALERT); |
| 8496 SSLSocketDataProvider ssl_socket_data_provider2(SYNCHRONOUS, OK); | 8448 SSLSocketDataProvider ssl_socket_data_provider2(SYNCHRONOUS, OK); |
| 8497 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider1); | 8449 session_deps.socket_factory->AddSocketDataProvider(&socket_data_provider1); |
| 8498 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider2); | 8450 session_deps.socket_factory->AddSocketDataProvider(&socket_data_provider2); |
| 8499 session_deps.socket_factory.AddSSLSocketDataProvider( | 8451 session_deps.socket_factory->AddSSLSocketDataProvider( |
| 8500 &ssl_socket_data_provider1); | 8452 &ssl_socket_data_provider1); |
| 8501 session_deps.socket_factory.AddSSLSocketDataProvider( | 8453 session_deps.socket_factory->AddSSLSocketDataProvider( |
| 8502 &ssl_socket_data_provider2); | 8454 &ssl_socket_data_provider2); |
| 8503 | 8455 |
| 8504 // Work around http://crbug.com/37454 | 8456 // Work around http://crbug.com/37454 |
| 8505 StaticSocketDataProvider bug37454_connection; | 8457 StaticSocketDataProvider bug37454_connection; |
| 8506 bug37454_connection.set_connect_data(MockConnect(ASYNC, ERR_UNEXPECTED)); | 8458 bug37454_connection.set_connect_data(MockConnect(ASYNC, ERR_UNEXPECTED)); |
| 8507 session_deps.socket_factory.AddSocketDataProvider(&bug37454_connection); | 8459 session_deps.socket_factory->AddSocketDataProvider(&bug37454_connection); |
| 8508 | 8460 |
| 8509 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8461 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8510 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8462 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 8511 TestCompletionCallback callback; | 8463 TestCompletionCallback callback; |
| 8512 | 8464 |
| 8513 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8465 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 8514 EXPECT_EQ(ERR_IO_PENDING, rv); | 8466 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8515 EXPECT_EQ(OK, callback.WaitForResult()); | 8467 EXPECT_EQ(OK, callback.WaitForResult()); |
| 8516 | 8468 |
| 8517 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8469 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 8528 // peer while reading the first bytes from the connection. This occurs when the | 8480 // peer while reading the first bytes from the connection. This occurs when the |
| 8529 // peer cannot handle DEFLATE but we're using False Start, so we don't notice | 8481 // peer cannot handle DEFLATE but we're using False Start, so we don't notice |
| 8530 // in the handshake. | 8482 // in the handshake. |
| 8531 TEST_F(HttpNetworkTransactionSpdy2Test, | 8483 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 8532 RestartAfterTLSDecompressionFailureWithFalseStart) { | 8484 RestartAfterTLSDecompressionFailureWithFalseStart) { |
| 8533 HttpRequestInfo request; | 8485 HttpRequestInfo request; |
| 8534 request.method = "GET"; | 8486 request.method = "GET"; |
| 8535 request.url = GURL("https://tlsdecompressionfailure2.example.com/"); | 8487 request.url = GURL("https://tlsdecompressionfailure2.example.com/"); |
| 8536 request.load_flags = 0; | 8488 request.load_flags = 0; |
| 8537 | 8489 |
| 8538 SessionDependencies session_deps; | 8490 SpdySessionDependencies session_deps; |
| 8539 TLSDecompressionFailureSocketDataProvider socket_data_provider1( | 8491 TLSDecompressionFailureSocketDataProvider socket_data_provider1( |
| 8540 true /* fail all reads */); | 8492 true /* fail all reads */); |
| 8541 TLSDecompressionFailureSocketDataProvider socket_data_provider2(false); | 8493 TLSDecompressionFailureSocketDataProvider socket_data_provider2(false); |
| 8542 SSLSocketDataProvider ssl_socket_data_provider1(SYNCHRONOUS, OK); | 8494 SSLSocketDataProvider ssl_socket_data_provider1(SYNCHRONOUS, OK); |
| 8543 SSLSocketDataProvider ssl_socket_data_provider2(SYNCHRONOUS, OK); | 8495 SSLSocketDataProvider ssl_socket_data_provider2(SYNCHRONOUS, OK); |
| 8544 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider1); | 8496 session_deps.socket_factory->AddSocketDataProvider(&socket_data_provider1); |
| 8545 session_deps.socket_factory.AddSocketDataProvider(&socket_data_provider2); | 8497 session_deps.socket_factory->AddSocketDataProvider(&socket_data_provider2); |
| 8546 session_deps.socket_factory.AddSSLSocketDataProvider( | 8498 session_deps.socket_factory->AddSSLSocketDataProvider( |
| 8547 &ssl_socket_data_provider1); | 8499 &ssl_socket_data_provider1); |
| 8548 session_deps.socket_factory.AddSSLSocketDataProvider( | 8500 session_deps.socket_factory->AddSSLSocketDataProvider( |
| 8549 &ssl_socket_data_provider2); | 8501 &ssl_socket_data_provider2); |
| 8550 | 8502 |
| 8551 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8503 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8552 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8504 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 8553 TestCompletionCallback callback; | 8505 TestCompletionCallback callback; |
| 8554 | 8506 |
| 8555 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8507 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 8556 EXPECT_EQ(ERR_IO_PENDING, rv); | 8508 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8557 EXPECT_EQ(OK, callback.WaitForResult()); | 8509 EXPECT_EQ(OK, callback.WaitForResult()); |
| 8558 | 8510 |
| 8559 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8511 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 8560 ASSERT_TRUE(response != NULL); | 8512 ASSERT_TRUE(response != NULL); |
| 8561 ASSERT_TRUE(response->headers != NULL); | 8513 ASSERT_TRUE(response->headers != NULL); |
| 8562 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 8514 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 8563 | 8515 |
| 8564 std::string response_data; | 8516 std::string response_data; |
| 8565 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 8517 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 8566 EXPECT_EQ("ok.", response_data); | 8518 EXPECT_EQ("ok.", response_data); |
| 8567 } | 8519 } |
| 8568 | 8520 |
| 8569 // This tests the case that a request is issued via http instead of spdy after | 8521 // This tests the case that a request is issued via http instead of spdy after |
| 8570 // npn is negotiated. | 8522 // npn is negotiated. |
| 8571 TEST_F(HttpNetworkTransactionSpdy2Test, NpnWithHttpOverSSL) { | 8523 TEST_F(HttpNetworkTransactionSpdy2Test, NpnWithHttpOverSSL) { |
| 8572 HttpStreamFactory::set_use_alternate_protocols(true); | 8524 HttpStreamFactory::set_use_alternate_protocols(true); |
| 8573 HttpStreamFactory::SetNextProtos( | 8525 HttpStreamFactory::SetNextProtos( |
| 8574 MakeNextProtos("http/1.1", "http1.1", NULL)); | 8526 MakeNextProtos("http/1.1", "http1.1", NULL)); |
| 8575 SessionDependencies session_deps; | 8527 SpdySessionDependencies session_deps; |
| 8576 HttpRequestInfo request; | 8528 HttpRequestInfo request; |
| 8577 request.method = "GET"; | 8529 request.method = "GET"; |
| 8578 request.url = GURL("https://www.google.com/"); | 8530 request.url = GURL("https://www.google.com/"); |
| 8579 request.load_flags = 0; | 8531 request.load_flags = 0; |
| 8580 | 8532 |
| 8581 MockWrite data_writes[] = { | 8533 MockWrite data_writes[] = { |
| 8582 MockWrite("GET / HTTP/1.1\r\n" | 8534 MockWrite("GET / HTTP/1.1\r\n" |
| 8583 "Host: www.google.com\r\n" | 8535 "Host: www.google.com\r\n" |
| 8584 "Connection: keep-alive\r\n\r\n"), | 8536 "Connection: keep-alive\r\n\r\n"), |
| 8585 }; | 8537 }; |
| 8586 | 8538 |
| 8587 MockRead data_reads[] = { | 8539 MockRead data_reads[] = { |
| 8588 MockRead("HTTP/1.1 200 OK\r\n"), | 8540 MockRead("HTTP/1.1 200 OK\r\n"), |
| 8589 MockRead(kAlternateProtocolHttpHeader), | 8541 MockRead(kAlternateProtocolHttpHeader), |
| 8590 MockRead("hello world"), | 8542 MockRead("hello world"), |
| 8591 MockRead(SYNCHRONOUS, OK), | 8543 MockRead(SYNCHRONOUS, OK), |
| 8592 }; | 8544 }; |
| 8593 | 8545 |
| 8594 SSLSocketDataProvider ssl(ASYNC, OK); | 8546 SSLSocketDataProvider ssl(ASYNC, OK); |
| 8595 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; | 8547 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
| 8596 ssl.next_proto = "http/1.1"; | 8548 ssl.next_proto = "http/1.1"; |
| 8597 ssl.protocol_negotiated = kProtoHTTP11; | 8549 ssl.protocol_negotiated = kProtoHTTP11; |
| 8598 | 8550 |
| 8599 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 8551 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 8600 | 8552 |
| 8601 StaticSocketDataProvider data(data_reads, arraysize(data_reads), | 8553 StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 8602 data_writes, arraysize(data_writes)); | 8554 data_writes, arraysize(data_writes)); |
| 8603 session_deps.socket_factory.AddSocketDataProvider(&data); | 8555 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 8604 | 8556 |
| 8605 TestCompletionCallback callback; | 8557 TestCompletionCallback callback; |
| 8606 | 8558 |
| 8607 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8559 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8608 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8560 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 8609 | 8561 |
| 8610 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8562 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 8611 | 8563 |
| 8612 EXPECT_EQ(ERR_IO_PENDING, rv); | 8564 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8613 EXPECT_EQ(OK, callback.WaitForResult()); | 8565 EXPECT_EQ(OK, callback.WaitForResult()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 8627 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); | 8579 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
| 8628 HttpStreamFactory::set_use_alternate_protocols(false); | 8580 HttpStreamFactory::set_use_alternate_protocols(false); |
| 8629 } | 8581 } |
| 8630 | 8582 |
| 8631 TEST_F(HttpNetworkTransactionSpdy2Test, SpdyPostNPNServerHangup) { | 8583 TEST_F(HttpNetworkTransactionSpdy2Test, SpdyPostNPNServerHangup) { |
| 8632 // Simulate the SSL handshake completing with an NPN negotiation | 8584 // Simulate the SSL handshake completing with an NPN negotiation |
| 8633 // followed by an immediate server closing of the socket. | 8585 // followed by an immediate server closing of the socket. |
| 8634 // Fix crash: http://crbug.com/46369 | 8586 // Fix crash: http://crbug.com/46369 |
| 8635 HttpStreamFactory::set_use_alternate_protocols(true); | 8587 HttpStreamFactory::set_use_alternate_protocols(true); |
| 8636 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 8588 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
| 8637 SessionDependencies session_deps; | 8589 SpdySessionDependencies session_deps; |
| 8638 | 8590 |
| 8639 HttpRequestInfo request; | 8591 HttpRequestInfo request; |
| 8640 request.method = "GET"; | 8592 request.method = "GET"; |
| 8641 request.url = GURL("https://www.google.com/"); | 8593 request.url = GURL("https://www.google.com/"); |
| 8642 request.load_flags = 0; | 8594 request.load_flags = 0; |
| 8643 | 8595 |
| 8644 SSLSocketDataProvider ssl(ASYNC, OK); | 8596 SSLSocketDataProvider ssl(ASYNC, OK); |
| 8645 ssl.SetNextProto(kProtoSPDY2); | 8597 ssl.SetNextProto(kProtoSPDY2); |
| 8646 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 8598 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 8647 | 8599 |
| 8648 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); | 8600 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
| 8649 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 8601 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
| 8650 | 8602 |
| 8651 MockRead spdy_reads[] = { | 8603 MockRead spdy_reads[] = { |
| 8652 MockRead(SYNCHRONOUS, 0, 0) // Not async - return 0 immediately. | 8604 MockRead(SYNCHRONOUS, 0, 0) // Not async - return 0 immediately. |
| 8653 }; | 8605 }; |
| 8654 | 8606 |
| 8655 DelayedSocketData spdy_data( | 8607 DelayedSocketData spdy_data( |
| 8656 0, // don't wait in this case, immediate hangup. | 8608 0, // don't wait in this case, immediate hangup. |
| 8657 spdy_reads, arraysize(spdy_reads), | 8609 spdy_reads, arraysize(spdy_reads), |
| 8658 spdy_writes, arraysize(spdy_writes)); | 8610 spdy_writes, arraysize(spdy_writes)); |
| 8659 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 8611 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 8660 | 8612 |
| 8661 TestCompletionCallback callback; | 8613 TestCompletionCallback callback; |
| 8662 | 8614 |
| 8663 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8615 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8664 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 8616 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 8665 | 8617 |
| 8666 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 8618 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
| 8667 EXPECT_EQ(ERR_IO_PENDING, rv); | 8619 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8668 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); | 8620 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); |
| 8669 | 8621 |
| 8670 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); | 8622 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
| 8671 HttpStreamFactory::set_use_alternate_protocols(false); | 8623 HttpStreamFactory::set_use_alternate_protocols(false); |
| 8672 } | 8624 } |
| 8673 | 8625 |
| 8674 TEST_F(HttpNetworkTransactionSpdy2Test, SpdyAlternateProtocolThroughProxy) { | 8626 TEST_F(HttpNetworkTransactionSpdy2Test, SpdyAlternateProtocolThroughProxy) { |
| 8675 // This test ensures that the URL passed into the proxy is upgraded | 8627 // This test ensures that the URL passed into the proxy is upgraded |
| 8676 // to https when doing an Alternate Protocol upgrade. | 8628 // to https when doing an Alternate Protocol upgrade. |
| 8677 HttpStreamFactory::set_use_alternate_protocols(true); | 8629 HttpStreamFactory::set_use_alternate_protocols(true); |
| 8678 HttpStreamFactory::SetNextProtos( | 8630 HttpStreamFactory::SetNextProtos( |
| 8679 MakeNextProtos( | 8631 MakeNextProtos( |
| 8680 "http/1.1", "http1.1", "spdy/2", "spdy", NULL)); | 8632 "http/1.1", "http1.1", "spdy/2", "spdy", NULL)); |
| 8681 | 8633 |
| 8682 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8634 SpdySessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 8683 HttpAuthHandlerMock::Factory* auth_factory = | 8635 HttpAuthHandlerMock::Factory* auth_factory = |
| 8684 new HttpAuthHandlerMock::Factory(); | 8636 new HttpAuthHandlerMock::Factory(); |
| 8685 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock(); | 8637 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock(); |
| 8686 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY); | 8638 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY); |
| 8687 auth_factory->set_do_init_from_challenge(true); | 8639 auth_factory->set_do_init_from_challenge(true); |
| 8688 session_deps.http_auth_handler_factory.reset(auth_factory); | 8640 session_deps.http_auth_handler_factory.reset(auth_factory); |
| 8689 | 8641 |
| 8690 HttpRequestInfo request; | 8642 HttpRequestInfo request; |
| 8691 request.method = "GET"; | 8643 request.method = "GET"; |
| 8692 request.url = GURL("http://www.google.com"); | 8644 request.url = GURL("http://www.google.com"); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8773 | 8725 |
| 8774 SSLSocketDataProvider ssl(ASYNC, OK); | 8726 SSLSocketDataProvider ssl(ASYNC, OK); |
| 8775 ssl.SetNextProto(kProtoSPDY2); | 8727 ssl.SetNextProto(kProtoSPDY2); |
| 8776 | 8728 |
| 8777 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); | 8729 MockConnect never_finishing_connect(SYNCHRONOUS, ERR_IO_PENDING); |
| 8778 StaticSocketDataProvider hanging_non_alternate_protocol_socket( | 8730 StaticSocketDataProvider hanging_non_alternate_protocol_socket( |
| 8779 NULL, 0, NULL, 0); | 8731 NULL, 0, NULL, 0); |
| 8780 hanging_non_alternate_protocol_socket.set_connect_data( | 8732 hanging_non_alternate_protocol_socket.set_connect_data( |
| 8781 never_finishing_connect); | 8733 never_finishing_connect); |
| 8782 | 8734 |
| 8783 session_deps.socket_factory.AddSocketDataProvider(&data_1); | 8735 session_deps.socket_factory->AddSocketDataProvider(&data_1); |
| 8784 session_deps.socket_factory.AddSocketDataProvider(&data_2); | 8736 session_deps.socket_factory->AddSocketDataProvider(&data_2); |
| 8785 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 8737 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 8786 session_deps.socket_factory.AddSocketDataProvider( | 8738 session_deps.socket_factory->AddSocketDataProvider( |
| 8787 &hanging_non_alternate_protocol_socket); | 8739 &hanging_non_alternate_protocol_socket); |
| 8788 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8740 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8789 | 8741 |
| 8790 // First round should work and provide the Alternate-Protocol state. | 8742 // First round should work and provide the Alternate-Protocol state. |
| 8791 TestCompletionCallback callback_1; | 8743 TestCompletionCallback callback_1; |
| 8792 scoped_ptr<HttpTransaction> trans_1(new HttpNetworkTransaction(session)); | 8744 scoped_ptr<HttpTransaction> trans_1(new HttpNetworkTransaction(session)); |
| 8793 int rv = trans_1->Start(&request, callback_1.callback(), BoundNetLog()); | 8745 int rv = trans_1->Start(&request, callback_1.callback(), BoundNetLog()); |
| 8794 EXPECT_EQ(ERR_IO_PENDING, rv); | 8746 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8795 EXPECT_EQ(OK, callback_1.WaitForResult()); | 8747 EXPECT_EQ(OK, callback_1.WaitForResult()); |
| 8796 | 8748 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8834 MockRead(SYNCHRONOUS, "HTTP/1.0 200 OK\r\n\r\n"), | 8786 MockRead(SYNCHRONOUS, "HTTP/1.0 200 OK\r\n\r\n"), |
| 8835 MockRead(SYNCHRONOUS, "hello world"), | 8787 MockRead(SYNCHRONOUS, "hello world"), |
| 8836 MockRead(SYNCHRONOUS, OK), | 8788 MockRead(SYNCHRONOUS, OK), |
| 8837 }; | 8789 }; |
| 8838 | 8790 |
| 8839 HttpRequestInfo request; | 8791 HttpRequestInfo request; |
| 8840 request.method = "GET"; | 8792 request.method = "GET"; |
| 8841 request.url = GURL("http://www.google.com/"); | 8793 request.url = GURL("http://www.google.com/"); |
| 8842 request.load_flags = 0; | 8794 request.load_flags = 0; |
| 8843 | 8795 |
| 8844 SessionDependencies session_deps; | 8796 SpdySessionDependencies session_deps; |
| 8845 session_deps.host_resolver->set_synchronous_mode(true); | 8797 session_deps.host_resolver->set_synchronous_mode(true); |
| 8846 scoped_ptr<HttpTransaction> trans( | 8798 scoped_ptr<HttpTransaction> trans( |
| 8847 new HttpNetworkTransaction(CreateSession(&session_deps))); | 8799 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 8848 | 8800 |
| 8849 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 8801 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
| 8850 data.set_connect_data(mock_connect); | 8802 data.set_connect_data(mock_connect); |
| 8851 session_deps.socket_factory.AddSocketDataProvider(&data); | 8803 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 8852 | 8804 |
| 8853 TestCompletionCallback callback; | 8805 TestCompletionCallback callback; |
| 8854 | 8806 |
| 8855 CapturingBoundNetLog log; | 8807 CapturingBoundNetLog log; |
| 8856 int rv = trans->Start(&request, callback.callback(), log.bound()); | 8808 int rv = trans->Start(&request, callback.callback(), log.bound()); |
| 8857 EXPECT_EQ(ERR_IO_PENDING, rv); | 8809 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8858 trans.reset(); // Cancel the transaction here. | 8810 trans.reset(); // Cancel the transaction here. |
| 8859 | 8811 |
| 8860 MessageLoop::current()->RunUntilIdle(); | 8812 MessageLoop::current()->RunUntilIdle(); |
| 8861 } | 8813 } |
| 8862 | 8814 |
| 8863 // Test a basic GET request through a proxy. | 8815 // Test a basic GET request through a proxy. |
| 8864 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyGet) { | 8816 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyGet) { |
| 8865 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8817 SpdySessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 8866 CapturingBoundNetLog log; | 8818 CapturingBoundNetLog log; |
| 8867 session_deps.net_log = log.bound().net_log(); | 8819 session_deps.net_log = log.bound().net_log(); |
| 8868 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8820 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8869 | 8821 |
| 8870 HttpRequestInfo request; | 8822 HttpRequestInfo request; |
| 8871 request.method = "GET"; | 8823 request.method = "GET"; |
| 8872 request.url = GURL("http://www.google.com/"); | 8824 request.url = GURL("http://www.google.com/"); |
| 8873 | 8825 |
| 8874 MockWrite data_writes1[] = { | 8826 MockWrite data_writes1[] = { |
| 8875 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" | 8827 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" |
| 8876 "Host: www.google.com\r\n" | 8828 "Host: www.google.com\r\n" |
| 8877 "Proxy-Connection: keep-alive\r\n\r\n"), | 8829 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 8878 }; | 8830 }; |
| 8879 | 8831 |
| 8880 MockRead data_reads1[] = { | 8832 MockRead data_reads1[] = { |
| 8881 MockRead("HTTP/1.1 200 OK\r\n"), | 8833 MockRead("HTTP/1.1 200 OK\r\n"), |
| 8882 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 8834 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 8883 MockRead("Content-Length: 100\r\n\r\n"), | 8835 MockRead("Content-Length: 100\r\n\r\n"), |
| 8884 MockRead(SYNCHRONOUS, OK), | 8836 MockRead(SYNCHRONOUS, OK), |
| 8885 }; | 8837 }; |
| 8886 | 8838 |
| 8887 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 8839 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 8888 data_writes1, arraysize(data_writes1)); | 8840 data_writes1, arraysize(data_writes1)); |
| 8889 session_deps.socket_factory.AddSocketDataProvider(&data1); | 8841 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 8890 | 8842 |
| 8891 TestCompletionCallback callback1; | 8843 TestCompletionCallback callback1; |
| 8892 | 8844 |
| 8893 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8845 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 8894 | 8846 |
| 8895 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 8847 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 8896 EXPECT_EQ(ERR_IO_PENDING, rv); | 8848 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8897 | 8849 |
| 8898 rv = callback1.WaitForResult(); | 8850 rv = callback1.WaitForResult(); |
| 8899 EXPECT_EQ(OK, rv); | 8851 EXPECT_EQ(OK, rv); |
| 8900 | 8852 |
| 8901 const HttpResponseInfo* response = trans->GetResponseInfo(); | 8853 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 8902 ASSERT_TRUE(response != NULL); | 8854 ASSERT_TRUE(response != NULL); |
| 8903 | 8855 |
| 8904 EXPECT_TRUE(response->headers->IsKeepAlive()); | 8856 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 8905 EXPECT_EQ(200, response->headers->response_code()); | 8857 EXPECT_EQ(200, response->headers->response_code()); |
| 8906 EXPECT_EQ(100, response->headers->GetContentLength()); | 8858 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 8907 EXPECT_TRUE(response->was_fetched_via_proxy); | 8859 EXPECT_TRUE(response->was_fetched_via_proxy); |
| 8908 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 8860 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 8909 } | 8861 } |
| 8910 | 8862 |
| 8911 // Test a basic HTTPS GET request through a proxy. | 8863 // Test a basic HTTPS GET request through a proxy. |
| 8912 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGet) { | 8864 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGet) { |
| 8913 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8865 SpdySessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 8914 CapturingBoundNetLog log; | 8866 CapturingBoundNetLog log; |
| 8915 session_deps.net_log = log.bound().net_log(); | 8867 session_deps.net_log = log.bound().net_log(); |
| 8916 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8868 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8917 | 8869 |
| 8918 HttpRequestInfo request; | 8870 HttpRequestInfo request; |
| 8919 request.method = "GET"; | 8871 request.method = "GET"; |
| 8920 request.url = GURL("https://www.google.com/"); | 8872 request.url = GURL("https://www.google.com/"); |
| 8921 | 8873 |
| 8922 // Since we have proxy, should try to establish tunnel. | 8874 // Since we have proxy, should try to establish tunnel. |
| 8923 MockWrite data_writes1[] = { | 8875 MockWrite data_writes1[] = { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 8934 MockRead("HTTP/1.1 200 Connection Established\r\n\r\n"), | 8886 MockRead("HTTP/1.1 200 Connection Established\r\n\r\n"), |
| 8935 | 8887 |
| 8936 MockRead("HTTP/1.1 200 OK\r\n"), | 8888 MockRead("HTTP/1.1 200 OK\r\n"), |
| 8937 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), | 8889 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), |
| 8938 MockRead("Content-Length: 100\r\n\r\n"), | 8890 MockRead("Content-Length: 100\r\n\r\n"), |
| 8939 MockRead(SYNCHRONOUS, OK), | 8891 MockRead(SYNCHRONOUS, OK), |
| 8940 }; | 8892 }; |
| 8941 | 8893 |
| 8942 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 8894 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 8943 data_writes1, arraysize(data_writes1)); | 8895 data_writes1, arraysize(data_writes1)); |
| 8944 session_deps.socket_factory.AddSocketDataProvider(&data1); | 8896 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 8945 SSLSocketDataProvider ssl(ASYNC, OK); | 8897 SSLSocketDataProvider ssl(ASYNC, OK); |
| 8946 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 8898 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 8947 | 8899 |
| 8948 TestCompletionCallback callback1; | 8900 TestCompletionCallback callback1; |
| 8949 | 8901 |
| 8950 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8902 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 8951 | 8903 |
| 8952 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 8904 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 8953 EXPECT_EQ(ERR_IO_PENDING, rv); | 8905 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 8954 | 8906 |
| 8955 rv = callback1.WaitForResult(); | 8907 rv = callback1.WaitForResult(); |
| 8956 EXPECT_EQ(OK, rv); | 8908 EXPECT_EQ(OK, rv); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 8970 EXPECT_TRUE(response->headers->IsKeepAlive()); | 8922 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 8971 EXPECT_EQ(200, response->headers->response_code()); | 8923 EXPECT_EQ(200, response->headers->response_code()); |
| 8972 EXPECT_EQ(100, response->headers->GetContentLength()); | 8924 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 8973 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 8925 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 8974 EXPECT_TRUE(response->was_fetched_via_proxy); | 8926 EXPECT_TRUE(response->was_fetched_via_proxy); |
| 8975 } | 8927 } |
| 8976 | 8928 |
| 8977 // Test a basic HTTPS GET request through a proxy, but the server hangs up | 8929 // Test a basic HTTPS GET request through a proxy, but the server hangs up |
| 8978 // while establishing the tunnel. | 8930 // while establishing the tunnel. |
| 8979 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGetHangup) { | 8931 TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGetHangup) { |
| 8980 SessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); | 8932 SpdySessionDependencies session_deps(ProxyService::CreateFixed("myproxy:70")); |
| 8981 CapturingBoundNetLog log; | 8933 CapturingBoundNetLog log; |
| 8982 session_deps.net_log = log.bound().net_log(); | 8934 session_deps.net_log = log.bound().net_log(); |
| 8983 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 8935 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 8984 | 8936 |
| 8985 HttpRequestInfo request; | 8937 HttpRequestInfo request; |
| 8986 request.method = "GET"; | 8938 request.method = "GET"; |
| 8987 request.url = GURL("https://www.google.com/"); | 8939 request.url = GURL("https://www.google.com/"); |
| 8988 | 8940 |
| 8989 // Since we have proxy, should try to establish tunnel. | 8941 // Since we have proxy, should try to establish tunnel. |
| 8990 MockWrite data_writes1[] = { | 8942 MockWrite data_writes1[] = { |
| 8991 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" | 8943 MockWrite("CONNECT www.google.com:443 HTTP/1.1\r\n" |
| 8992 "Host: www.google.com\r\n" | 8944 "Host: www.google.com\r\n" |
| 8993 "Proxy-Connection: keep-alive\r\n\r\n"), | 8945 "Proxy-Connection: keep-alive\r\n\r\n"), |
| 8994 | 8946 |
| 8995 MockWrite("GET / HTTP/1.1\r\n" | 8947 MockWrite("GET / HTTP/1.1\r\n" |
| 8996 "Host: www.google.com\r\n" | 8948 "Host: www.google.com\r\n" |
| 8997 "Connection: keep-alive\r\n\r\n"), | 8949 "Connection: keep-alive\r\n\r\n"), |
| 8998 }; | 8950 }; |
| 8999 | 8951 |
| 9000 MockRead data_reads1[] = { | 8952 MockRead data_reads1[] = { |
| 9001 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 8953 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 9002 MockRead("HTTP/1.1 200 Connection Established\r\n\r\n"), | 8954 MockRead("HTTP/1.1 200 Connection Established\r\n\r\n"), |
| 9003 MockRead(ASYNC, 0, 0), // EOF | 8955 MockRead(ASYNC, 0, 0), // EOF |
| 9004 }; | 8956 }; |
| 9005 | 8957 |
| 9006 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), | 8958 StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), |
| 9007 data_writes1, arraysize(data_writes1)); | 8959 data_writes1, arraysize(data_writes1)); |
| 9008 session_deps.socket_factory.AddSocketDataProvider(&data1); | 8960 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 9009 SSLSocketDataProvider ssl(ASYNC, OK); | 8961 SSLSocketDataProvider ssl(ASYNC, OK); |
| 9010 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 8962 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 9011 | 8963 |
| 9012 TestCompletionCallback callback1; | 8964 TestCompletionCallback callback1; |
| 9013 | 8965 |
| 9014 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); | 8966 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); |
| 9015 | 8967 |
| 9016 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 8968 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 9017 EXPECT_EQ(ERR_IO_PENDING, rv); | 8969 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9018 | 8970 |
| 9019 rv = callback1.WaitForResult(); | 8971 rv = callback1.WaitForResult(); |
| 9020 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); | 8972 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); |
| 9021 net::CapturingNetLog::CapturedEntryList entries; | 8973 net::CapturingNetLog::CapturedEntryList entries; |
| 9022 log.GetEntries(&entries); | 8974 log.GetEntries(&entries); |
| 9023 size_t pos = ExpectLogContainsSomewhere( | 8975 size_t pos = ExpectLogContainsSomewhere( |
| 9024 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 8976 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 9025 NetLog::PHASE_NONE); | 8977 NetLog::PHASE_NONE); |
| 9026 ExpectLogContainsSomewhere( | 8978 ExpectLogContainsSomewhere( |
| 9027 entries, pos, | 8979 entries, pos, |
| 9028 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 8980 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 9029 NetLog::PHASE_NONE); | 8981 NetLog::PHASE_NONE); |
| 9030 } | 8982 } |
| 9031 | 8983 |
| 9032 // Test for crbug.com/55424. | 8984 // Test for crbug.com/55424. |
| 9033 TEST_F(HttpNetworkTransactionSpdy2Test, PreconnectWithExistingSpdySession) { | 8985 TEST_F(HttpNetworkTransactionSpdy2Test, PreconnectWithExistingSpdySession) { |
| 9034 SessionDependencies session_deps; | 8986 SpdySessionDependencies session_deps; |
| 9035 | 8987 |
| 9036 scoped_ptr<SpdyFrame> req(ConstructSpdyGet( | 8988 scoped_ptr<SpdyFrame> req(ConstructSpdyGet( |
| 9037 "https://www.google.com", false, 1, LOWEST)); | 8989 "https://www.google.com", false, 1, LOWEST)); |
| 9038 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; | 8990 MockWrite spdy_writes[] = { CreateMockWrite(*req) }; |
| 9039 | 8991 |
| 9040 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 8992 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 9041 scoped_ptr<SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); | 8993 scoped_ptr<SpdyFrame> data(ConstructSpdyBodyFrame(1, true)); |
| 9042 MockRead spdy_reads[] = { | 8994 MockRead spdy_reads[] = { |
| 9043 CreateMockRead(*resp), | 8995 CreateMockRead(*resp), |
| 9044 CreateMockRead(*data), | 8996 CreateMockRead(*data), |
| 9045 MockRead(ASYNC, 0, 0), | 8997 MockRead(ASYNC, 0, 0), |
| 9046 }; | 8998 }; |
| 9047 | 8999 |
| 9048 DelayedSocketData spdy_data( | 9000 DelayedSocketData spdy_data( |
| 9049 1, // wait for one write to finish before reading. | 9001 1, // wait for one write to finish before reading. |
| 9050 spdy_reads, arraysize(spdy_reads), | 9002 spdy_reads, arraysize(spdy_reads), |
| 9051 spdy_writes, arraysize(spdy_writes)); | 9003 spdy_writes, arraysize(spdy_writes)); |
| 9052 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 9004 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 9053 | 9005 |
| 9054 SSLSocketDataProvider ssl(ASYNC, OK); | 9006 SSLSocketDataProvider ssl(ASYNC, OK); |
| 9055 ssl.SetNextProto(kProtoSPDY2); | 9007 ssl.SetNextProto(kProtoSPDY2); |
| 9056 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 9008 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 9057 | 9009 |
| 9058 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 9010 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 9059 | 9011 |
| 9060 // Set up an initial SpdySession in the pool to reuse. | 9012 // Set up an initial SpdySession in the pool to reuse. |
| 9061 HostPortPair host_port_pair("www.google.com", 443); | 9013 HostPortPair host_port_pair("www.google.com", 443); |
| 9062 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | 9014 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); |
| 9063 scoped_refptr<SpdySession> spdy_session = | 9015 scoped_refptr<SpdySession> spdy_session = |
| 9064 session->spdy_session_pool()->Get(pair, BoundNetLog()); | 9016 session->spdy_session_pool()->Get(pair, BoundNetLog()); |
| 9065 scoped_refptr<TransportSocketParams> transport_params( | 9017 scoped_refptr<TransportSocketParams> transport_params( |
| 9066 new TransportSocketParams(host_port_pair, MEDIUM, false, false, | 9018 new TransportSocketParams(host_port_pair, MEDIUM, false, false, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 9095 } | 9047 } |
| 9096 | 9048 |
| 9097 // Given a net error, cause that error to be returned from the first Write() | 9049 // Given a net error, cause that error to be returned from the first Write() |
| 9098 // call and verify that the HttpTransaction fails with that error. | 9050 // call and verify that the HttpTransaction fails with that error. |
| 9099 static void CheckErrorIsPassedBack(int error, IoMode mode) { | 9051 static void CheckErrorIsPassedBack(int error, IoMode mode) { |
| 9100 net::HttpRequestInfo request_info; | 9052 net::HttpRequestInfo request_info; |
| 9101 request_info.url = GURL("https://www.example.com/"); | 9053 request_info.url = GURL("https://www.example.com/"); |
| 9102 request_info.method = "GET"; | 9054 request_info.method = "GET"; |
| 9103 request_info.load_flags = net::LOAD_NORMAL; | 9055 request_info.load_flags = net::LOAD_NORMAL; |
| 9104 | 9056 |
| 9105 SessionDependencies session_deps; | 9057 SpdySessionDependencies session_deps; |
| 9106 | 9058 |
| 9107 SSLSocketDataProvider ssl_data(mode, OK); | 9059 SSLSocketDataProvider ssl_data(mode, OK); |
| 9108 net::MockWrite data_writes[] = { | 9060 net::MockWrite data_writes[] = { |
| 9109 net::MockWrite(mode, error), | 9061 net::MockWrite(mode, error), |
| 9110 }; | 9062 }; |
| 9111 net::StaticSocketDataProvider data(NULL, 0, | 9063 net::StaticSocketDataProvider data(NULL, 0, |
| 9112 data_writes, arraysize(data_writes)); | 9064 data_writes, arraysize(data_writes)); |
| 9113 session_deps.socket_factory.AddSocketDataProvider(&data); | 9065 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 9114 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data); | 9066 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_data); |
| 9115 | 9067 |
| 9116 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 9068 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 9117 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 9069 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 9118 | 9070 |
| 9119 TestCompletionCallback callback; | 9071 TestCompletionCallback callback; |
| 9120 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 9072 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
| 9121 if (rv == net::ERR_IO_PENDING) | 9073 if (rv == net::ERR_IO_PENDING) |
| 9122 rv = callback.WaitForResult(); | 9074 rv = callback.WaitForResult(); |
| 9123 ASSERT_EQ(error, rv); | 9075 ASSERT_EQ(error, rv); |
| 9124 } | 9076 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 9142 // 2) TLS False Start is disabled. | 9094 // 2) TLS False Start is disabled. |
| 9143 // 3) The initial TLS handshake requests a client certificate. | 9095 // 3) The initial TLS handshake requests a client certificate. |
| 9144 // 4) The client supplies an invalid/unacceptable certificate. | 9096 // 4) The client supplies an invalid/unacceptable certificate. |
| 9145 TEST_F(HttpNetworkTransactionSpdy2Test, | 9097 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 9146 ClientAuthCertCache_Direct_NoFalseStart) { | 9098 ClientAuthCertCache_Direct_NoFalseStart) { |
| 9147 net::HttpRequestInfo request_info; | 9099 net::HttpRequestInfo request_info; |
| 9148 request_info.url = GURL("https://www.example.com/"); | 9100 request_info.url = GURL("https://www.example.com/"); |
| 9149 request_info.method = "GET"; | 9101 request_info.method = "GET"; |
| 9150 request_info.load_flags = net::LOAD_NORMAL; | 9102 request_info.load_flags = net::LOAD_NORMAL; |
| 9151 | 9103 |
| 9152 SessionDependencies session_deps; | 9104 SpdySessionDependencies session_deps; |
| 9153 | 9105 |
| 9154 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); | 9106 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); |
| 9155 cert_request->host_and_port = "www.example.com:443"; | 9107 cert_request->host_and_port = "www.example.com:443"; |
| 9156 | 9108 |
| 9157 // [ssl_]data1 contains the data for the first SSL handshake. When a | 9109 // [ssl_]data1 contains the data for the first SSL handshake. When a |
| 9158 // CertificateRequest is received for the first time, the handshake will | 9110 // CertificateRequest is received for the first time, the handshake will |
| 9159 // be aborted to allow the caller to provide a certificate. | 9111 // be aborted to allow the caller to provide a certificate. |
| 9160 SSLSocketDataProvider ssl_data1(ASYNC, net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED); | 9112 SSLSocketDataProvider ssl_data1(ASYNC, net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED); |
| 9161 ssl_data1.cert_request_info = cert_request.get(); | 9113 ssl_data1.cert_request_info = cert_request.get(); |
| 9162 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data1); | 9114 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_data1); |
| 9163 net::StaticSocketDataProvider data1(NULL, 0, NULL, 0); | 9115 net::StaticSocketDataProvider data1(NULL, 0, NULL, 0); |
| 9164 session_deps.socket_factory.AddSocketDataProvider(&data1); | 9116 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 9165 | 9117 |
| 9166 // [ssl_]data2 contains the data for the second SSL handshake. When TLS | 9118 // [ssl_]data2 contains the data for the second SSL handshake. When TLS |
| 9167 // False Start is not being used, the result of the SSL handshake will be | 9119 // False Start is not being used, the result of the SSL handshake will be |
| 9168 // returned as part of the SSLClientSocket::Connect() call. This test | 9120 // returned as part of the SSLClientSocket::Connect() call. This test |
| 9169 // matches the result of a server sending a handshake_failure alert, | 9121 // matches the result of a server sending a handshake_failure alert, |
| 9170 // rather than a Finished message, because it requires a client | 9122 // rather than a Finished message, because it requires a client |
| 9171 // certificate and none was supplied. | 9123 // certificate and none was supplied. |
| 9172 SSLSocketDataProvider ssl_data2(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); | 9124 SSLSocketDataProvider ssl_data2(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); |
| 9173 ssl_data2.cert_request_info = cert_request.get(); | 9125 ssl_data2.cert_request_info = cert_request.get(); |
| 9174 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data2); | 9126 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_data2); |
| 9175 net::StaticSocketDataProvider data2(NULL, 0, NULL, 0); | 9127 net::StaticSocketDataProvider data2(NULL, 0, NULL, 0); |
| 9176 session_deps.socket_factory.AddSocketDataProvider(&data2); | 9128 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 9177 | 9129 |
| 9178 // [ssl_]data3 contains the data for the third SSL handshake. When a | 9130 // [ssl_]data3 contains the data for the third SSL handshake. When a |
| 9179 // connection to a server fails during an SSL handshake, | 9131 // connection to a server fails during an SSL handshake, |
| 9180 // HttpNetworkTransaction will attempt to fallback to TLSv1 if the previous | 9132 // HttpNetworkTransaction will attempt to fallback to TLSv1 if the previous |
| 9181 // connection was attempted with TLSv1.1. This is transparent to the caller | 9133 // connection was attempted with TLSv1.1. This is transparent to the caller |
| 9182 // of the HttpNetworkTransaction. Because this test failure is due to | 9134 // of the HttpNetworkTransaction. Because this test failure is due to |
| 9183 // requiring a client certificate, this fallback handshake should also | 9135 // requiring a client certificate, this fallback handshake should also |
| 9184 // fail. | 9136 // fail. |
| 9185 SSLSocketDataProvider ssl_data3(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); | 9137 SSLSocketDataProvider ssl_data3(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); |
| 9186 ssl_data3.cert_request_info = cert_request.get(); | 9138 ssl_data3.cert_request_info = cert_request.get(); |
| 9187 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data3); | 9139 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_data3); |
| 9188 net::StaticSocketDataProvider data3(NULL, 0, NULL, 0); | 9140 net::StaticSocketDataProvider data3(NULL, 0, NULL, 0); |
| 9189 session_deps.socket_factory.AddSocketDataProvider(&data3); | 9141 session_deps.socket_factory->AddSocketDataProvider(&data3); |
| 9190 | 9142 |
| 9191 // [ssl_]data4 contains the data for the fourth SSL handshake. When a | 9143 // [ssl_]data4 contains the data for the fourth SSL handshake. When a |
| 9192 // connection to a server fails during an SSL handshake, | 9144 // connection to a server fails during an SSL handshake, |
| 9193 // HttpNetworkTransaction will attempt to fallback to SSLv3 if the previous | 9145 // HttpNetworkTransaction will attempt to fallback to SSLv3 if the previous |
| 9194 // connection was attempted with TLSv1. This is transparent to the caller | 9146 // connection was attempted with TLSv1. This is transparent to the caller |
| 9195 // of the HttpNetworkTransaction. Because this test failure is due to | 9147 // of the HttpNetworkTransaction. Because this test failure is due to |
| 9196 // requiring a client certificate, this fallback handshake should also | 9148 // requiring a client certificate, this fallback handshake should also |
| 9197 // fail. | 9149 // fail. |
| 9198 SSLSocketDataProvider ssl_data4(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); | 9150 SSLSocketDataProvider ssl_data4(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); |
| 9199 ssl_data4.cert_request_info = cert_request.get(); | 9151 ssl_data4.cert_request_info = cert_request.get(); |
| 9200 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data4); | 9152 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_data4); |
| 9201 net::StaticSocketDataProvider data4(NULL, 0, NULL, 0); | 9153 net::StaticSocketDataProvider data4(NULL, 0, NULL, 0); |
| 9202 session_deps.socket_factory.AddSocketDataProvider(&data4); | 9154 session_deps.socket_factory->AddSocketDataProvider(&data4); |
| 9203 | 9155 |
| 9204 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 9156 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 9205 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 9157 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 9206 | 9158 |
| 9207 // Begin the SSL handshake with the peer. This consumes ssl_data1. | 9159 // Begin the SSL handshake with the peer. This consumes ssl_data1. |
| 9208 TestCompletionCallback callback; | 9160 TestCompletionCallback callback; |
| 9209 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 9161 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
| 9210 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 9162 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
| 9211 | 9163 |
| 9212 // Complete the SSL handshake, which should abort due to requiring a | 9164 // Complete the SSL handshake, which should abort due to requiring a |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9246 // 2) TLS False Start is enabled. | 9198 // 2) TLS False Start is enabled. |
| 9247 // 3) The initial TLS handshake requests a client certificate. | 9199 // 3) The initial TLS handshake requests a client certificate. |
| 9248 // 4) The client supplies an invalid/unacceptable certificate. | 9200 // 4) The client supplies an invalid/unacceptable certificate. |
| 9249 TEST_F(HttpNetworkTransactionSpdy2Test, | 9201 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 9250 ClientAuthCertCache_Direct_FalseStart) { | 9202 ClientAuthCertCache_Direct_FalseStart) { |
| 9251 net::HttpRequestInfo request_info; | 9203 net::HttpRequestInfo request_info; |
| 9252 request_info.url = GURL("https://www.example.com/"); | 9204 request_info.url = GURL("https://www.example.com/"); |
| 9253 request_info.method = "GET"; | 9205 request_info.method = "GET"; |
| 9254 request_info.load_flags = net::LOAD_NORMAL; | 9206 request_info.load_flags = net::LOAD_NORMAL; |
| 9255 | 9207 |
| 9256 SessionDependencies session_deps; | 9208 SpdySessionDependencies session_deps; |
| 9257 | 9209 |
| 9258 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); | 9210 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); |
| 9259 cert_request->host_and_port = "www.example.com:443"; | 9211 cert_request->host_and_port = "www.example.com:443"; |
| 9260 | 9212 |
| 9261 // When TLS False Start is used, SSLClientSocket::Connect() calls will | 9213 // When TLS False Start is used, SSLClientSocket::Connect() calls will |
| 9262 // return successfully after reading up to the peer's Certificate message. | 9214 // return successfully after reading up to the peer's Certificate message. |
| 9263 // This is to allow the caller to call SSLClientSocket::Write(), which can | 9215 // This is to allow the caller to call SSLClientSocket::Write(), which can |
| 9264 // enqueue application data to be sent in the same packet as the | 9216 // enqueue application data to be sent in the same packet as the |
| 9265 // ChangeCipherSpec and Finished messages. | 9217 // ChangeCipherSpec and Finished messages. |
| 9266 // The actual handshake will be finished when SSLClientSocket::Read() is | 9218 // The actual handshake will be finished when SSLClientSocket::Read() is |
| 9267 // called, which expects to process the peer's ChangeCipherSpec and | 9219 // called, which expects to process the peer's ChangeCipherSpec and |
| 9268 // Finished messages. If there was an error negotiating with the peer, | 9220 // Finished messages. If there was an error negotiating with the peer, |
| 9269 // such as due to the peer requiring a client certificate when none was | 9221 // such as due to the peer requiring a client certificate when none was |
| 9270 // supplied, the alert sent by the peer won't be processed until Read() is | 9222 // supplied, the alert sent by the peer won't be processed until Read() is |
| 9271 // called. | 9223 // called. |
| 9272 | 9224 |
| 9273 // Like the non-False Start case, when a client certificate is requested by | 9225 // Like the non-False Start case, when a client certificate is requested by |
| 9274 // the peer, the handshake is aborted during the Connect() call. | 9226 // the peer, the handshake is aborted during the Connect() call. |
| 9275 // [ssl_]data1 represents the initial SSL handshake with the peer. | 9227 // [ssl_]data1 represents the initial SSL handshake with the peer. |
| 9276 SSLSocketDataProvider ssl_data1(ASYNC, net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED); | 9228 SSLSocketDataProvider ssl_data1(ASYNC, net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED); |
| 9277 ssl_data1.cert_request_info = cert_request.get(); | 9229 ssl_data1.cert_request_info = cert_request.get(); |
| 9278 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data1); | 9230 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_data1); |
| 9279 net::StaticSocketDataProvider data1(NULL, 0, NULL, 0); | 9231 net::StaticSocketDataProvider data1(NULL, 0, NULL, 0); |
| 9280 session_deps.socket_factory.AddSocketDataProvider(&data1); | 9232 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 9281 | 9233 |
| 9282 // When a client certificate is supplied, Connect() will not be aborted | 9234 // When a client certificate is supplied, Connect() will not be aborted |
| 9283 // when the peer requests the certificate. Instead, the handshake will | 9235 // when the peer requests the certificate. Instead, the handshake will |
| 9284 // artificially succeed, allowing the caller to write the HTTP request to | 9236 // artificially succeed, allowing the caller to write the HTTP request to |
| 9285 // the socket. The handshake messages are not processed until Read() is | 9237 // the socket. The handshake messages are not processed until Read() is |
| 9286 // called, which then detects that the handshake was aborted, due to the | 9238 // called, which then detects that the handshake was aborted, due to the |
| 9287 // peer sending a handshake_failure because it requires a client | 9239 // peer sending a handshake_failure because it requires a client |
| 9288 // certificate. | 9240 // certificate. |
| 9289 SSLSocketDataProvider ssl_data2(ASYNC, net::OK); | 9241 SSLSocketDataProvider ssl_data2(ASYNC, net::OK); |
| 9290 ssl_data2.cert_request_info = cert_request.get(); | 9242 ssl_data2.cert_request_info = cert_request.get(); |
| 9291 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data2); | 9243 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_data2); |
| 9292 net::MockRead data2_reads[] = { | 9244 net::MockRead data2_reads[] = { |
| 9293 net::MockRead(ASYNC /* async */, net::ERR_SSL_PROTOCOL_ERROR), | 9245 net::MockRead(ASYNC /* async */, net::ERR_SSL_PROTOCOL_ERROR), |
| 9294 }; | 9246 }; |
| 9295 net::StaticSocketDataProvider data2( | 9247 net::StaticSocketDataProvider data2( |
| 9296 data2_reads, arraysize(data2_reads), NULL, 0); | 9248 data2_reads, arraysize(data2_reads), NULL, 0); |
| 9297 session_deps.socket_factory.AddSocketDataProvider(&data2); | 9249 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 9298 | 9250 |
| 9299 // As described in ClientAuthCertCache_Direct_NoFalseStart, [ssl_]data3 is | 9251 // As described in ClientAuthCertCache_Direct_NoFalseStart, [ssl_]data3 is |
| 9300 // the data for the SSL handshake once the TLSv1.1 connection falls back to | 9252 // the data for the SSL handshake once the TLSv1.1 connection falls back to |
| 9301 // TLSv1. It has the same behaviour as [ssl_]data2. | 9253 // TLSv1. It has the same behaviour as [ssl_]data2. |
| 9302 SSLSocketDataProvider ssl_data3(ASYNC, net::OK); | 9254 SSLSocketDataProvider ssl_data3(ASYNC, net::OK); |
| 9303 ssl_data3.cert_request_info = cert_request.get(); | 9255 ssl_data3.cert_request_info = cert_request.get(); |
| 9304 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data3); | 9256 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_data3); |
| 9305 net::StaticSocketDataProvider data3( | 9257 net::StaticSocketDataProvider data3( |
| 9306 data2_reads, arraysize(data2_reads), NULL, 0); | 9258 data2_reads, arraysize(data2_reads), NULL, 0); |
| 9307 session_deps.socket_factory.AddSocketDataProvider(&data3); | 9259 session_deps.socket_factory->AddSocketDataProvider(&data3); |
| 9308 | 9260 |
| 9309 // [ssl_]data4 is the data for the SSL handshake once the TLSv1 connection | 9261 // [ssl_]data4 is the data for the SSL handshake once the TLSv1 connection |
| 9310 // falls back to SSLv3. It has the same behaviour as [ssl_]data2. | 9262 // falls back to SSLv3. It has the same behaviour as [ssl_]data2. |
| 9311 SSLSocketDataProvider ssl_data4(ASYNC, net::OK); | 9263 SSLSocketDataProvider ssl_data4(ASYNC, net::OK); |
| 9312 ssl_data4.cert_request_info = cert_request.get(); | 9264 ssl_data4.cert_request_info = cert_request.get(); |
| 9313 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data4); | 9265 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_data4); |
| 9314 net::StaticSocketDataProvider data4( | 9266 net::StaticSocketDataProvider data4( |
| 9315 data2_reads, arraysize(data2_reads), NULL, 0); | 9267 data2_reads, arraysize(data2_reads), NULL, 0); |
| 9316 session_deps.socket_factory.AddSocketDataProvider(&data4); | 9268 session_deps.socket_factory->AddSocketDataProvider(&data4); |
| 9317 | 9269 |
| 9318 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 9270 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 9319 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 9271 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 9320 | 9272 |
| 9321 // Begin the initial SSL handshake. | 9273 // Begin the initial SSL handshake. |
| 9322 TestCompletionCallback callback; | 9274 TestCompletionCallback callback; |
| 9323 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); | 9275 int rv = trans->Start(&request_info, callback.callback(), net::BoundNetLog()); |
| 9324 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 9276 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
| 9325 | 9277 |
| 9326 // Complete the SSL handshake, which should abort due to requiring a | 9278 // Complete the SSL handshake, which should abort due to requiring a |
| (...skipping 30 matching lines...) Expand all Loading... |
| 9357 | 9309 |
| 9358 // Ensure that a client certificate is removed from the SSL client auth | 9310 // Ensure that a client certificate is removed from the SSL client auth |
| 9359 // cache when: | 9311 // cache when: |
| 9360 // 1) An HTTPS proxy is involved. | 9312 // 1) An HTTPS proxy is involved. |
| 9361 // 3) The HTTPS proxy requests a client certificate. | 9313 // 3) The HTTPS proxy requests a client certificate. |
| 9362 // 4) The client supplies an invalid/unacceptable certificate for the | 9314 // 4) The client supplies an invalid/unacceptable certificate for the |
| 9363 // proxy. | 9315 // proxy. |
| 9364 // The test is repeated twice, first for connecting to an HTTPS endpoint, | 9316 // The test is repeated twice, first for connecting to an HTTPS endpoint, |
| 9365 // then for connecting to an HTTP endpoint. | 9317 // then for connecting to an HTTP endpoint. |
| 9366 TEST_F(HttpNetworkTransactionSpdy2Test, ClientAuthCertCache_Proxy_Fail) { | 9318 TEST_F(HttpNetworkTransactionSpdy2Test, ClientAuthCertCache_Proxy_Fail) { |
| 9367 SessionDependencies session_deps( | 9319 SpdySessionDependencies session_deps( |
| 9368 ProxyService::CreateFixed("https://proxy:70")); | 9320 ProxyService::CreateFixed("https://proxy:70")); |
| 9369 CapturingBoundNetLog log; | 9321 CapturingBoundNetLog log; |
| 9370 session_deps.net_log = log.bound().net_log(); | 9322 session_deps.net_log = log.bound().net_log(); |
| 9371 | 9323 |
| 9372 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); | 9324 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo()); |
| 9373 cert_request->host_and_port = "proxy:70"; | 9325 cert_request->host_and_port = "proxy:70"; |
| 9374 | 9326 |
| 9375 // See ClientAuthCertCache_Direct_NoFalseStart for the explanation of | 9327 // See ClientAuthCertCache_Direct_NoFalseStart for the explanation of |
| 9376 // [ssl_]data[1-3]. Rather than represending the endpoint | 9328 // [ssl_]data[1-3]. Rather than represending the endpoint |
| 9377 // (www.example.com:443), they represent failures with the HTTPS proxy | 9329 // (www.example.com:443), they represent failures with the HTTPS proxy |
| 9378 // (proxy:70). | 9330 // (proxy:70). |
| 9379 SSLSocketDataProvider ssl_data1(ASYNC, net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED); | 9331 SSLSocketDataProvider ssl_data1(ASYNC, net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED); |
| 9380 ssl_data1.cert_request_info = cert_request.get(); | 9332 ssl_data1.cert_request_info = cert_request.get(); |
| 9381 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data1); | 9333 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_data1); |
| 9382 net::StaticSocketDataProvider data1(NULL, 0, NULL, 0); | 9334 net::StaticSocketDataProvider data1(NULL, 0, NULL, 0); |
| 9383 session_deps.socket_factory.AddSocketDataProvider(&data1); | 9335 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 9384 | 9336 |
| 9385 SSLSocketDataProvider ssl_data2(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); | 9337 SSLSocketDataProvider ssl_data2(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); |
| 9386 ssl_data2.cert_request_info = cert_request.get(); | 9338 ssl_data2.cert_request_info = cert_request.get(); |
| 9387 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data2); | 9339 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_data2); |
| 9388 net::StaticSocketDataProvider data2(NULL, 0, NULL, 0); | 9340 net::StaticSocketDataProvider data2(NULL, 0, NULL, 0); |
| 9389 session_deps.socket_factory.AddSocketDataProvider(&data2); | 9341 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 9390 | 9342 |
| 9391 // TODO(wtc): find out why this unit test doesn't need [ssl_]data3. | 9343 // TODO(wtc): find out why this unit test doesn't need [ssl_]data3. |
| 9392 #if 0 | 9344 #if 0 |
| 9393 SSLSocketDataProvider ssl_data3(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); | 9345 SSLSocketDataProvider ssl_data3(ASYNC, net::ERR_SSL_PROTOCOL_ERROR); |
| 9394 ssl_data3.cert_request_info = cert_request.get(); | 9346 ssl_data3.cert_request_info = cert_request.get(); |
| 9395 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data3); | 9347 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl_data3); |
| 9396 net::StaticSocketDataProvider data3(NULL, 0, NULL, 0); | 9348 net::StaticSocketDataProvider data3(NULL, 0, NULL, 0); |
| 9397 session_deps.socket_factory.AddSocketDataProvider(&data3); | 9349 session_deps.socket_factory->AddSocketDataProvider(&data3); |
| 9398 #endif | 9350 #endif |
| 9399 | 9351 |
| 9400 net::HttpRequestInfo requests[2]; | 9352 net::HttpRequestInfo requests[2]; |
| 9401 requests[0].url = GURL("https://www.example.com/"); | 9353 requests[0].url = GURL("https://www.example.com/"); |
| 9402 requests[0].method = "GET"; | 9354 requests[0].method = "GET"; |
| 9403 requests[0].load_flags = net::LOAD_NORMAL; | 9355 requests[0].load_flags = net::LOAD_NORMAL; |
| 9404 | 9356 |
| 9405 requests[1].url = GURL("http://www.example.com/"); | 9357 requests[1].url = GURL("http://www.example.com/"); |
| 9406 requests[1].method = "GET"; | 9358 requests[1].method = "GET"; |
| 9407 requests[1].load_flags = net::LOAD_NORMAL; | 9359 requests[1].load_flags = net::LOAD_NORMAL; |
| 9408 | 9360 |
| 9409 for (size_t i = 0; i < arraysize(requests); ++i) { | 9361 for (size_t i = 0; i < arraysize(requests); ++i) { |
| 9410 session_deps.socket_factory.ResetNextMockIndexes(); | 9362 session_deps.socket_factory->ResetNextMockIndexes(); |
| 9411 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 9363 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 9412 scoped_ptr<HttpNetworkTransaction> trans( | 9364 scoped_ptr<HttpNetworkTransaction> trans( |
| 9413 new HttpNetworkTransaction(session)); | 9365 new HttpNetworkTransaction(session)); |
| 9414 | 9366 |
| 9415 // Begin the SSL handshake with the proxy. | 9367 // Begin the SSL handshake with the proxy. |
| 9416 TestCompletionCallback callback; | 9368 TestCompletionCallback callback; |
| 9417 int rv = trans->Start( | 9369 int rv = trans->Start( |
| 9418 &requests[i], callback.callback(), net::BoundNetLog()); | 9370 &requests[i], callback.callback(), net::BoundNetLog()); |
| 9419 ASSERT_EQ(net::ERR_IO_PENDING, rv); | 9371 ASSERT_EQ(net::ERR_IO_PENDING, rv); |
| 9420 | 9372 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9460 #if defined(OS_WIN) | 9412 #if defined(OS_WIN) |
| 9461 #define MAYBE_UseIPConnectionPooling DISABLED_UseIPConnectionPooling | 9413 #define MAYBE_UseIPConnectionPooling DISABLED_UseIPConnectionPooling |
| 9462 #else | 9414 #else |
| 9463 #define MAYBE_UseIPConnectionPooling UseIPConnectionPooling | 9415 #define MAYBE_UseIPConnectionPooling UseIPConnectionPooling |
| 9464 #endif | 9416 #endif |
| 9465 TEST_F(HttpNetworkTransactionSpdy2Test, MAYBE_UseIPConnectionPooling) { | 9417 TEST_F(HttpNetworkTransactionSpdy2Test, MAYBE_UseIPConnectionPooling) { |
| 9466 HttpStreamFactory::set_use_alternate_protocols(true); | 9418 HttpStreamFactory::set_use_alternate_protocols(true); |
| 9467 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 9419 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
| 9468 | 9420 |
| 9469 // Set up a special HttpNetworkSession with a MockCachingHostResolver. | 9421 // Set up a special HttpNetworkSession with a MockCachingHostResolver. |
| 9470 SessionDependencies session_deps; | 9422 SpdySessionDependencies session_deps; |
| 9471 MockCachingHostResolver host_resolver; | 9423 session_deps.host_resolver.reset(new MockCachingHostResolver()); |
| 9472 net::HttpNetworkSession::Params params; | 9424 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 9473 params.client_socket_factory = &session_deps.socket_factory; | |
| 9474 params.host_resolver = &host_resolver; | |
| 9475 params.cert_verifier = session_deps.cert_verifier.get(); | |
| 9476 params.proxy_service = session_deps.proxy_service.get(); | |
| 9477 params.ssl_config_service = session_deps.ssl_config_service; | |
| 9478 params.http_auth_handler_factory = | |
| 9479 session_deps.http_auth_handler_factory.get(); | |
| 9480 params.http_server_properties = &session_deps.http_server_properties; | |
| 9481 params.net_log = session_deps.net_log; | |
| 9482 scoped_refptr<HttpNetworkSession> session(new HttpNetworkSession(params)); | |
| 9483 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); | 9425 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); |
| 9484 pool_peer.DisableDomainAuthenticationVerification(); | 9426 pool_peer.DisableDomainAuthenticationVerification(); |
| 9485 pool_peer.EnableSendingInitialSettings(false); | |
| 9486 | 9427 |
| 9487 SSLSocketDataProvider ssl(ASYNC, OK); | 9428 SSLSocketDataProvider ssl(ASYNC, OK); |
| 9488 ssl.SetNextProto(kProtoSPDY2); | 9429 ssl.SetNextProto(kProtoSPDY2); |
| 9489 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 9430 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 9490 | 9431 |
| 9491 scoped_ptr<SpdyFrame> host1_req(ConstructSpdyGet( | 9432 scoped_ptr<SpdyFrame> host1_req(ConstructSpdyGet( |
| 9492 "https://www.google.com", false, 1, LOWEST)); | 9433 "https://www.google.com", false, 1, LOWEST)); |
| 9493 scoped_ptr<SpdyFrame> host2_req(ConstructSpdyGet( | 9434 scoped_ptr<SpdyFrame> host2_req(ConstructSpdyGet( |
| 9494 "https://www.gmail.com", false, 3, LOWEST)); | 9435 "https://www.gmail.com", false, 3, LOWEST)); |
| 9495 MockWrite spdy_writes[] = { | 9436 MockWrite spdy_writes[] = { |
| 9496 CreateMockWrite(*host1_req, 1), | 9437 CreateMockWrite(*host1_req, 1), |
| 9497 CreateMockWrite(*host2_req, 4), | 9438 CreateMockWrite(*host2_req, 4), |
| 9498 }; | 9439 }; |
| 9499 scoped_ptr<SpdyFrame> host1_resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 9440 scoped_ptr<SpdyFrame> host1_resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 9500 scoped_ptr<SpdyFrame> host1_resp_body(ConstructSpdyBodyFrame(1, true)); | 9441 scoped_ptr<SpdyFrame> host1_resp_body(ConstructSpdyBodyFrame(1, true)); |
| 9501 scoped_ptr<SpdyFrame> host2_resp(ConstructSpdyGetSynReply(NULL, 0, 3)); | 9442 scoped_ptr<SpdyFrame> host2_resp(ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 9502 scoped_ptr<SpdyFrame> host2_resp_body(ConstructSpdyBodyFrame(3, true)); | 9443 scoped_ptr<SpdyFrame> host2_resp_body(ConstructSpdyBodyFrame(3, true)); |
| 9503 MockRead spdy_reads[] = { | 9444 MockRead spdy_reads[] = { |
| 9504 CreateMockRead(*host1_resp, 2), | 9445 CreateMockRead(*host1_resp, 2), |
| 9505 CreateMockRead(*host1_resp_body, 3), | 9446 CreateMockRead(*host1_resp_body, 3), |
| 9506 CreateMockRead(*host2_resp, 5), | 9447 CreateMockRead(*host2_resp, 5), |
| 9507 CreateMockRead(*host2_resp_body, 6), | 9448 CreateMockRead(*host2_resp_body, 6), |
| 9508 MockRead(ASYNC, 0, 7), | 9449 MockRead(ASYNC, 0, 7), |
| 9509 }; | 9450 }; |
| 9510 | 9451 |
| 9511 IPAddressNumber ip; | 9452 IPAddressNumber ip; |
| 9512 ASSERT_TRUE(ParseIPLiteralToNumber("127.0.0.1", &ip)); | 9453 ASSERT_TRUE(ParseIPLiteralToNumber("127.0.0.1", &ip)); |
| 9513 IPEndPoint peer_addr = IPEndPoint(ip, 443); | 9454 IPEndPoint peer_addr = IPEndPoint(ip, 443); |
| 9514 MockConnect connect(ASYNC, OK, peer_addr); | 9455 MockConnect connect(ASYNC, OK, peer_addr); |
| 9515 OrderedSocketData spdy_data( | 9456 OrderedSocketData spdy_data( |
| 9516 connect, | 9457 connect, |
| 9517 spdy_reads, arraysize(spdy_reads), | 9458 spdy_reads, arraysize(spdy_reads), |
| 9518 spdy_writes, arraysize(spdy_writes)); | 9459 spdy_writes, arraysize(spdy_writes)); |
| 9519 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 9460 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 9520 | 9461 |
| 9521 TestCompletionCallback callback; | 9462 TestCompletionCallback callback; |
| 9522 HttpRequestInfo request1; | 9463 HttpRequestInfo request1; |
| 9523 request1.method = "GET"; | 9464 request1.method = "GET"; |
| 9524 request1.url = GURL("https://www.google.com/"); | 9465 request1.url = GURL("https://www.google.com/"); |
| 9525 request1.load_flags = 0; | 9466 request1.load_flags = 0; |
| 9526 HttpNetworkTransaction trans1(session); | 9467 HttpNetworkTransaction trans1(session); |
| 9527 | 9468 |
| 9528 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); | 9469 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); |
| 9529 EXPECT_EQ(ERR_IO_PENDING, rv); | 9470 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9530 EXPECT_EQ(OK, callback.WaitForResult()); | 9471 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9531 | 9472 |
| 9532 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 9473 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
| 9533 ASSERT_TRUE(response != NULL); | 9474 ASSERT_TRUE(response != NULL); |
| 9534 ASSERT_TRUE(response->headers != NULL); | 9475 ASSERT_TRUE(response->headers != NULL); |
| 9535 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9476 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9536 | 9477 |
| 9537 std::string response_data; | 9478 std::string response_data; |
| 9538 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 9479 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
| 9539 EXPECT_EQ("hello!", response_data); | 9480 EXPECT_EQ("hello!", response_data); |
| 9540 | 9481 |
| 9541 // Preload www.gmail.com into HostCache. | 9482 // Preload www.gmail.com into HostCache. |
| 9542 HostPortPair host_port("www.gmail.com", 443); | 9483 HostPortPair host_port("www.gmail.com", 443); |
| 9543 HostResolver::RequestInfo resolve_info(host_port); | 9484 HostResolver::RequestInfo resolve_info(host_port); |
| 9544 AddressList ignored; | 9485 AddressList ignored; |
| 9545 rv = host_resolver.Resolve(resolve_info, &ignored, callback.callback(), NULL, | 9486 rv = session_deps.host_resolver->Resolve(resolve_info, &ignored, |
| 9546 BoundNetLog()); | 9487 callback.callback(), NULL, |
| 9488 BoundNetLog()); |
| 9547 EXPECT_EQ(ERR_IO_PENDING, rv); | 9489 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9548 rv = callback.WaitForResult(); | 9490 rv = callback.WaitForResult(); |
| 9549 EXPECT_EQ(OK, rv); | 9491 EXPECT_EQ(OK, rv); |
| 9550 | 9492 |
| 9551 HttpRequestInfo request2; | 9493 HttpRequestInfo request2; |
| 9552 request2.method = "GET"; | 9494 request2.method = "GET"; |
| 9553 request2.url = GURL("https://www.gmail.com/"); | 9495 request2.url = GURL("https://www.gmail.com/"); |
| 9554 request2.load_flags = 0; | 9496 request2.load_flags = 0; |
| 9555 HttpNetworkTransaction trans2(session); | 9497 HttpNetworkTransaction trans2(session); |
| 9556 | 9498 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 9570 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); | 9512 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
| 9571 HttpStreamFactory::set_use_alternate_protocols(false); | 9513 HttpStreamFactory::set_use_alternate_protocols(false); |
| 9572 } | 9514 } |
| 9573 #undef MAYBE_UseIPConnectionPooling | 9515 #undef MAYBE_UseIPConnectionPooling |
| 9574 | 9516 |
| 9575 TEST_F(HttpNetworkTransactionSpdy2Test, UseIPConnectionPoolingAfterResolution) { | 9517 TEST_F(HttpNetworkTransactionSpdy2Test, UseIPConnectionPoolingAfterResolution) { |
| 9576 HttpStreamFactory::set_use_alternate_protocols(true); | 9518 HttpStreamFactory::set_use_alternate_protocols(true); |
| 9577 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 9519 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
| 9578 | 9520 |
| 9579 // Set up a special HttpNetworkSession with a MockCachingHostResolver. | 9521 // Set up a special HttpNetworkSession with a MockCachingHostResolver. |
| 9580 SessionDependencies session_deps; | 9522 SpdySessionDependencies session_deps; |
| 9581 MockCachingHostResolver host_resolver; | 9523 session_deps.host_resolver.reset(new MockCachingHostResolver()); |
| 9582 net::HttpNetworkSession::Params params; | 9524 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 9583 params.client_socket_factory = &session_deps.socket_factory; | |
| 9584 params.host_resolver = &host_resolver; | |
| 9585 params.cert_verifier = session_deps.cert_verifier.get(); | |
| 9586 params.proxy_service = session_deps.proxy_service.get(); | |
| 9587 params.ssl_config_service = session_deps.ssl_config_service; | |
| 9588 params.http_auth_handler_factory = | |
| 9589 session_deps.http_auth_handler_factory.get(); | |
| 9590 params.http_server_properties = &session_deps.http_server_properties; | |
| 9591 params.net_log = session_deps.net_log; | |
| 9592 scoped_refptr<HttpNetworkSession> session(new HttpNetworkSession(params)); | |
| 9593 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); | 9525 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); |
| 9594 pool_peer.DisableDomainAuthenticationVerification(); | 9526 pool_peer.DisableDomainAuthenticationVerification(); |
| 9595 pool_peer.EnableSendingInitialSettings(false); | |
| 9596 | 9527 |
| 9597 SSLSocketDataProvider ssl(ASYNC, OK); | 9528 SSLSocketDataProvider ssl(ASYNC, OK); |
| 9598 ssl.SetNextProto(kProtoSPDY2); | 9529 ssl.SetNextProto(kProtoSPDY2); |
| 9599 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 9530 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 9600 | 9531 |
| 9601 scoped_ptr<SpdyFrame> host1_req(ConstructSpdyGet( | 9532 scoped_ptr<SpdyFrame> host1_req(ConstructSpdyGet( |
| 9602 "https://www.google.com", false, 1, LOWEST)); | 9533 "https://www.google.com", false, 1, LOWEST)); |
| 9603 scoped_ptr<SpdyFrame> host2_req(ConstructSpdyGet( | 9534 scoped_ptr<SpdyFrame> host2_req(ConstructSpdyGet( |
| 9604 "https://www.gmail.com", false, 3, LOWEST)); | 9535 "https://www.gmail.com", false, 3, LOWEST)); |
| 9605 MockWrite spdy_writes[] = { | 9536 MockWrite spdy_writes[] = { |
| 9606 CreateMockWrite(*host1_req, 1), | 9537 CreateMockWrite(*host1_req, 1), |
| 9607 CreateMockWrite(*host2_req, 4), | 9538 CreateMockWrite(*host2_req, 4), |
| 9608 }; | 9539 }; |
| 9609 scoped_ptr<SpdyFrame> host1_resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 9540 scoped_ptr<SpdyFrame> host1_resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 9610 scoped_ptr<SpdyFrame> host1_resp_body(ConstructSpdyBodyFrame(1, true)); | 9541 scoped_ptr<SpdyFrame> host1_resp_body(ConstructSpdyBodyFrame(1, true)); |
| 9611 scoped_ptr<SpdyFrame> host2_resp(ConstructSpdyGetSynReply(NULL, 0, 3)); | 9542 scoped_ptr<SpdyFrame> host2_resp(ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 9612 scoped_ptr<SpdyFrame> host2_resp_body(ConstructSpdyBodyFrame(3, true)); | 9543 scoped_ptr<SpdyFrame> host2_resp_body(ConstructSpdyBodyFrame(3, true)); |
| 9613 MockRead spdy_reads[] = { | 9544 MockRead spdy_reads[] = { |
| 9614 CreateMockRead(*host1_resp, 2), | 9545 CreateMockRead(*host1_resp, 2), |
| 9615 CreateMockRead(*host1_resp_body, 3), | 9546 CreateMockRead(*host1_resp_body, 3), |
| 9616 CreateMockRead(*host2_resp, 5), | 9547 CreateMockRead(*host2_resp, 5), |
| 9617 CreateMockRead(*host2_resp_body, 6), | 9548 CreateMockRead(*host2_resp_body, 6), |
| 9618 MockRead(ASYNC, 0, 7), | 9549 MockRead(ASYNC, 0, 7), |
| 9619 }; | 9550 }; |
| 9620 | 9551 |
| 9621 IPAddressNumber ip; | 9552 IPAddressNumber ip; |
| 9622 ASSERT_TRUE(ParseIPLiteralToNumber("127.0.0.1", &ip)); | 9553 ASSERT_TRUE(ParseIPLiteralToNumber("127.0.0.1", &ip)); |
| 9623 IPEndPoint peer_addr = IPEndPoint(ip, 443); | 9554 IPEndPoint peer_addr = IPEndPoint(ip, 443); |
| 9624 MockConnect connect(ASYNC, OK, peer_addr); | 9555 MockConnect connect(ASYNC, OK, peer_addr); |
| 9625 OrderedSocketData spdy_data( | 9556 OrderedSocketData spdy_data( |
| 9626 connect, | 9557 connect, |
| 9627 spdy_reads, arraysize(spdy_reads), | 9558 spdy_reads, arraysize(spdy_reads), |
| 9628 spdy_writes, arraysize(spdy_writes)); | 9559 spdy_writes, arraysize(spdy_writes)); |
| 9629 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 9560 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 9630 | 9561 |
| 9631 TestCompletionCallback callback; | 9562 TestCompletionCallback callback; |
| 9632 HttpRequestInfo request1; | 9563 HttpRequestInfo request1; |
| 9633 request1.method = "GET"; | 9564 request1.method = "GET"; |
| 9634 request1.url = GURL("https://www.google.com/"); | 9565 request1.url = GURL("https://www.google.com/"); |
| 9635 request1.load_flags = 0; | 9566 request1.load_flags = 0; |
| 9636 HttpNetworkTransaction trans1(session); | 9567 HttpNetworkTransaction trans1(session); |
| 9637 | 9568 |
| 9638 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); | 9569 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); |
| 9639 EXPECT_EQ(ERR_IO_PENDING, rv); | 9570 EXPECT_EQ(ERR_IO_PENDING, rv); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9716 #define MAYBE_UseIPConnectionPoolingWithHostCacheExpiration DISABLED_UseIPConnec
tionPoolingWithHostCacheExpiration | 9647 #define MAYBE_UseIPConnectionPoolingWithHostCacheExpiration DISABLED_UseIPConnec
tionPoolingWithHostCacheExpiration |
| 9717 #else | 9648 #else |
| 9718 #define MAYBE_UseIPConnectionPoolingWithHostCacheExpiration UseIPConnectionPooli
ngWithHostCacheExpiration | 9649 #define MAYBE_UseIPConnectionPoolingWithHostCacheExpiration UseIPConnectionPooli
ngWithHostCacheExpiration |
| 9719 #endif | 9650 #endif |
| 9720 TEST_F(HttpNetworkTransactionSpdy2Test, | 9651 TEST_F(HttpNetworkTransactionSpdy2Test, |
| 9721 MAYBE_UseIPConnectionPoolingWithHostCacheExpiration) { | 9652 MAYBE_UseIPConnectionPoolingWithHostCacheExpiration) { |
| 9722 HttpStreamFactory::set_use_alternate_protocols(true); | 9653 HttpStreamFactory::set_use_alternate_protocols(true); |
| 9723 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); | 9654 HttpStreamFactory::SetNextProtos(SpdyNextProtos()); |
| 9724 | 9655 |
| 9725 // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver. | 9656 // Set up a special HttpNetworkSession with a OneTimeCachingHostResolver. |
| 9726 SessionDependencies session_deps; | |
| 9727 OneTimeCachingHostResolver host_resolver(HostPortPair("www.gmail.com", 443)); | 9657 OneTimeCachingHostResolver host_resolver(HostPortPair("www.gmail.com", 443)); |
| 9728 net::HttpNetworkSession::Params params; | 9658 SpdySessionDependencies session_deps; |
| 9729 params.client_socket_factory = &session_deps.socket_factory; | 9659 HttpNetworkSession::Params params = session_deps.CreateSessionParams(); |
| 9730 params.host_resolver = &host_resolver; | 9660 params.host_resolver = &host_resolver; |
| 9731 params.cert_verifier = session_deps.cert_verifier.get(); | 9661 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 9732 params.proxy_service = session_deps.proxy_service.get(); | |
| 9733 params.ssl_config_service = session_deps.ssl_config_service; | |
| 9734 params.http_auth_handler_factory = | |
| 9735 session_deps.http_auth_handler_factory.get(); | |
| 9736 params.http_server_properties = &session_deps.http_server_properties; | |
| 9737 params.net_log = session_deps.net_log; | |
| 9738 scoped_refptr<HttpNetworkSession> session(new HttpNetworkSession(params)); | |
| 9739 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); | 9662 SpdySessionPoolPeer pool_peer(session->spdy_session_pool()); |
| 9740 pool_peer.DisableDomainAuthenticationVerification(); | 9663 pool_peer.DisableDomainAuthenticationVerification(); |
| 9741 pool_peer.EnableSendingInitialSettings(false); | |
| 9742 | 9664 |
| 9743 SSLSocketDataProvider ssl(ASYNC, OK); | 9665 SSLSocketDataProvider ssl(ASYNC, OK); |
| 9744 ssl.SetNextProto(kProtoSPDY2); | 9666 ssl.SetNextProto(kProtoSPDY2); |
| 9745 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 9667 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 9746 | 9668 |
| 9747 scoped_ptr<SpdyFrame> host1_req(ConstructSpdyGet( | 9669 scoped_ptr<SpdyFrame> host1_req(ConstructSpdyGet( |
| 9748 "https://www.google.com", false, 1, LOWEST)); | 9670 "https://www.google.com", false, 1, LOWEST)); |
| 9749 scoped_ptr<SpdyFrame> host2_req(ConstructSpdyGet( | 9671 scoped_ptr<SpdyFrame> host2_req(ConstructSpdyGet( |
| 9750 "https://www.gmail.com", false, 3, LOWEST)); | 9672 "https://www.gmail.com", false, 3, LOWEST)); |
| 9751 MockWrite spdy_writes[] = { | 9673 MockWrite spdy_writes[] = { |
| 9752 CreateMockWrite(*host1_req, 1), | 9674 CreateMockWrite(*host1_req, 1), |
| 9753 CreateMockWrite(*host2_req, 4), | 9675 CreateMockWrite(*host2_req, 4), |
| 9754 }; | 9676 }; |
| 9755 scoped_ptr<SpdyFrame> host1_resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 9677 scoped_ptr<SpdyFrame> host1_resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 9756 scoped_ptr<SpdyFrame> host1_resp_body(ConstructSpdyBodyFrame(1, true)); | 9678 scoped_ptr<SpdyFrame> host1_resp_body(ConstructSpdyBodyFrame(1, true)); |
| 9757 scoped_ptr<SpdyFrame> host2_resp(ConstructSpdyGetSynReply(NULL, 0, 3)); | 9679 scoped_ptr<SpdyFrame> host2_resp(ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 9758 scoped_ptr<SpdyFrame> host2_resp_body(ConstructSpdyBodyFrame(3, true)); | 9680 scoped_ptr<SpdyFrame> host2_resp_body(ConstructSpdyBodyFrame(3, true)); |
| 9759 MockRead spdy_reads[] = { | 9681 MockRead spdy_reads[] = { |
| 9760 CreateMockRead(*host1_resp, 2), | 9682 CreateMockRead(*host1_resp, 2), |
| 9761 CreateMockRead(*host1_resp_body, 3), | 9683 CreateMockRead(*host1_resp_body, 3), |
| 9762 CreateMockRead(*host2_resp, 5), | 9684 CreateMockRead(*host2_resp, 5), |
| 9763 CreateMockRead(*host2_resp_body, 6), | 9685 CreateMockRead(*host2_resp_body, 6), |
| 9764 MockRead(ASYNC, 0, 7), | 9686 MockRead(ASYNC, 0, 7), |
| 9765 }; | 9687 }; |
| 9766 | 9688 |
| 9767 IPAddressNumber ip; | 9689 IPAddressNumber ip; |
| 9768 ASSERT_TRUE(ParseIPLiteralToNumber("127.0.0.1", &ip)); | 9690 ASSERT_TRUE(ParseIPLiteralToNumber("127.0.0.1", &ip)); |
| 9769 IPEndPoint peer_addr = IPEndPoint(ip, 443); | 9691 IPEndPoint peer_addr = IPEndPoint(ip, 443); |
| 9770 MockConnect connect(ASYNC, OK, peer_addr); | 9692 MockConnect connect(ASYNC, OK, peer_addr); |
| 9771 OrderedSocketData spdy_data( | 9693 OrderedSocketData spdy_data( |
| 9772 connect, | 9694 connect, |
| 9773 spdy_reads, arraysize(spdy_reads), | 9695 spdy_reads, arraysize(spdy_reads), |
| 9774 spdy_writes, arraysize(spdy_writes)); | 9696 spdy_writes, arraysize(spdy_writes)); |
| 9775 session_deps.socket_factory.AddSocketDataProvider(&spdy_data); | 9697 session_deps.socket_factory->AddSocketDataProvider(&spdy_data); |
| 9776 | 9698 |
| 9777 TestCompletionCallback callback; | 9699 TestCompletionCallback callback; |
| 9778 HttpRequestInfo request1; | 9700 HttpRequestInfo request1; |
| 9779 request1.method = "GET"; | 9701 request1.method = "GET"; |
| 9780 request1.url = GURL("https://www.google.com/"); | 9702 request1.url = GURL("https://www.google.com/"); |
| 9781 request1.load_flags = 0; | 9703 request1.load_flags = 0; |
| 9782 HttpNetworkTransaction trans1(session); | 9704 HttpNetworkTransaction trans1(session); |
| 9783 | 9705 |
| 9784 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); | 9706 int rv = trans1.Start(&request1, callback.callback(), BoundNetLog()); |
| 9785 EXPECT_EQ(ERR_IO_PENDING, rv); | 9707 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9786 EXPECT_EQ(OK, callback.WaitForResult()); | 9708 EXPECT_EQ(OK, callback.WaitForResult()); |
| 9787 | 9709 |
| 9788 const HttpResponseInfo* response = trans1.GetResponseInfo(); | 9710 const HttpResponseInfo* response = trans1.GetResponseInfo(); |
| 9789 ASSERT_TRUE(response != NULL); | 9711 ASSERT_TRUE(response != NULL); |
| 9790 ASSERT_TRUE(response->headers != NULL); | 9712 ASSERT_TRUE(response->headers != NULL); |
| 9791 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 9713 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 9792 | 9714 |
| 9793 std::string response_data; | 9715 std::string response_data; |
| 9794 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); | 9716 ASSERT_EQ(OK, ReadTransaction(&trans1, &response_data)); |
| 9795 EXPECT_EQ("hello!", response_data); | 9717 EXPECT_EQ("hello!", response_data); |
| 9796 | 9718 |
| 9797 // Preload cache entries into HostCache. | 9719 // Preload cache entries into HostCache. |
| 9798 HostResolver::RequestInfo resolve_info(HostPortPair("www.gmail.com", 443)); | 9720 HostResolver::RequestInfo resolve_info(HostPortPair("www.gmail.com", 443)); |
| 9799 AddressList ignored; | 9721 AddressList ignored; |
| 9800 rv = host_resolver.Resolve(resolve_info, &ignored, callback.callback(), NULL, | 9722 rv = host_resolver.Resolve(resolve_info, &ignored, callback.callback(), |
| 9801 BoundNetLog()); | 9723 NULL, BoundNetLog()); |
| 9802 EXPECT_EQ(ERR_IO_PENDING, rv); | 9724 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 9803 rv = callback.WaitForResult(); | 9725 rv = callback.WaitForResult(); |
| 9804 EXPECT_EQ(OK, rv); | 9726 EXPECT_EQ(OK, rv); |
| 9805 | 9727 |
| 9806 HttpRequestInfo request2; | 9728 HttpRequestInfo request2; |
| 9807 request2.method = "GET"; | 9729 request2.method = "GET"; |
| 9808 request2.url = GURL("https://www.gmail.com/"); | 9730 request2.url = GURL("https://www.gmail.com/"); |
| 9809 request2.load_flags = 0; | 9731 request2.load_flags = 0; |
| 9810 HttpNetworkTransaction trans2(session); | 9732 HttpNetworkTransaction trans2(session); |
| 9811 | 9733 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9911 MockRead reads2[] = { | 9833 MockRead reads2[] = { |
| 9912 MockRead(ASYNC, 5, "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), | 9834 MockRead(ASYNC, 5, "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), |
| 9913 MockRead(ASYNC, 6, "hello"), | 9835 MockRead(ASYNC, 6, "hello"), |
| 9914 MockRead(ASYNC, 7, OK), | 9836 MockRead(ASYNC, 7, OK), |
| 9915 }; | 9837 }; |
| 9916 | 9838 |
| 9917 DelayedSocketData data2( | 9839 DelayedSocketData data2( |
| 9918 1, reads2, arraysize(reads2), | 9840 1, reads2, arraysize(reads2), |
| 9919 writes2, arraysize(writes2)); | 9841 writes2, arraysize(writes2)); |
| 9920 | 9842 |
| 9921 SessionDependencies session_deps; | 9843 SpdySessionDependencies session_deps; |
| 9922 SSLSocketDataProvider ssl(ASYNC, OK); | 9844 SSLSocketDataProvider ssl(ASYNC, OK); |
| 9923 ssl.SetNextProto(kProtoSPDY2); | 9845 ssl.SetNextProto(kProtoSPDY2); |
| 9924 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 9846 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 9925 session_deps.socket_factory.AddSocketDataProvider(&data1); | 9847 session_deps.socket_factory->AddSocketDataProvider(&data1); |
| 9926 session_deps.socket_factory.AddSocketDataProvider(&data2); | 9848 session_deps.socket_factory->AddSocketDataProvider(&data2); |
| 9927 | 9849 |
| 9928 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 9850 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 9929 | 9851 |
| 9930 // Start the first transaction to set up the SpdySession | 9852 // Start the first transaction to set up the SpdySession |
| 9931 HttpRequestInfo request1; | 9853 HttpRequestInfo request1; |
| 9932 request1.method = "GET"; | 9854 request1.method = "GET"; |
| 9933 request1.url = GURL(https_url); | 9855 request1.url = GURL(https_url); |
| 9934 request1.priority = LOWEST; | 9856 request1.priority = LOWEST; |
| 9935 request1.load_flags = 0; | 9857 request1.load_flags = 0; |
| 9936 HttpNetworkTransaction trans1(session); | 9858 HttpNetworkTransaction trans1(session); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10080 CreateMockRead(*resp1, 2), | 10002 CreateMockRead(*resp1, 2), |
| 10081 CreateMockRead(*body1, 3), | 10003 CreateMockRead(*body1, 3), |
| 10082 CreateMockRead(*resp2, 5), | 10004 CreateMockRead(*resp2, 5), |
| 10083 CreateMockRead(*body2, 6), | 10005 CreateMockRead(*body2, 6), |
| 10084 MockRead(ASYNC, ERR_IO_PENDING, 7) | 10006 MockRead(ASYNC, ERR_IO_PENDING, 7) |
| 10085 }; | 10007 }; |
| 10086 | 10008 |
| 10087 OrderedSocketData data(reads, arraysize(reads), | 10009 OrderedSocketData data(reads, arraysize(reads), |
| 10088 writes, arraysize(writes)); | 10010 writes, arraysize(writes)); |
| 10089 | 10011 |
| 10090 SessionDependencies session_deps; | 10012 SpdySessionDependencies session_deps; |
| 10091 SSLSocketDataProvider ssl(ASYNC, OK); | 10013 SSLSocketDataProvider ssl(ASYNC, OK); |
| 10092 ssl.SetNextProto(kProtoSPDY2); | 10014 ssl.SetNextProto(kProtoSPDY2); |
| 10093 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); | 10015 session_deps.socket_factory->AddSSLSocketDataProvider(&ssl); |
| 10094 session_deps.socket_factory.AddSocketDataProvider(&data); | 10016 session_deps.socket_factory->AddSocketDataProvider(&data); |
| 10095 | 10017 |
| 10096 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); | 10018 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 10097 | 10019 |
| 10098 // Start the first transaction to set up the SpdySession | 10020 // Start the first transaction to set up the SpdySession |
| 10099 HttpRequestInfo request1; | 10021 HttpRequestInfo request1; |
| 10100 request1.method = "GET"; | 10022 request1.method = "GET"; |
| 10101 request1.url = GURL(https_url); | 10023 request1.url = GURL(https_url); |
| 10102 request1.priority = LOWEST; | 10024 request1.priority = LOWEST; |
| 10103 request1.load_flags = 0; | 10025 request1.load_flags = 0; |
| 10104 HttpNetworkTransaction trans1(session); | 10026 HttpNetworkTransaction trans1(session); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10257 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 10179 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
| 10258 MessageLoop::current()->RunUntilIdle(); | 10180 MessageLoop::current()->RunUntilIdle(); |
| 10259 data2->RunFor(3); | 10181 data2->RunFor(3); |
| 10260 | 10182 |
| 10261 ASSERT_TRUE(callback2.have_result()); | 10183 ASSERT_TRUE(callback2.have_result()); |
| 10262 EXPECT_EQ(OK, callback2.WaitForResult()); | 10184 EXPECT_EQ(OK, callback2.WaitForResult()); |
| 10263 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 10185 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
| 10264 } | 10186 } |
| 10265 | 10187 |
| 10266 } // namespace net | 10188 } // namespace net |
| OLD | NEW |