diff options
author | ttuttle@chromium.org <ttuttle@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-09 05:40:17 +0000 |
---|---|---|
committer | ttuttle@chromium.org <ttuttle@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-09 05:40:17 +0000 |
commit | 4eddbc735618575805c304bcee9f50d4fe4b68e7 (patch) | |
tree | 49ddcf08fad02125d5606589fe5b777a802fdc4e /net/http/http_util.cc | |
parent | 16e2ba27dbbb74a0dc2a85db91746b6e9d8abd63 (diff) | |
download | chromium_src-4eddbc735618575805c304bcee9f50d4fe4b68e7.zip chromium_src-4eddbc735618575805c304bcee9f50d4fe4b68e7.tar.gz chromium_src-4eddbc735618575805c304bcee9f50d4fe4b68e7.tar.bz2 |
Fix proxy CONNECT response handling
Don't trust most non-success responses to a CONNECT request -- as the BUG=
explains, the rest of the stack will treat the response as if it came from
the target server, not the proxy. This trivially lets a proxy run code as
any HTTPS site the user tries to connect to, which is Very Badâ„¢.
Do, however, accept 302 responses, but sanitize them so they contain only
the Location header and no response body. Many proxies use this for login
pages, so we can't break it.
Update the HttpProxyClientSocketPool unittests to expect failure in all but
the 302 case, and add a 302-specific test case.
BUG=137891
TEST=Added cases to Http- and SpdyProxyClientSocket unittests. net_unittests pass.
Review URL: https://chromiumcodereview.appspot.com/10825030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_util.cc')
-rw-r--r-- | net/http/http_util.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/net/http/http_util.cc b/net/http/http_util.cc index a4c6266..43be4f0 100644 --- a/net/http/http_util.cc +++ b/net/http/http_util.cc @@ -730,6 +730,36 @@ bool HttpUtil::HasStrongValidators(HttpVersion version, return ((date - last_modified).InSeconds() >= 60); } +// Functions for histogram initialization. The code 0 is put in the map to +// track status codes that are invalid. +// TODO(gavinp): Greatly prune the collected codes once we learn which +// ones are not sent in practice, to reduce upload size & memory use. + +enum { + HISTOGRAM_MIN_HTTP_STATUS_CODE = 100, + HISTOGRAM_MAX_HTTP_STATUS_CODE = 599, +}; + +// static +std::vector<int> HttpUtil::GetStatusCodesForHistogram() { + std::vector<int> codes; + codes.reserve( + HISTOGRAM_MAX_HTTP_STATUS_CODE - HISTOGRAM_MIN_HTTP_STATUS_CODE + 2); + codes.push_back(0); + for (int i = HISTOGRAM_MIN_HTTP_STATUS_CODE; + i <= HISTOGRAM_MAX_HTTP_STATUS_CODE; ++i) + codes.push_back(i); + return codes; +} + +// static +int HttpUtil::MapStatusCodeForHistogram(int code) { + if (HISTOGRAM_MIN_HTTP_STATUS_CODE <= code && + code <= HISTOGRAM_MAX_HTTP_STATUS_CODE) + return code; + return 0; +} + // BNF from section 4.2 of RFC 2616: // // message-header = field-name ":" [ field-value ] |