| OLD | NEW |
| 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 "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 9 #include "net/base/auth.h" | 10 #include "net/base/auth.h" |
| 10 #include "net/base/host_port_pair.h" | 11 #include "net/base/host_port_pair.h" |
| 11 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
| 12 #include "net/base/net_log.h" | 13 #include "net/base/net_log.h" |
| 13 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
| 14 #include "net/http/http_net_log_params.h" | 15 #include "net/http/http_net_log_params.h" |
| 15 #include "net/http/http_network_session.h" | 16 #include "net/http/http_network_session.h" |
| 16 #include "net/http/http_request_info.h" | 17 #include "net/http/http_request_info.h" |
| 17 #include "net/http/http_stream_parser.h" | 18 #include "net/http/http_stream_parser.h" |
| 18 #include "net/socket/client_socket_handle.h" | 19 #include "net/socket/client_socket_handle.h" |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 // The HTTP CONNECT method for establishing a tunnel connection is documented | 25 // The HTTP CONNECT method for establishing a tunnel connection is documented |
| 25 // in draft-luotonen-web-proxy-tunneling-01.txt and RFC 2817, Sections 5.2 and | 26 // in draft-luotonen-web-proxy-tunneling-01.txt and RFC 2817, Sections 5.2 and |
| 26 // 5.3. | 27 // 5.3. |
| 27 void BuildTunnelRequest(const HttpRequestInfo* request_info, | 28 void BuildTunnelRequest(const HttpRequestInfo* request_info, |
| 28 const HttpRequestHeaders& authorization_headers, | 29 const HttpRequestHeaders& authorization_headers, |
| 29 const HostPortPair& endpoint, | 30 const HostPortPair& endpoint, |
| 30 std::string* request_line, | 31 std::string* request_line, |
| 31 HttpRequestHeaders* request_headers) { | 32 HttpRequestHeaders* request_headers) { |
| 32 // RFC 2616 Section 9 says the Host request-header field MUST accompany all | 33 // RFC 2616 Section 9 says the Host request-header field MUST accompany all |
| 33 // HTTP/1.1 requests. Add "Proxy-Connection: keep-alive" for compat with | 34 // HTTP/1.1 requests. Add "Proxy-Connection: keep-alive" for compat with |
| 34 // HTTP/1.0 proxies such as Squid (required for NTLM authentication). | 35 // HTTP/1.0 proxies such as Squid (required for NTLM authentication). |
| 35 *request_line = StringPrintf( | 36 *request_line = base::StringPrintf( |
| 36 "CONNECT %s HTTP/1.1\r\n", endpoint.ToString().c_str()); | 37 "CONNECT %s HTTP/1.1\r\n", endpoint.ToString().c_str()); |
| 37 request_headers->SetHeader(HttpRequestHeaders::kHost, | 38 request_headers->SetHeader(HttpRequestHeaders::kHost, |
| 38 GetHostAndOptionalPort(request_info->url)); | 39 GetHostAndOptionalPort(request_info->url)); |
| 39 request_headers->SetHeader(HttpRequestHeaders::kProxyConnection, | 40 request_headers->SetHeader(HttpRequestHeaders::kProxyConnection, |
| 40 "keep-alive"); | 41 "keep-alive"); |
| 41 | 42 |
| 42 std::string user_agent; | 43 std::string user_agent; |
| 43 if (request_info->extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, | 44 if (request_info->extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, |
| 44 &user_agent)) | 45 &user_agent)) |
| 45 request_headers->SetHeader(HttpRequestHeaders::kUserAgent, user_agent); | 46 request_headers->SetHeader(HttpRequestHeaders::kUserAgent, user_agent); |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 476 |
| 476 int rv = auth_->HandleAuthChallenge(response_.headers, false, true, net_log_); | 477 int rv = auth_->HandleAuthChallenge(response_.headers, false, true, net_log_); |
| 477 response_.auth_challenge = auth_->auth_info(); | 478 response_.auth_challenge = auth_->auth_info(); |
| 478 if (rv == OK) | 479 if (rv == OK) |
| 479 return ERR_PROXY_AUTH_REQUESTED; | 480 return ERR_PROXY_AUTH_REQUESTED; |
| 480 | 481 |
| 481 return rv; | 482 return rv; |
| 482 } | 483 } |
| 483 | 484 |
| 484 } // namespace net | 485 } // namespace net |
| OLD | NEW |