OLD | NEW |
---|---|
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.h" | 7 #include "base/metrics/histogram.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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 HttpUtil::GetStatusCodesForHistogram()); | 65 HttpUtil::GetStatusCodesForHistogram()); |
66 } else { | 66 } else { |
67 UMA_HISTOGRAM_CUSTOM_ENUMERATION( | 67 UMA_HISTOGRAM_CUSTOM_ENUMERATION( |
68 "Net.BlockedTunnelResponse.HttpProxy", | 68 "Net.BlockedTunnelResponse.HttpProxy", |
69 HttpUtil::MapStatusCodeForHistogram(http_status_code), | 69 HttpUtil::MapStatusCodeForHistogram(http_status_code), |
70 HttpUtil::GetStatusCodesForHistogram()); | 70 HttpUtil::GetStatusCodesForHistogram()); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 // static | 74 // static |
75 bool ProxyClientSocket::SanitizeProxyRedirect(HttpResponseInfo* response, | 75 bool ProxyClientSocket::SanitizeProxyAuth(HttpResponseInfo* response) { |
76 const GURL& url) { | 76 DCHECK(response && response->headers.get()); |
77 | |
78 const char* kHeaderName = "Proxy-Authenticate"; | |
79 void* iter = NULL; | |
80 std::string auth, ignored; | |
81 // Make sure there is one Proxy-Authenticate header... | |
82 if (!response->headers->EnumerateHeader(&iter, kHeaderName, &auth)) | |
83 return false; | |
84 // ...but not more than one. | |
Ryan Sleevi
2014/12/08 22:04:39
BUG: This is NOT required by the spec. Per RFC 723
| |
85 if (response->headers->EnumerateHeader(&iter, kHeaderName, &ignored)) | |
86 return false; | |
87 | |
88 std::string fake_response_headers = base::StringPrintf( | |
89 "HTTP/1.1 407 Proxy Authentication Required\n" | |
90 "Proxy-Authenticate: %s\n" | |
91 "Content-Length: 0\n" | |
Ryan Hamilton
2014/12/08 22:51:59
Looks like the content-length should not be 0, sin
Deprecated (see juliatuttle)
2014/12/09 15:31:15
The goal was to avoid providing the response body,
Ryan Hamilton
2014/12/10 19:53:42
Oh! I'm sorry. I misread line 94 to be appending a
Deprecated (see juliatuttle)
2014/12/10 20:38:40
I've removed the content-length header entirely, s
| |
92 "Connection: close\n" | |
Ryan Hamilton
2014/12/08 22:51:59
I'm not sure that you want to make this connection
Deprecated (see juliatuttle)
2014/12/09 15:31:15
Sigh, okay.
Deprecated (see juliatuttle)
2014/12/10 20:38:40
I've passed along Connection headers along with th
| |
93 "\n", | |
94 auth.c_str()); | |
95 std::string raw_headers = HttpUtil::AssembleRawHeaders( | |
96 fake_response_headers.data(), fake_response_headers.length()); | |
97 response->headers = new HttpResponseHeaders(raw_headers); | |
98 return true; | |
99 } | |
100 | |
101 // static | |
102 bool ProxyClientSocket::SanitizeProxyRedirect(HttpResponseInfo* response) { | |
77 DCHECK(response && response->headers.get()); | 103 DCHECK(response && response->headers.get()); |
78 | 104 |
79 std::string location; | 105 std::string location; |
80 if (!response->headers->IsRedirect(&location)) | 106 if (!response->headers->IsRedirect(&location)) |
81 return false; | 107 return false; |
82 | 108 |
83 // Return minimal headers; set "Content-length: 0" to ignore response body. | 109 // Return minimal headers; set "Content-Length: 0" to ignore response body. |
84 std::string fake_response_headers = | 110 std::string fake_response_headers = base::StringPrintf( |
85 base::StringPrintf("HTTP/1.0 302 Found\n" | 111 "HTTP/1.1 302 Found\n" |
Ryan Sleevi
2014/12/08 22:04:40
Note: While this may seem trivial, it's going to r
Ryan Hamilton
2014/12/08 22:53:48
From my reading, I think there are no required res
Deprecated (see juliatuttle)
2014/12/09 15:31:15
I can make them both 1.0, but that would break kee
| |
86 "Location: %s\n" | 112 "Location: %s\n" |
87 "Content-length: 0\n" | 113 "Content-Length: 0\n" |
88 "Connection: close\n" | 114 "Connection: close\n" |
89 "\n", | 115 "\n", |
90 location.c_str()); | 116 location.c_str()); |
91 std::string raw_headers = | 117 std::string raw_headers = |
92 HttpUtil::AssembleRawHeaders(fake_response_headers.data(), | 118 HttpUtil::AssembleRawHeaders(fake_response_headers.data(), |
93 fake_response_headers.length()); | 119 fake_response_headers.length()); |
94 response->headers = new HttpResponseHeaders(raw_headers); | 120 response->headers = new HttpResponseHeaders(raw_headers); |
95 | 121 |
96 return true; | 122 return true; |
97 } | 123 } |
98 | 124 |
99 } // namespace net | 125 } // namespace net |
OLD | NEW |