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

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

Issue 3432009: Add a new class SpdyProxyClientSocket which implements ClientSocket... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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 | « no previous file | net/http/http_proxy_utils.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 "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "net/base/auth.h" 10 #include "net/base/auth.h"
11 #include "net/base/host_port_pair.h" 11 #include "net/base/host_port_pair.h"
12 #include "net/base/io_buffer.h" 12 #include "net/base/io_buffer.h"
13 #include "net/base/net_log.h" 13 #include "net/base/net_log.h"
14 #include "net/base/net_util.h" 14 #include "net/base/net_util.h"
15 #include "net/http/http_net_log_params.h" 15 #include "net/http/http_net_log_params.h"
16 #include "net/http/http_network_session.h" 16 #include "net/http/http_network_session.h"
17 #include "net/http/http_proxy_utils.h"
17 #include "net/http/http_request_info.h" 18 #include "net/http/http_request_info.h"
18 #include "net/http/http_stream_parser.h" 19 #include "net/http/http_stream_parser.h"
19 #include "net/socket/client_socket_handle.h" 20 #include "net/socket/client_socket_handle.h"
20 21
21 namespace net { 22 namespace net {
22 23
23 namespace {
24
25 // The HTTP CONNECT method for establishing a tunnel connection is documented
26 // in draft-luotonen-web-proxy-tunneling-01.txt and RFC 2817, Sections 5.2 and
27 // 5.3.
28 void BuildTunnelRequest(const HttpRequestInfo* request_info,
29 const HttpRequestHeaders& authorization_headers,
30 const HostPortPair& endpoint,
31 std::string* request_line,
32 HttpRequestHeaders* request_headers) {
33 // RFC 2616 Section 9 says the Host request-header field MUST accompany all
34 // HTTP/1.1 requests. Add "Proxy-Connection: keep-alive" for compat with
35 // HTTP/1.0 proxies such as Squid (required for NTLM authentication).
36 *request_line = base::StringPrintf(
37 "CONNECT %s HTTP/1.1\r\n", endpoint.ToString().c_str());
38 request_headers->SetHeader(HttpRequestHeaders::kHost,
39 GetHostAndOptionalPort(request_info->url));
40 request_headers->SetHeader(HttpRequestHeaders::kProxyConnection,
41 "keep-alive");
42
43 std::string user_agent;
44 if (request_info->extra_headers.GetHeader(HttpRequestHeaders::kUserAgent,
45 &user_agent))
46 request_headers->SetHeader(HttpRequestHeaders::kUserAgent, user_agent);
47
48 request_headers->MergeFrom(authorization_headers);
49 }
50
51 } // namespace
52
53 HttpProxyClientSocket::HttpProxyClientSocket( 24 HttpProxyClientSocket::HttpProxyClientSocket(
54 ClientSocketHandle* transport_socket, 25 ClientSocketHandle* transport_socket,
55 const GURL& request_url, 26 const GURL& request_url,
56 const std::string& user_agent, 27 const std::string& user_agent,
57 const HostPortPair& endpoint, 28 const HostPortPair& endpoint,
58 const HostPortPair& proxy_server, 29 const HostPortPair& proxy_server,
59 HttpAuthCache* http_auth_cache, 30 HttpAuthCache* http_auth_cache,
60 HttpAuthHandlerFactory* http_auth_handler_factory, 31 HttpAuthHandlerFactory* http_auth_handler_factory,
61 bool tunnel, 32 bool tunnel,
62 bool using_spdy) 33 bool using_spdy)
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 next_state_ = STATE_SEND_REQUEST_COMPLETE; 322 next_state_ = STATE_SEND_REQUEST_COMPLETE;
352 323
353 // This is constructed lazily (instead of within our Start method), so that 324 // This is constructed lazily (instead of within our Start method), so that
354 // we have proxy info available. 325 // we have proxy info available.
355 if (request_headers_.empty()) { 326 if (request_headers_.empty()) {
356 HttpRequestHeaders authorization_headers; 327 HttpRequestHeaders authorization_headers;
357 if (auth_->HaveAuth()) 328 if (auth_->HaveAuth())
358 auth_->AddAuthorizationHeader(&authorization_headers); 329 auth_->AddAuthorizationHeader(&authorization_headers);
359 std::string request_line; 330 std::string request_line;
360 HttpRequestHeaders request_headers; 331 HttpRequestHeaders request_headers;
361 BuildTunnelRequest(&request_, authorization_headers, endpoint_, 332 BuildTunnelRequest(request_, authorization_headers, endpoint_,
362 &request_line, &request_headers); 333 &request_line, &request_headers);
363 if (net_log_.IsLoggingAll()) { 334 if (net_log_.IsLoggingAll()) {
364 net_log_.AddEvent( 335 net_log_.AddEvent(
365 NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, 336 NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
366 new NetLogHttpRequestParameter( 337 new NetLogHttpRequestParameter(
367 request_line, request_headers)); 338 request_line, request_headers));
368 } 339 }
369 request_headers_ = request_line + request_headers.ToString(); 340 request_headers_ = request_line + request_headers.ToString();
370 } 341 }
371 342
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 447
477 int rv = auth_->HandleAuthChallenge(response_.headers, false, true, net_log_); 448 int rv = auth_->HandleAuthChallenge(response_.headers, false, true, net_log_);
478 response_.auth_challenge = auth_->auth_info(); 449 response_.auth_challenge = auth_->auth_info();
479 if (rv == OK) 450 if (rv == OK)
480 return ERR_PROXY_AUTH_REQUESTED; 451 return ERR_PROXY_AUTH_REQUESTED;
481 452
482 return rv; 453 return rv;
483 } 454 }
484 455
485 } // namespace net 456 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_proxy_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698