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

Unified Diff: net/http/http_util.cc

Issue 2624213002: net: remove AppendHeaderIfMissing() from HttpUtil (Closed)
Patch Set: Created 3 years, 11 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_util.h ('k') | net/http/http_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_util.cc
diff --git a/net/http/http_util.cc b/net/http/http_util.cc
index bb980bd0d33b4b4e86cb919a3bba4f7d64592b0e..62bed8c449c09098bd5d703be0a7172066d2050d 100644
--- a/net/http/http_util.cc
+++ b/net/http/http_util.cc
@@ -312,30 +312,8 @@ bool HttpUtil::ParseRetryAfterHeader(const std::string& retry_after_string,
return true;
}
-// static
-bool HttpUtil::HasHeader(const std::string& headers, const char* name) {
- size_t name_len = strlen(name);
- std::string::const_iterator it =
- std::search(headers.begin(),
- headers.end(),
- name,
- name + name_len,
- base::CaseInsensitiveCompareASCII<char>());
- if (it == headers.end())
- return false;
-
- // ensure match is prefixed by newline
- if (it != headers.begin() && it[-1] != '\n')
- return false;
-
- // ensure match is suffixed by colon
- if (it + name_len >= headers.end() || it[name_len] != ':')
- return false;
-
- return true;
-}
-
namespace {
+
// A header string containing any of the following fields will cause
// an error. The list comes from the XMLHttpRequest standard.
// http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader-method
@@ -362,7 +340,8 @@ const char* const kForbiddenHeaderFields[] = {
"user-agent",
"via",
};
-} // anonymous namespace
+
+} // namespace
// static
bool HttpUtil::IsSafeHeader(const std::string& name) {
@@ -781,16 +760,6 @@ std::string HttpUtil::GenerateAcceptLanguageHeader(
return lang_list_with_q;
}
-void HttpUtil::AppendHeaderIfMissing(const char* header_name,
- const std::string& header_value,
- std::string* headers) {
- if (header_value.empty())
- return;
- if (HttpUtil::HasHeader(*headers, header_name))
- return;
- *headers += std::string(header_name) + ": " + header_value + "\r\n";
-}
-
bool HttpUtil::HasStrongValidators(HttpVersion version,
const std::string& etag_header,
const std::string& last_modified_header,
« no previous file with comments | « net/http/http_util.h ('k') | net/http/http_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698