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

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

Issue 3259006: Add support for speaking SPDY to an HTTPS proxy.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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
« no previous file with comments | « net/http/http_proxy_client_socket.h ('k') | net/http/http_proxy_client_socket_pool.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_proxy_client_socket.h" 5 #include "net/http/http_proxy_client_socket.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "net/base/auth.h" 9 #include "net/base/auth.h"
10 #include "net/base/host_port_pair.h" 10 #include "net/base/host_port_pair.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 request_headers->MergeFrom(authorization_headers); 47 request_headers->MergeFrom(authorization_headers);
48 } 48 }
49 49
50 } // namespace 50 } // namespace
51 51
52 HttpProxyClientSocket::HttpProxyClientSocket( 52 HttpProxyClientSocket::HttpProxyClientSocket(
53 ClientSocketHandle* transport_socket, const GURL& request_url, 53 ClientSocketHandle* transport_socket, const GURL& request_url,
54 const std::string& user_agent, const HostPortPair& endpoint, 54 const std::string& user_agent, const HostPortPair& endpoint,
55 const HostPortPair& proxy_server, 55 const HostPortPair& proxy_server,
56 const scoped_refptr<HttpNetworkSession>& session, bool tunnel) 56 const scoped_refptr<HttpNetworkSession>& session, bool tunnel,
57 bool using_spdy)
57 : ALLOW_THIS_IN_INITIALIZER_LIST( 58 : ALLOW_THIS_IN_INITIALIZER_LIST(
58 io_callback_(this, &HttpProxyClientSocket::OnIOComplete)), 59 io_callback_(this, &HttpProxyClientSocket::OnIOComplete)),
59 next_state_(STATE_NONE), 60 next_state_(STATE_NONE),
60 user_callback_(NULL), 61 user_callback_(NULL),
61 transport_(transport_socket), 62 transport_(transport_socket),
62 endpoint_(endpoint), 63 endpoint_(endpoint),
63 auth_(tunnel ? 64 auth_(tunnel ?
64 new HttpAuthController(HttpAuth::AUTH_PROXY, 65 new HttpAuthController(HttpAuth::AUTH_PROXY,
65 GURL("http://" + proxy_server.ToString()), 66 GURL("http://" + proxy_server.ToString()),
66 session) : NULL), 67 session) : NULL),
67 tunnel_(tunnel), 68 tunnel_(tunnel),
69 using_spdy_(using_spdy),
68 net_log_(transport_socket->socket()->NetLog()) { 70 net_log_(transport_socket->socket()->NetLog()) {
69 // Synthesize the bits of a request that we actually use. 71 // Synthesize the bits of a request that we actually use.
70 request_.url = request_url; 72 request_.url = request_url;
71 request_.method = "GET"; 73 request_.method = "GET";
72 if (!user_agent.empty()) 74 if (!user_agent.empty())
73 request_.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, 75 request_.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent,
74 user_agent); 76 user_agent);
75 } 77 }
76 78
77 HttpProxyClientSocket::~HttpProxyClientSocket() { 79 HttpProxyClientSocket::~HttpProxyClientSocket() {
78 Disconnect(); 80 Disconnect();
79 } 81 }
80 82
81 int HttpProxyClientSocket::Connect(CompletionCallback* callback) { 83 int HttpProxyClientSocket::Connect(CompletionCallback* callback) {
82 DCHECK(transport_.get()); 84 DCHECK(transport_.get());
83 DCHECK(transport_->socket()); 85 DCHECK(transport_->socket());
84 DCHECK(!user_callback_); 86 DCHECK(!user_callback_);
85 87
86 if (!tunnel_) 88 // TODO(rch): figure out the right way to set up a tunnel with SPDY.
89 // This approach sends the complete HTTPS request to the proxy
90 // which allows the proxy to see "private" data. Instead, we should
91 // create an SSL tunnel to the origin server using the CONNECT method
92 // inside a single SPDY stream.
93 if (using_spdy_ || !tunnel_)
87 next_state_ = STATE_DONE; 94 next_state_ = STATE_DONE;
88 if (next_state_ == STATE_DONE) 95 if (next_state_ == STATE_DONE)
89 return OK; 96 return OK;
90 97
91 DCHECK_EQ(STATE_NONE, next_state_); 98 DCHECK_EQ(STATE_NONE, next_state_);
92 next_state_ = STATE_GENERATE_AUTH_TOKEN; 99 next_state_ = STATE_GENERATE_AUTH_TOKEN;
93 100
94 int rv = DoLoop(OK); 101 int rv = DoLoop(OK);
95 if (rv == ERR_IO_PENDING) 102 if (rv == ERR_IO_PENDING)
96 user_callback_ = callback; 103 user_callback_ = callback;
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 458
452 int rv = auth_->HandleAuthChallenge(response_.headers, false, true, net_log_); 459 int rv = auth_->HandleAuthChallenge(response_.headers, false, true, net_log_);
453 response_.auth_challenge = auth_->auth_info(); 460 response_.auth_challenge = auth_->auth_info();
454 if (rv == OK) 461 if (rv == OK)
455 return ERR_PROXY_AUTH_REQUESTED; 462 return ERR_PROXY_AUTH_REQUESTED;
456 463
457 return rv; 464 return rv;
458 } 465 }
459 466
460 } // namespace net 467 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_proxy_client_socket.h ('k') | net/http/http_proxy_client_socket_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698