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

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

Issue 1391053002: [net/http auth] Make HttpAuthHandler challenge handling asynchronous. Base URL: https://chromium.googlesource.com/chromium/src.git@auth-handler-init-split
Patch Set: Created 5 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
« no previous file with comments | « net/http/proxy_client_socket.h ('k') | net/log/net_log_event_type_list.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/proxy_client_socket.h" 5 #include "net/http/proxy_client_socket.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.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_errors.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 : host_and_port); 50 : host_and_port);
51 request_headers->SetHeader(HttpRequestHeaders::kProxyConnection, 51 request_headers->SetHeader(HttpRequestHeaders::kProxyConnection,
52 "keep-alive"); 52 "keep-alive");
53 if (!user_agent.empty()) 53 if (!user_agent.empty())
54 request_headers->SetHeader(HttpRequestHeaders::kUserAgent, user_agent); 54 request_headers->SetHeader(HttpRequestHeaders::kUserAgent, user_agent);
55 55
56 request_headers->MergeFrom(auth_headers); 56 request_headers->MergeFrom(auth_headers);
57 } 57 }
58 58
59 // static 59 // static
60 int ProxyClientSocket::HandleProxyAuthChallenge(HttpAuthController* auth,
61 HttpResponseInfo* response,
62 const BoundNetLog& net_log) {
63 DCHECK(response->headers.get());
64 int rv = auth->HandleAuthChallenge(response->headers, false, true, net_log);
65 response->auth_challenge = auth->auth_info();
66 if (rv == OK)
67 return ERR_PROXY_AUTH_REQUESTED;
68 return rv;
69 }
70
71 // static
72 void ProxyClientSocket::LogBlockedTunnelResponse(int http_status_code, 60 void ProxyClientSocket::LogBlockedTunnelResponse(int http_status_code,
73 bool is_https_proxy) { 61 bool is_https_proxy) {
74 if (is_https_proxy) { 62 if (is_https_proxy) {
75 UMA_HISTOGRAM_CUSTOM_ENUMERATION( 63 UMA_HISTOGRAM_CUSTOM_ENUMERATION(
76 "Net.BlockedTunnelResponse.HttpsProxy", 64 "Net.BlockedTunnelResponse.HttpsProxy",
77 HttpUtil::MapStatusCodeForHistogram(http_status_code), 65 HttpUtil::MapStatusCodeForHistogram(http_status_code),
78 HttpUtil::GetStatusCodesForHistogram()); 66 HttpUtil::GetStatusCodesForHistogram());
79 } else { 67 } else {
80 UMA_HISTOGRAM_CUSTOM_ENUMERATION( 68 UMA_HISTOGRAM_CUSTOM_ENUMERATION(
81 "Net.BlockedTunnelResponse.HttpProxy", 69 "Net.BlockedTunnelResponse.HttpProxy",
(...skipping 14 matching lines...) Expand all
96 84
97 // Copy status line and all hop-by-hop headers to preserve keep-alive 85 // Copy status line and all hop-by-hop headers to preserve keep-alive
98 // behavior. 86 // behavior.
99 new_headers->ReplaceStatusLine(old_headers->GetStatusLine()); 87 new_headers->ReplaceStatusLine(old_headers->GetStatusLine());
100 CopyHeaderValues(old_headers, new_headers, "connection"); 88 CopyHeaderValues(old_headers, new_headers, "connection");
101 CopyHeaderValues(old_headers, new_headers, "proxy-connection"); 89 CopyHeaderValues(old_headers, new_headers, "proxy-connection");
102 CopyHeaderValues(old_headers, new_headers, "keep-alive"); 90 CopyHeaderValues(old_headers, new_headers, "keep-alive");
103 CopyHeaderValues(old_headers, new_headers, "trailer"); 91 CopyHeaderValues(old_headers, new_headers, "trailer");
104 CopyHeaderValues(old_headers, new_headers, "transfer-encoding"); 92 CopyHeaderValues(old_headers, new_headers, "transfer-encoding");
105 CopyHeaderValues(old_headers, new_headers, "upgrade"); 93 CopyHeaderValues(old_headers, new_headers, "upgrade");
106
107 CopyHeaderValues(old_headers, new_headers, "content-length"); 94 CopyHeaderValues(old_headers, new_headers, "content-length");
108
109 CopyHeaderValues(old_headers, new_headers, "proxy-authenticate"); 95 CopyHeaderValues(old_headers, new_headers, "proxy-authenticate");
110 96
111 response->headers = new_headers; 97 response->headers = new_headers;
112 return true; 98 return true;
113 } 99 }
114 100
115 // static 101 // static
116 bool ProxyClientSocket::SanitizeProxyRedirect(HttpResponseInfo* response) { 102 bool ProxyClientSocket::SanitizeProxyRedirect(HttpResponseInfo* response) {
117 DCHECK(response && response->headers.get()); 103 DCHECK(response && response->headers.get());
118 104
(...skipping 11 matching lines...) Expand all
130 location.c_str()); 116 location.c_str());
131 std::string raw_headers = 117 std::string raw_headers =
132 HttpUtil::AssembleRawHeaders(fake_response_headers.data(), 118 HttpUtil::AssembleRawHeaders(fake_response_headers.data(),
133 fake_response_headers.length()); 119 fake_response_headers.length());
134 response->headers = new HttpResponseHeaders(raw_headers); 120 response->headers = new HttpResponseHeaders(raw_headers);
135 121
136 return true; 122 return true;
137 } 123 }
138 124
139 } // namespace net 125 } // namespace net
OLDNEW
« no previous file with comments | « net/http/proxy_client_socket.h ('k') | net/log/net_log_event_type_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698