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

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

Issue 9148011: Allow chrome to handle 407 auth challenges to CONNECT requests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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_utils.h ('k') | net/http/http_stream_factory_impl_job.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_utils.h" 5 #include "net/http/http_proxy_utils.h"
6 6
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "net/base/host_port_pair.h" 9 #include "net/base/host_port_pair.h"
10 #include "net/base/net_errors.h"
10 #include "net/base/net_util.h" 11 #include "net/base/net_util.h"
12 #include "net/http/http_auth_controller.h"
11 #include "net/http/http_request_info.h" 13 #include "net/http/http_request_info.h"
14 #include "net/http/http_response_headers.h"
15 #include "net/http/http_response_info.h"
12 16
13 namespace net { 17 namespace net {
14 18
15 void BuildTunnelRequest( 19 void BuildTunnelRequest(
16 const HttpRequestInfo& request_info, 20 const HttpRequestInfo& request_info,
17 const HttpRequestHeaders& auth_headers, 21 const HttpRequestHeaders& auth_headers,
18 const HostPortPair& endpoint, 22 const HostPortPair& endpoint,
19 std::string* request_line, 23 std::string* request_line,
20 HttpRequestHeaders* request_headers) { 24 HttpRequestHeaders* request_headers) {
21 // RFC 2616 Section 9 says the Host request-header field MUST accompany all 25 // RFC 2616 Section 9 says the Host request-header field MUST accompany all
22 // HTTP/1.1 requests. Add "Proxy-Connection: keep-alive" for compat with 26 // HTTP/1.1 requests. Add "Proxy-Connection: keep-alive" for compat with
23 // HTTP/1.0 proxies such as Squid (required for NTLM authentication). 27 // HTTP/1.0 proxies such as Squid (required for NTLM authentication).
24 *request_line = StringPrintf( 28 *request_line = StringPrintf(
25 "CONNECT %s HTTP/1.1\r\n", endpoint.ToString().c_str()); 29 "CONNECT %s HTTP/1.1\r\n", endpoint.ToString().c_str());
26 request_headers->SetHeader(HttpRequestHeaders::kHost, 30 request_headers->SetHeader(HttpRequestHeaders::kHost,
27 GetHostAndOptionalPort(request_info.url)); 31 GetHostAndOptionalPort(request_info.url));
28 request_headers->SetHeader(HttpRequestHeaders::kProxyConnection, 32 request_headers->SetHeader(HttpRequestHeaders::kProxyConnection,
29 "keep-alive"); 33 "keep-alive");
30 34
31 std::string user_agent; 35 std::string user_agent;
32 if (request_info.extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, 36 if (request_info.extra_headers.GetHeader(HttpRequestHeaders::kUserAgent,
33 &user_agent)) 37 &user_agent))
34 request_headers->SetHeader(HttpRequestHeaders::kUserAgent, user_agent); 38 request_headers->SetHeader(HttpRequestHeaders::kUserAgent, user_agent);
35 39
36 request_headers->MergeFrom(auth_headers); 40 request_headers->MergeFrom(auth_headers);
37 } 41 }
38 42
43 int HandleAuthChallenge(HttpAuthController* auth,
44 HttpResponseInfo* response,
45 const BoundNetLog& net_log) {
46 DCHECK(response->headers);
47
48 int rv = auth->HandleAuthChallenge(response->headers, false, true, net_log);
49 response->auth_challenge = auth->auth_info();
50 if (rv == OK)
51 return ERR_PROXY_AUTH_REQUESTED;
52 return rv;
53 }
54
39 } // namespace net 55 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_proxy_utils.h ('k') | net/http/http_stream_factory_impl_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698