Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 346713003: Surface ERR_SPDY_SESSION_ALREADY_EXISTS to the proxy delegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 3010 matching lines...) Expand 10 before | Expand all | Expand 10 after
3021 const HttpResponseInfo* response = trans->GetResponseInfo(); 3021 const HttpResponseInfo* response = trans->GetResponseInfo();
3022 ASSERT_TRUE(response != NULL); 3022 ASSERT_TRUE(response != NULL);
3023 ASSERT_TRUE(response->headers.get() != NULL); 3023 ASSERT_TRUE(response->headers.get() != NULL);
3024 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 3024 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
3025 3025
3026 std::string response_data; 3026 std::string response_data;
3027 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); 3027 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
3028 EXPECT_EQ(kUploadData, response_data); 3028 EXPECT_EQ(kUploadData, response_data);
3029 } 3029 }
3030 3030
3031 // Verifies that a session which races and wins against the owning transaction
3032 // (completing prior to host resolution), doesn't fail the transaction.
3033 // Regression test for crbug.com/334413.
3034 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyGetWithSessionRace) {
3035 HttpRequestInfo request;
3036 request.method = "GET";
3037 request.url = GURL("http://www.google.com/");
3038 request.load_flags = 0;
3039
3040 // Configure SPDY proxy server "proxy:70".
3041 session_deps_.proxy_service.reset(
3042 ProxyService::CreateFixed("https://proxy:70"));
3043 CapturingBoundNetLog log;
3044 session_deps_.net_log = log.bound().net_log();
3045 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
3046
3047 // Fetch http://www.google.com/ through the SPDY proxy.
3048 scoped_ptr<SpdyFrame> req(
3049 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, false));
3050 MockWrite spdy_writes[] = {CreateMockWrite(*req)};
3051
3052 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
3053 scoped_ptr<SpdyFrame> data(spdy_util_.ConstructSpdyBodyFrame(1, true));
3054 MockRead spdy_reads[] = {
3055 CreateMockRead(*resp), CreateMockRead(*data), MockRead(ASYNC, 0, 0),
3056 };
3057
3058 DelayedSocketData spdy_data(
3059 1, // wait for one write to finish before reading.
3060 spdy_reads,
3061 arraysize(spdy_reads),
3062 spdy_writes,
3063 arraysize(spdy_writes));
3064 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data);
3065
3066 SSLSocketDataProvider ssl(ASYNC, OK);
3067 ssl.SetNextProto(GetParam());
3068 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
3069
3070 TestCompletionCallback callback1;
3071
3072 scoped_ptr<HttpTransaction> trans(
3073 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
3074
3075 // Stall the hostname resolution begun by the transaction.
3076 session_deps_.host_resolver->set_synchronous_mode(false);
3077 session_deps_.host_resolver->set_ondemand_mode(true);
3078
3079 int rv = trans->Start(&request, callback1.callback(), log.bound());
3080 EXPECT_EQ(ERR_IO_PENDING, rv);
3081
3082 // Race a session to the proxy, which completes first.
3083 session_deps_.host_resolver->set_ondemand_mode(false);
3084 SpdySessionKey key(
3085 HostPortPair("proxy", 70), ProxyServer::Direct(), PRIVACY_MODE_DISABLED);
3086 base::WeakPtr<SpdySession> spdy_session =
3087 CreateSecureSpdySession(session, key, log.bound());
3088
3089 // Unstall the resolution begun by the transaction.
3090 session_deps_.host_resolver->set_ondemand_mode(true);
3091 session_deps_.host_resolver->ResolveAllPending();
3092
3093 EXPECT_FALSE(callback1.have_result());
3094 rv = callback1.WaitForResult();
3095 EXPECT_EQ(OK, rv);
3096
3097 const HttpResponseInfo* response = trans->GetResponseInfo();
3098 ASSERT_TRUE(response != NULL);
3099 ASSERT_TRUE(response->headers.get() != NULL);
3100 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
3101
3102 std::string response_data;
3103 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data));
3104 EXPECT_EQ(kUploadData, response_data);
3105 }
3106
3031 // Test a SPDY get through an HTTPS Proxy. 3107 // Test a SPDY get through an HTTPS Proxy.
3032 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyGetWithProxyAuth) { 3108 TEST_P(HttpNetworkTransactionTest, HttpsProxySpdyGetWithProxyAuth) {
3033 HttpRequestInfo request; 3109 HttpRequestInfo request;
3034 request.method = "GET"; 3110 request.method = "GET";
3035 request.url = GURL("http://www.google.com/"); 3111 request.url = GURL("http://www.google.com/");
3036 request.load_flags = 0; 3112 request.load_flags = 0;
3037 3113
3038 // Configure against https proxy server "myproxy:70". 3114 // Configure against https proxy server "myproxy:70".
3039 session_deps_.proxy_service.reset( 3115 session_deps_.proxy_service.reset(
3040 ProxyService::CreateFixed("https://myproxy:70")); 3116 ProxyService::CreateFixed("https://myproxy:70"));
(...skipping 10064 matching lines...) Expand 10 before | Expand all | Expand 10 after
13105 EXPECT_EQ(ERR_IO_PENDING, rv); 13181 EXPECT_EQ(ERR_IO_PENDING, rv);
13106 13182
13107 rv = callback.WaitForResult(); 13183 rv = callback.WaitForResult();
13108 EXPECT_EQ(ERR_CONNECTION_RESET, rv); 13184 EXPECT_EQ(ERR_CONNECTION_RESET, rv);
13109 13185
13110 const HttpResponseInfo* response = trans->GetResponseInfo(); 13186 const HttpResponseInfo* response = trans->GetResponseInfo();
13111 EXPECT_TRUE(response == NULL); 13187 EXPECT_TRUE(response == NULL);
13112 } 13188 }
13113 13189
13114 } // namespace net 13190 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_proxy_client_socket_pool.cc » ('j') | net/http/http_proxy_client_socket_pool.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698