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

Unified Diff: net/http/http_vary_data.cc

Issue 1604011: Use HttpRequestHeaders for extra_headers. (Closed)
Patch Set: Address eroman comments. Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_vary_data.h ('k') | net/http/http_vary_data_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_vary_data.cc
diff --git a/net/http/http_vary_data.cc b/net/http/http_vary_data.cc
index fa7a3254eef5f7b684b2c3d7a4538d50a6504e8a..f5c75141a18fbb3955cae151c854975b320a19de 100644
--- a/net/http/http_vary_data.cc
+++ b/net/http/http_vary_data.cc
@@ -8,6 +8,7 @@
#include "base/pickle.h"
#include "base/string_util.h"
+#include "net/http/http_request_headers.h"
#include "net/http/http_request_info.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
@@ -97,33 +98,18 @@ std::string HttpVaryData::GetRequestValue(
const HttpRequestInfo& request_info,
const std::string& request_header) {
// Some special cases:
- if (LowerCaseEqualsASCII(request_header, "referer"))
+ if (!base::strcasecmp(request_header.c_str(), HttpRequestHeaders::kReferer))
return request_info.referrer.spec();
- if (LowerCaseEqualsASCII(request_header, "user-agent"))
- return request_info.user_agent;
-
- std::string result;
-
- // Check extra headers:
- HttpUtil::HeadersIterator it(request_info.extra_headers.begin(),
- request_info.extra_headers.end(),
- "\r\n");
- while (it.GetNext()) {
- size_t name_len = it.name_end() - it.name_begin();
- if (request_header.size() == name_len &&
- std::equal(it.name_begin(), it.name_end(), request_header.begin(),
- CaseInsensitiveCompare<char>())) {
- if (!result.empty())
- result.append(1, ',');
- result.append(it.values());
- }
- }
// Unfortunately, we do not have access to all of the request headers at this
// point. Most notably, we do not have access to an Authorization header if
// one will be added to the request.
- return result;
+ std::string result;
+ if (request_info.extra_headers.GetHeader(request_header, &result))
+ return result;
+
+ return "";
}
// static
« no previous file with comments | « net/http/http_vary_data.h ('k') | net/http/http_vary_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698