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

Unified Diff: net/http/http_response_headers.cc

Issue 2670013002: net: remove GetNormalizedHeaders() function (Closed)
Patch Set: n Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_response_headers.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_response_headers.cc
diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc
index d5ab1e87cabaf4cfff8e2d971820de2a14429b6e..d0b2fc18ced38245b5b8397e33a3fe22f4cee804 100644
--- a/net/http/http_response_headers.cc
+++ b/net/http/http_response_headers.cc
@@ -460,60 +460,6 @@ void HttpResponseHeaders::Parse(const std::string& raw_input) {
DCHECK_EQ('\0', raw_headers_[raw_headers_.size() - 1]);
}
-// Append all of our headers to the final output string.
-void HttpResponseHeaders::GetNormalizedHeaders(std::string* output) const {
- // copy up to the null byte. this just copies the status line.
- output->assign(raw_headers_.c_str());
-
- // headers may appear multiple times (not necessarily in succession) in the
- // header data, so we build a map from header name to generated header lines.
- // to preserve the order of the original headers, the actual values are kept
- // in a separate list. finally, the list of headers is flattened to form
- // the normalized block of headers.
- //
- // NOTE: We take special care to preserve the whitespace around any commas
- // that may occur in the original response headers. Because our consumer may
- // be a web app, we cannot be certain of the semantics of commas despite the
- // fact that RFC 2616 says that they should be regarded as value separators.
- //
- using HeadersMap = std::unordered_map<std::string, size_t>;
- HeadersMap headers_map;
- HeadersMap::iterator iter = headers_map.end();
-
- std::vector<std::string> headers;
-
- for (size_t i = 0; i < parsed_.size(); ++i) {
- DCHECK(!parsed_[i].is_continuation());
-
- std::string name(parsed_[i].name_begin, parsed_[i].name_end);
- std::string lower_name = base::ToLowerASCII(name);
-
- iter = headers_map.find(lower_name);
- if (iter == headers_map.end()) {
- iter = headers_map.insert(
- HeadersMap::value_type(lower_name, headers.size())).first;
- headers.push_back(name + ": ");
- } else {
- headers[iter->second].append(", ");
- }
-
- std::string::const_iterator value_begin = parsed_[i].value_begin;
- std::string::const_iterator value_end = parsed_[i].value_end;
- while (++i < parsed_.size() && parsed_[i].is_continuation())
- value_end = parsed_[i].value_end;
- --i;
-
- headers[iter->second].append(value_begin, value_end);
- }
-
- for (size_t i = 0; i < headers.size(); ++i) {
- output->push_back('\n');
- output->append(headers[i]);
- }
-
- output->push_back('\n');
-}
-
bool HttpResponseHeaders::GetNormalizedHeader(const std::string& name,
std::string* value) const {
// If you hit this assertion, please use EnumerateHeader instead!
« no previous file with comments | « net/http/http_response_headers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698