| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
| 8 #include <stdarg.h> | 8 #include <stdarg.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #include "net/http/http_network_session.h" | 53 #include "net/http/http_network_session.h" |
| 54 #include "net/http/http_network_session_peer.h" | 54 #include "net/http/http_network_session_peer.h" |
| 55 #include "net/http/http_request_headers.h" | 55 #include "net/http/http_request_headers.h" |
| 56 #include "net/http/http_response_info.h" | 56 #include "net/http/http_response_info.h" |
| 57 #include "net/http/http_server_properties_impl.h" | 57 #include "net/http/http_server_properties_impl.h" |
| 58 #include "net/http/http_stream.h" | 58 #include "net/http/http_stream.h" |
| 59 #include "net/http/http_stream_factory.h" | 59 #include "net/http/http_stream_factory.h" |
| 60 #include "net/http/http_stream_parser.h" | 60 #include "net/http/http_stream_parser.h" |
| 61 #include "net/http/http_transaction_test_util.h" | 61 #include "net/http/http_transaction_test_util.h" |
| 62 #include "net/log/net_log.h" | 62 #include "net/log/net_log.h" |
| 63 #include "net/log/net_log_event_type.h" |
| 63 #include "net/log/test_net_log.h" | 64 #include "net/log/test_net_log.h" |
| 64 #include "net/log/test_net_log_entry.h" | 65 #include "net/log/test_net_log_entry.h" |
| 65 #include "net/log/test_net_log_util.h" | 66 #include "net/log/test_net_log_util.h" |
| 66 #include "net/proxy/mock_proxy_resolver.h" | 67 #include "net/proxy/mock_proxy_resolver.h" |
| 67 #include "net/proxy/proxy_config_service_fixed.h" | 68 #include "net/proxy/proxy_config_service_fixed.h" |
| 68 #include "net/proxy/proxy_info.h" | 69 #include "net/proxy/proxy_info.h" |
| 69 #include "net/proxy/proxy_resolver.h" | 70 #include "net/proxy/proxy_resolver.h" |
| 70 #include "net/proxy/proxy_server.h" | 71 #include "net/proxy/proxy_server.h" |
| 71 #include "net/proxy/proxy_service.h" | 72 #include "net/proxy/proxy_service.h" |
| 72 #include "net/socket/client_socket_factory.h" | 73 #include "net/socket/client_socket_factory.h" |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 trans.GetRemoteEndpoint(&out.remote_endpoint_after_start); | 371 trans.GetRemoteEndpoint(&out.remote_endpoint_after_start); |
| 371 EXPECT_EQ(got_endpoint, | 372 EXPECT_EQ(got_endpoint, |
| 372 out.remote_endpoint_after_start.address().size() > 0); | 373 out.remote_endpoint_after_start.address().size() > 0); |
| 373 | 374 |
| 374 rv = ReadTransaction(&trans, &out.response_data); | 375 rv = ReadTransaction(&trans, &out.response_data); |
| 375 EXPECT_THAT(rv, IsOk()); | 376 EXPECT_THAT(rv, IsOk()); |
| 376 | 377 |
| 377 TestNetLogEntry::List entries; | 378 TestNetLogEntry::List entries; |
| 378 log.GetEntries(&entries); | 379 log.GetEntries(&entries); |
| 379 size_t pos = ExpectLogContainsSomewhere( | 380 size_t pos = ExpectLogContainsSomewhere( |
| 380 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, | 381 entries, 0, NetLogEventType::HTTP_TRANSACTION_SEND_REQUEST_HEADERS, |
| 381 NetLog::PHASE_NONE); | 382 NetLogEventPhase::NONE); |
| 382 ExpectLogContainsSomewhere( | 383 ExpectLogContainsSomewhere( |
| 383 entries, pos, | 384 entries, pos, |
| 384 NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS, | 385 NetLogEventType::HTTP_TRANSACTION_READ_RESPONSE_HEADERS, |
| 385 NetLog::PHASE_NONE); | 386 NetLogEventPhase::NONE); |
| 386 | 387 |
| 387 std::string line; | 388 std::string line; |
| 388 EXPECT_TRUE(entries[pos].GetStringValue("line", &line)); | 389 EXPECT_TRUE(entries[pos].GetStringValue("line", &line)); |
| 389 EXPECT_EQ("GET / HTTP/1.1\r\n", line); | 390 EXPECT_EQ("GET / HTTP/1.1\r\n", line); |
| 390 | 391 |
| 391 HttpRequestHeaders request_headers; | 392 HttpRequestHeaders request_headers; |
| 392 EXPECT_TRUE(trans.GetFullRequestHeaders(&request_headers)); | 393 EXPECT_TRUE(trans.GetFullRequestHeaders(&request_headers)); |
| 393 std::string value; | 394 std::string value; |
| 394 EXPECT_TRUE(request_headers.GetHeader("Host", &value)); | 395 EXPECT_TRUE(request_headers.GetHeader("Host", &value)); |
| 395 EXPECT_EQ("www.example.org", value); | 396 EXPECT_EQ("www.example.org", value); |
| (...skipping 2448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2844 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 2845 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 2845 | 2846 |
| 2846 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2847 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2847 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 2848 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 2848 | 2849 |
| 2849 rv = callback1.WaitForResult(); | 2850 rv = callback1.WaitForResult(); |
| 2850 EXPECT_THAT(rv, IsOk()); | 2851 EXPECT_THAT(rv, IsOk()); |
| 2851 TestNetLogEntry::List entries; | 2852 TestNetLogEntry::List entries; |
| 2852 log.GetEntries(&entries); | 2853 log.GetEntries(&entries); |
| 2853 size_t pos = ExpectLogContainsSomewhere( | 2854 size_t pos = ExpectLogContainsSomewhere( |
| 2854 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 2855 entries, 0, NetLogEventType::HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 2855 NetLog::PHASE_NONE); | 2856 NetLogEventPhase::NONE); |
| 2856 ExpectLogContainsSomewhere( | 2857 ExpectLogContainsSomewhere( |
| 2857 entries, pos, NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 2858 entries, pos, |
| 2858 NetLog::PHASE_NONE); | 2859 NetLogEventType::HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 2860 NetLogEventPhase::NONE); |
| 2859 | 2861 |
| 2860 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2862 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2861 ASSERT_TRUE(response); | 2863 ASSERT_TRUE(response); |
| 2862 EXPECT_FALSE(response->headers->IsKeepAlive()); | 2864 EXPECT_FALSE(response->headers->IsKeepAlive()); |
| 2863 ASSERT_TRUE(response->headers); | 2865 ASSERT_TRUE(response->headers); |
| 2864 EXPECT_EQ(407, response->headers->response_code()); | 2866 EXPECT_EQ(407, response->headers->response_code()); |
| 2865 EXPECT_TRUE(HttpVersion(1, 0) == response->headers->GetHttpVersion()); | 2867 EXPECT_TRUE(HttpVersion(1, 0) == response->headers->GetHttpVersion()); |
| 2866 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2868 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 2867 | 2869 |
| 2868 LoadTimingInfo load_timing_info; | 2870 LoadTimingInfo load_timing_info; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2967 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 2969 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 2968 | 2970 |
| 2969 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 2971 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 2970 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 2972 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 2971 | 2973 |
| 2972 rv = callback1.WaitForResult(); | 2974 rv = callback1.WaitForResult(); |
| 2973 EXPECT_THAT(rv, IsOk()); | 2975 EXPECT_THAT(rv, IsOk()); |
| 2974 TestNetLogEntry::List entries; | 2976 TestNetLogEntry::List entries; |
| 2975 log.GetEntries(&entries); | 2977 log.GetEntries(&entries); |
| 2976 size_t pos = ExpectLogContainsSomewhere( | 2978 size_t pos = ExpectLogContainsSomewhere( |
| 2977 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 2979 entries, 0, NetLogEventType::HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 2978 NetLog::PHASE_NONE); | 2980 NetLogEventPhase::NONE); |
| 2979 ExpectLogContainsSomewhere( | 2981 ExpectLogContainsSomewhere( |
| 2980 entries, pos, | 2982 entries, pos, |
| 2981 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 2983 NetLogEventType::HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 2982 NetLog::PHASE_NONE); | 2984 NetLogEventPhase::NONE); |
| 2983 | 2985 |
| 2984 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2986 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 2985 ASSERT_TRUE(response); | 2987 ASSERT_TRUE(response); |
| 2986 EXPECT_FALSE(response->headers->IsKeepAlive()); | 2988 EXPECT_FALSE(response->headers->IsKeepAlive()); |
| 2987 ASSERT_TRUE(response->headers); | 2989 ASSERT_TRUE(response->headers); |
| 2988 EXPECT_EQ(407, response->headers->response_code()); | 2990 EXPECT_EQ(407, response->headers->response_code()); |
| 2989 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2991 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 2990 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2992 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 2991 | 2993 |
| 2992 LoadTimingInfo load_timing_info; | 2994 LoadTimingInfo load_timing_info; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3087 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 3089 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
| 3088 | 3090 |
| 3089 TestCompletionCallback callback1; | 3091 TestCompletionCallback callback1; |
| 3090 | 3092 |
| 3091 int rv = trans.Start(&request, callback1.callback(), log.bound()); | 3093 int rv = trans.Start(&request, callback1.callback(), log.bound()); |
| 3092 EXPECT_THAT(callback1.GetResult(rv), IsOk()); | 3094 EXPECT_THAT(callback1.GetResult(rv), IsOk()); |
| 3093 | 3095 |
| 3094 TestNetLogEntry::List entries; | 3096 TestNetLogEntry::List entries; |
| 3095 log.GetEntries(&entries); | 3097 log.GetEntries(&entries); |
| 3096 size_t pos = ExpectLogContainsSomewhere( | 3098 size_t pos = ExpectLogContainsSomewhere( |
| 3097 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 3099 entries, 0, NetLogEventType::HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 3098 NetLog::PHASE_NONE); | 3100 NetLogEventPhase::NONE); |
| 3099 ExpectLogContainsSomewhere( | 3101 ExpectLogContainsSomewhere( |
| 3100 entries, pos, | 3102 entries, pos, |
| 3101 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 3103 NetLogEventType::HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 3102 NetLog::PHASE_NONE); | 3104 NetLogEventPhase::NONE); |
| 3103 | 3105 |
| 3104 const HttpResponseInfo* response = trans.GetResponseInfo(); | 3106 const HttpResponseInfo* response = trans.GetResponseInfo(); |
| 3105 ASSERT_TRUE(response); | 3107 ASSERT_TRUE(response); |
| 3106 ASSERT_TRUE(response->headers); | 3108 ASSERT_TRUE(response->headers); |
| 3107 EXPECT_TRUE(response->headers->IsKeepAlive()); | 3109 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 3108 EXPECT_EQ(407, response->headers->response_code()); | 3110 EXPECT_EQ(407, response->headers->response_code()); |
| 3109 EXPECT_EQ(10, response->headers->GetContentLength()); | 3111 EXPECT_EQ(10, response->headers->GetContentLength()); |
| 3110 EXPECT_TRUE(HttpVersion(1, 0) == response->headers->GetHttpVersion()); | 3112 EXPECT_TRUE(HttpVersion(1, 0) == response->headers->GetHttpVersion()); |
| 3111 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 3113 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 3112 | 3114 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3195 session_deps_.socket_factory->AddSocketDataProvider(&data1); | 3197 session_deps_.socket_factory->AddSocketDataProvider(&data1); |
| 3196 | 3198 |
| 3197 TestCompletionCallback callback1; | 3199 TestCompletionCallback callback1; |
| 3198 | 3200 |
| 3199 int rv = trans.Start(&request, callback1.callback(), log.bound()); | 3201 int rv = trans.Start(&request, callback1.callback(), log.bound()); |
| 3200 EXPECT_THAT(callback1.GetResult(rv), IsOk()); | 3202 EXPECT_THAT(callback1.GetResult(rv), IsOk()); |
| 3201 | 3203 |
| 3202 TestNetLogEntry::List entries; | 3204 TestNetLogEntry::List entries; |
| 3203 log.GetEntries(&entries); | 3205 log.GetEntries(&entries); |
| 3204 size_t pos = ExpectLogContainsSomewhere( | 3206 size_t pos = ExpectLogContainsSomewhere( |
| 3205 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 3207 entries, 0, NetLogEventType::HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 3206 NetLog::PHASE_NONE); | 3208 NetLogEventPhase::NONE); |
| 3207 ExpectLogContainsSomewhere( | 3209 ExpectLogContainsSomewhere( |
| 3208 entries, pos, | 3210 entries, pos, |
| 3209 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 3211 NetLogEventType::HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 3210 NetLog::PHASE_NONE); | 3212 NetLogEventPhase::NONE); |
| 3211 | 3213 |
| 3212 const HttpResponseInfo* response = trans.GetResponseInfo(); | 3214 const HttpResponseInfo* response = trans.GetResponseInfo(); |
| 3213 ASSERT_TRUE(response); | 3215 ASSERT_TRUE(response); |
| 3214 ASSERT_TRUE(response->headers); | 3216 ASSERT_TRUE(response->headers); |
| 3215 EXPECT_TRUE(response->headers->IsKeepAlive()); | 3217 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 3216 EXPECT_EQ(407, response->headers->response_code()); | 3218 EXPECT_EQ(407, response->headers->response_code()); |
| 3217 EXPECT_EQ(10, response->headers->GetContentLength()); | 3219 EXPECT_EQ(10, response->headers->GetContentLength()); |
| 3218 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 3220 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 3219 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 3221 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 3220 | 3222 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3318 | 3320 |
| 3319 std::unique_ptr<HttpNetworkTransaction> trans( | 3321 std::unique_ptr<HttpNetworkTransaction> trans( |
| 3320 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 3322 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 3321 | 3323 |
| 3322 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 3324 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 3323 EXPECT_THAT(callback1.GetResult(rv), IsOk()); | 3325 EXPECT_THAT(callback1.GetResult(rv), IsOk()); |
| 3324 | 3326 |
| 3325 TestNetLogEntry::List entries; | 3327 TestNetLogEntry::List entries; |
| 3326 log.GetEntries(&entries); | 3328 log.GetEntries(&entries); |
| 3327 size_t pos = ExpectLogContainsSomewhere( | 3329 size_t pos = ExpectLogContainsSomewhere( |
| 3328 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 3330 entries, 0, NetLogEventType::HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 3329 NetLog::PHASE_NONE); | 3331 NetLogEventPhase::NONE); |
| 3330 ExpectLogContainsSomewhere( | 3332 ExpectLogContainsSomewhere( |
| 3331 entries, pos, | 3333 entries, pos, |
| 3332 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 3334 NetLogEventType::HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 3333 NetLog::PHASE_NONE); | 3335 NetLogEventPhase::NONE); |
| 3334 | 3336 |
| 3335 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3337 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 3336 ASSERT_TRUE(response); | 3338 ASSERT_TRUE(response); |
| 3337 ASSERT_TRUE(response->headers); | 3339 ASSERT_TRUE(response->headers); |
| 3338 EXPECT_TRUE(response->headers->IsKeepAlive()); | 3340 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 3339 EXPECT_EQ(407, response->headers->response_code()); | 3341 EXPECT_EQ(407, response->headers->response_code()); |
| 3340 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 3342 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 3341 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 3343 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
| 3342 | 3344 |
| 3343 LoadTimingInfo load_timing_info; | 3345 LoadTimingInfo load_timing_info; |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3664 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); | 3666 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
| 3665 | 3667 |
| 3666 int rv = trans.Start(&request, callback1.callback(), log.bound()); | 3668 int rv = trans.Start(&request, callback1.callback(), log.bound()); |
| 3667 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 3669 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 3668 | 3670 |
| 3669 rv = callback1.WaitForResult(); | 3671 rv = callback1.WaitForResult(); |
| 3670 EXPECT_THAT(rv, IsError(ERR_UNEXPECTED_PROXY_AUTH)); | 3672 EXPECT_THAT(rv, IsError(ERR_UNEXPECTED_PROXY_AUTH)); |
| 3671 TestNetLogEntry::List entries; | 3673 TestNetLogEntry::List entries; |
| 3672 log.GetEntries(&entries); | 3674 log.GetEntries(&entries); |
| 3673 size_t pos = ExpectLogContainsSomewhere( | 3675 size_t pos = ExpectLogContainsSomewhere( |
| 3674 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 3676 entries, 0, NetLogEventType::HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 3675 NetLog::PHASE_NONE); | 3677 NetLogEventPhase::NONE); |
| 3676 ExpectLogContainsSomewhere( | 3678 ExpectLogContainsSomewhere( |
| 3677 entries, pos, | 3679 entries, pos, |
| 3678 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 3680 NetLogEventType::HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 3679 NetLog::PHASE_NONE); | 3681 NetLogEventPhase::NONE); |
| 3680 } | 3682 } |
| 3681 | 3683 |
| 3682 // Test a proxy auth scheme that allows default credentials and a proxy server | 3684 // Test a proxy auth scheme that allows default credentials and a proxy server |
| 3683 // that uses non-persistent connections. | 3685 // that uses non-persistent connections. |
| 3684 TEST_F(HttpNetworkTransactionTest, | 3686 TEST_F(HttpNetworkTransactionTest, |
| 3685 AuthAllowsDefaultCredentialsTunnelConnectionClose) { | 3687 AuthAllowsDefaultCredentialsTunnelConnectionClose) { |
| 3686 HttpRequestInfo request; | 3688 HttpRequestInfo request; |
| 3687 request.method = "GET"; | 3689 request.method = "GET"; |
| 3688 request.url = GURL("https://www.example.org/"); | 3690 request.url = GURL("https://www.example.org/"); |
| 3689 | 3691 |
| (...skipping 4174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7864 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 7866 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 7865 | 7867 |
| 7866 int rv = trans->Start(&request, callback1.callback(), log.bound()); | 7868 int rv = trans->Start(&request, callback1.callback(), log.bound()); |
| 7867 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 7869 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 7868 | 7870 |
| 7869 rv = callback1.WaitForResult(); | 7871 rv = callback1.WaitForResult(); |
| 7870 EXPECT_THAT(rv, IsOk()); | 7872 EXPECT_THAT(rv, IsOk()); |
| 7871 TestNetLogEntry::List entries; | 7873 TestNetLogEntry::List entries; |
| 7872 log.GetEntries(&entries); | 7874 log.GetEntries(&entries); |
| 7873 size_t pos = ExpectLogContainsSomewhere( | 7875 size_t pos = ExpectLogContainsSomewhere( |
| 7874 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 7876 entries, 0, NetLogEventType::HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 7875 NetLog::PHASE_NONE); | 7877 NetLogEventPhase::NONE); |
| 7876 ExpectLogContainsSomewhere( | 7878 ExpectLogContainsSomewhere( |
| 7877 entries, pos, | 7879 entries, pos, |
| 7878 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 7880 NetLogEventType::HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 7879 NetLog::PHASE_NONE); | 7881 NetLogEventPhase::NONE); |
| 7880 | 7882 |
| 7881 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7883 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7882 ASSERT_TRUE(response); | 7884 ASSERT_TRUE(response); |
| 7883 ASSERT_TRUE(response->headers); | 7885 ASSERT_TRUE(response->headers); |
| 7884 EXPECT_EQ(407, response->headers->response_code()); | 7886 EXPECT_EQ(407, response->headers->response_code()); |
| 7885 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 7887 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 7886 EXPECT_TRUE(response->auth_challenge); | 7888 EXPECT_TRUE(response->auth_challenge); |
| 7887 EXPECT_TRUE(CheckBasicSecureProxyAuth(response->auth_challenge.get())); | 7889 EXPECT_TRUE(CheckBasicSecureProxyAuth(response->auth_challenge.get())); |
| 7888 | 7890 |
| 7889 TestCompletionCallback callback2; | 7891 TestCompletionCallback callback2; |
| (...skipping 4297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12187 base::Unretained(&headers_handler))); | 12189 base::Unretained(&headers_handler))); |
| 12188 | 12190 |
| 12189 int rv = trans.Start(&request, callback1.callback(), log.bound()); | 12191 int rv = trans.Start(&request, callback1.callback(), log.bound()); |
| 12190 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 12192 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 12191 | 12193 |
| 12192 rv = callback1.WaitForResult(); | 12194 rv = callback1.WaitForResult(); |
| 12193 EXPECT_THAT(rv, IsOk()); | 12195 EXPECT_THAT(rv, IsOk()); |
| 12194 TestNetLogEntry::List entries; | 12196 TestNetLogEntry::List entries; |
| 12195 log.GetEntries(&entries); | 12197 log.GetEntries(&entries); |
| 12196 size_t pos = ExpectLogContainsSomewhere( | 12198 size_t pos = ExpectLogContainsSomewhere( |
| 12197 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 12199 entries, 0, NetLogEventType::HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 12198 NetLog::PHASE_NONE); | 12200 NetLogEventPhase::NONE); |
| 12199 ExpectLogContainsSomewhere( | 12201 ExpectLogContainsSomewhere( |
| 12200 entries, pos, | 12202 entries, pos, |
| 12201 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 12203 NetLogEventType::HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 12202 NetLog::PHASE_NONE); | 12204 NetLogEventPhase::NONE); |
| 12203 | 12205 |
| 12204 const HttpResponseInfo* response = trans.GetResponseInfo(); | 12206 const HttpResponseInfo* response = trans.GetResponseInfo(); |
| 12205 ASSERT_TRUE(response); | 12207 ASSERT_TRUE(response); |
| 12206 | 12208 |
| 12207 EXPECT_TRUE(response->headers->IsKeepAlive()); | 12209 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 12208 EXPECT_EQ(200, response->headers->response_code()); | 12210 EXPECT_EQ(200, response->headers->response_code()); |
| 12209 EXPECT_EQ(100, response->headers->GetContentLength()); | 12211 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 12210 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 12212 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 12211 EXPECT_TRUE(response->was_fetched_via_proxy); | 12213 EXPECT_TRUE(response->was_fetched_via_proxy); |
| 12212 EXPECT_TRUE( | 12214 EXPECT_TRUE( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12265 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); | 12267 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
| 12266 | 12268 |
| 12267 int rv = trans.Start(&request, callback1.callback(), log.bound()); | 12269 int rv = trans.Start(&request, callback1.callback(), log.bound()); |
| 12268 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 12270 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 12269 | 12271 |
| 12270 rv = callback1.WaitForResult(); | 12272 rv = callback1.WaitForResult(); |
| 12271 EXPECT_THAT(rv, IsOk()); | 12273 EXPECT_THAT(rv, IsOk()); |
| 12272 TestNetLogEntry::List entries; | 12274 TestNetLogEntry::List entries; |
| 12273 log.GetEntries(&entries); | 12275 log.GetEntries(&entries); |
| 12274 size_t pos = ExpectLogContainsSomewhere( | 12276 size_t pos = ExpectLogContainsSomewhere( |
| 12275 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 12277 entries, 0, NetLogEventType::HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 12276 NetLog::PHASE_NONE); | 12278 NetLogEventPhase::NONE); |
| 12277 ExpectLogContainsSomewhere( | 12279 ExpectLogContainsSomewhere( |
| 12278 entries, pos, NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 12280 entries, pos, |
| 12279 NetLog::PHASE_NONE); | 12281 NetLogEventType::HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 12282 NetLogEventPhase::NONE); |
| 12280 | 12283 |
| 12281 const HttpResponseInfo* response = trans.GetResponseInfo(); | 12284 const HttpResponseInfo* response = trans.GetResponseInfo(); |
| 12282 ASSERT_TRUE(response); | 12285 ASSERT_TRUE(response); |
| 12283 | 12286 |
| 12284 EXPECT_TRUE(response->headers->IsKeepAlive()); | 12287 EXPECT_TRUE(response->headers->IsKeepAlive()); |
| 12285 EXPECT_EQ(200, response->headers->response_code()); | 12288 EXPECT_EQ(200, response->headers->response_code()); |
| 12286 EXPECT_EQ(100, response->headers->GetContentLength()); | 12289 EXPECT_EQ(100, response->headers->GetContentLength()); |
| 12287 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 12290 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
| 12288 EXPECT_TRUE(response->was_fetched_via_proxy); | 12291 EXPECT_TRUE(response->was_fetched_via_proxy); |
| 12289 EXPECT_TRUE( | 12292 EXPECT_TRUE( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12335 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); | 12338 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
| 12336 | 12339 |
| 12337 int rv = trans.Start(&request, callback1.callback(), log.bound()); | 12340 int rv = trans.Start(&request, callback1.callback(), log.bound()); |
| 12338 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 12341 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
| 12339 | 12342 |
| 12340 rv = callback1.WaitForResult(); | 12343 rv = callback1.WaitForResult(); |
| 12341 EXPECT_THAT(rv, IsError(ERR_EMPTY_RESPONSE)); | 12344 EXPECT_THAT(rv, IsError(ERR_EMPTY_RESPONSE)); |
| 12342 TestNetLogEntry::List entries; | 12345 TestNetLogEntry::List entries; |
| 12343 log.GetEntries(&entries); | 12346 log.GetEntries(&entries); |
| 12344 size_t pos = ExpectLogContainsSomewhere( | 12347 size_t pos = ExpectLogContainsSomewhere( |
| 12345 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, | 12348 entries, 0, NetLogEventType::HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |
| 12346 NetLog::PHASE_NONE); | 12349 NetLogEventPhase::NONE); |
| 12347 ExpectLogContainsSomewhere( | 12350 ExpectLogContainsSomewhere( |
| 12348 entries, pos, | 12351 entries, pos, |
| 12349 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, | 12352 NetLogEventType::HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, |
| 12350 NetLog::PHASE_NONE); | 12353 NetLogEventPhase::NONE); |
| 12351 } | 12354 } |
| 12352 | 12355 |
| 12353 // Test for crbug.com/55424. | 12356 // Test for crbug.com/55424. |
| 12354 TEST_F(HttpNetworkTransactionTest, PreconnectWithExistingSpdySession) { | 12357 TEST_F(HttpNetworkTransactionTest, PreconnectWithExistingSpdySession) { |
| 12355 SpdySerializedFrame req( | 12358 SpdySerializedFrame req( |
| 12356 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); | 12359 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); |
| 12357 MockWrite spdy_writes[] = {CreateMockWrite(req, 0)}; | 12360 MockWrite spdy_writes[] = {CreateMockWrite(req, 0)}; |
| 12358 | 12361 |
| 12359 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 12362 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 12360 SpdySerializedFrame data(spdy_util_.ConstructSpdyDataFrame(1, true)); | 12363 SpdySerializedFrame data(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| (...skipping 3212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15573 base::RunLoop().RunUntilIdle(); | 15576 base::RunLoop().RunUntilIdle(); |
| 15574 | 15577 |
| 15575 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 15578 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
| 15576 HttpRequestHeaders headers; | 15579 HttpRequestHeaders headers; |
| 15577 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 15580 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
| 15578 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 15581 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
| 15579 } | 15582 } |
| 15580 #endif // !defined(OS_IOS) | 15583 #endif // !defined(OS_IOS) |
| 15581 | 15584 |
| 15582 } // namespace net | 15585 } // namespace net |
| OLD | NEW |