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

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

Issue 3391029: Revert 60747 - Add a new class SpdyProxyClientSocket which implements ClientS... (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"
18 #include "net/http/http_request_info.h" 17 #include "net/http/http_request_info.h"
19 #include "net/http/http_stream_parser.h" 18 #include "net/http/http_stream_parser.h"
20 #include "net/socket/client_socket_handle.h" 19 #include "net/socket/client_socket_handle.h"
21 20
22 namespace net { 21 namespace net {
23 22
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
24 HttpProxyClientSocket::HttpProxyClientSocket( 53 HttpProxyClientSocket::HttpProxyClientSocket(
25 ClientSocketHandle* transport_socket, 54 ClientSocketHandle* transport_socket,
26 const GURL& request_url, 55 const GURL& request_url,
27 const std::string& user_agent, 56 const std::string& user_agent,
28 const HostPortPair& endpoint, 57 const HostPortPair& endpoint,
29 const HostPortPair& proxy_server, 58 const HostPortPair& proxy_server,
30 HttpAuthCache* http_auth_cache, 59 HttpAuthCache* http_auth_cache,
31 HttpAuthHandlerFactory* http_auth_handler_factory, 60 HttpAuthHandlerFactory* http_auth_handler_factory,
32 bool tunnel, 61 bool tunnel,
33 bool using_spdy) 62 bool using_spdy)
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 next_state_ = STATE_SEND_REQUEST_COMPLETE; 351 next_state_ = STATE_SEND_REQUEST_COMPLETE;
323 352
324 // This is constructed lazily (instead of within our Start method), so that 353 // This is constructed lazily (instead of within our Start method), so that
325 // we have proxy info available. 354 // we have proxy info available.
326 if (request_headers_.empty()) { 355 if (request_headers_.empty()) {
327 HttpRequestHeaders authorization_headers; 356 HttpRequestHeaders authorization_headers;
328 if (auth_->HaveAuth()) 357 if (auth_->HaveAuth())
329 auth_->AddAuthorizationHeader(&authorization_headers); 358 auth_->AddAuthorizationHeader(&authorization_headers);
330 std::string request_line; 359 std::string request_line;
331 HttpRequestHeaders request_headers; 360 HttpRequestHeaders request_headers;
332 BuildTunnelRequest(request_, authorization_headers, endpoint_, 361 BuildTunnelRequest(&request_, authorization_headers, endpoint_,
333 &request_line, &request_headers); 362 &request_line, &request_headers);
334 if (net_log_.IsLoggingAll()) { 363 if (net_log_.IsLoggingAll()) {
335 net_log_.AddEvent( 364 net_log_.AddEvent(
336 NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, 365 NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
337 new NetLogHttpRequestParameter( 366 new NetLogHttpRequestParameter(
338 request_line, request_headers)); 367 request_line, request_headers));
339 } 368 }
340 request_headers_ = request_line + request_headers.ToString(); 369 request_headers_ = request_line + request_headers.ToString();
341 } 370 }
342 371
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 476
448 int rv = auth_->HandleAuthChallenge(response_.headers, false, true, net_log_); 477 int rv = auth_->HandleAuthChallenge(response_.headers, false, true, net_log_);
449 response_.auth_challenge = auth_->auth_info(); 478 response_.auth_challenge = auth_->auth_info();
450 if (rv == OK) 479 if (rv == OK)
451 return ERR_PROXY_AUTH_REQUESTED; 480 return ERR_PROXY_AUTH_REQUESTED;
452 481
453 return rv; 482 return rv;
454 } 483 }
455 484
456 } // namespace net 485 } // 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