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

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

Issue 1897033002: Reland 'Convert //net and //chromecast to std::unordered_*' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix TestDownloadRequestHandler Created 4 years, 8 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/http_response_headers.h ('k') | net/http/http_server_properties_impl_unittest.cc » ('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 // The rules for header parsing were borrowed from Firefox: 5 // The rules for header parsing were borrowed from Firefox:
6 // http://lxr.mozilla.org/seamonkey/source/netwerk/protocol/http/src/nsHttpRespo nseHead.cpp 6 // http://lxr.mozilla.org/seamonkey/source/netwerk/protocol/http/src/nsHttpRespo nseHead.cpp
7 // The rules for parsing content-types were also borrowed from Firefox: 7 // The rules for parsing content-types were also borrowed from Firefox:
8 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 8 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834
9 9
10 #include "net/http/http_response_headers.h" 10 #include "net/http/http_response_headers.h"
11 11
12 #include <algorithm> 12 #include <algorithm>
13 #include <unordered_map>
13 #include <utility> 14 #include <utility>
14 15
15 #include "base/format_macros.h" 16 #include "base/format_macros.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/metrics/histogram_macros.h" 18 #include "base/metrics/histogram_macros.h"
18 #include "base/pickle.h" 19 #include "base/pickle.h"
19 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_piece.h" 21 #include "base/strings/string_piece.h"
21 #include "base/strings/string_util.h" 22 #include "base/strings/string_util.h"
22 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // header data, so we build a map from header name to generated header lines. 451 // header data, so we build a map from header name to generated header lines.
451 // to preserve the order of the original headers, the actual values are kept 452 // to preserve the order of the original headers, the actual values are kept
452 // in a separate list. finally, the list of headers is flattened to form 453 // in a separate list. finally, the list of headers is flattened to form
453 // the normalized block of headers. 454 // the normalized block of headers.
454 // 455 //
455 // NOTE: We take special care to preserve the whitespace around any commas 456 // NOTE: We take special care to preserve the whitespace around any commas
456 // that may occur in the original response headers. Because our consumer may 457 // that may occur in the original response headers. Because our consumer may
457 // be a web app, we cannot be certain of the semantics of commas despite the 458 // be a web app, we cannot be certain of the semantics of commas despite the
458 // fact that RFC 2616 says that they should be regarded as value separators. 459 // fact that RFC 2616 says that they should be regarded as value separators.
459 // 460 //
460 typedef base::hash_map<std::string, size_t> HeadersMap; 461 using HeadersMap = std::unordered_map<std::string, size_t>;
461 HeadersMap headers_map; 462 HeadersMap headers_map;
462 HeadersMap::iterator iter = headers_map.end(); 463 HeadersMap::iterator iter = headers_map.end();
463 464
464 std::vector<std::string> headers; 465 std::vector<std::string> headers;
465 466
466 for (size_t i = 0; i < parsed_.size(); ++i) { 467 for (size_t i = 0; i < parsed_.size(); ++i) {
467 DCHECK(!parsed_[i].is_continuation()); 468 DCHECK(!parsed_[i].is_continuation());
468 469
469 std::string name(parsed_[i].name_begin, parsed_[i].name_end); 470 std::string name(parsed_[i].name_begin, parsed_[i].name_end);
470 std::string lower_name = base::ToLowerASCII(name); 471 std::string lower_name = base::ToLowerASCII(name);
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 return true; 1465 return true;
1465 } 1466 }
1466 1467
1467 bool HttpResponseHeaders::IsChunkEncoded() const { 1468 bool HttpResponseHeaders::IsChunkEncoded() const {
1468 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. 1469 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies.
1469 return GetHttpVersion() >= HttpVersion(1, 1) && 1470 return GetHttpVersion() >= HttpVersion(1, 1) &&
1470 HasHeaderValue("Transfer-Encoding", "chunked"); 1471 HasHeaderValue("Transfer-Encoding", "chunked");
1471 } 1472 }
1472 1473
1473 } // namespace net 1474 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_response_headers.h ('k') | net/http/http_server_properties_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698