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

Unified Diff: extensions/browser/api/web_request/web_request_api_helpers.cc

Issue 1315643005: Use EnumerateHeaderLines to parse added headers in webRequest API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « chrome/browser/extensions/api/web_request/web_request_api_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/web_request/web_request_api_helpers.cc
diff --git a/extensions/browser/api/web_request/web_request_api_helpers.cc b/extensions/browser/api/web_request/web_request_api_helpers.cc
index fae5cdc212e2a38edaad011de1ad44b86ea16ee9..35060deaa6f62213b62887da7f36190369014950 100644
--- a/extensions/browser/api/web_request/web_request_api_helpers.cc
+++ b/extensions/browser/api/web_request/web_request_api_helpers.cc
@@ -361,17 +361,21 @@ EventResponseDelta* CalculateOnHeadersReceivedDelta(
// Find added headers (header keys are treated case insensitively).
{
- for (ResponseHeaders::const_iterator i = new_response_headers->begin();
- i != new_response_headers->end(); ++i) {
- void* iter = NULL;
+ for (const auto& i : *new_response_headers) {
+ std::string name_lowercase = base::ToLowerASCII(i.first);
+ void* iter = nullptr;
not at google - send to devlin 2015/09/08 22:55:34 I presume you don't need |iter| for anything?
robwu 2015/09/08 23:00:21 iter is just used to keep track of the header iter
+ std::string name;
std::string value;
bool header_found = false;
- while (old_response_headers->EnumerateHeader(&iter, i->first, &value) &&
- !header_found) {
- header_found = (value == i->second);
+ while (old_response_headers->EnumerateHeaderLines(&iter, &name, &value)) {
+ if (base::LowerCaseEqualsASCII(name, name_lowercase) &&
not at google - send to devlin 2015/09/08 22:55:34 Seems like you could use EqualsCaseInsensitiveASCI
robwu 2015/09/08 23:00:20 Possibly, but transforming once to lowercase and s
+ value == i.second) {
+ header_found = true;
+ break;
+ }
}
if (!header_found)
- result->added_response_headers.push_back(*i);
+ result->added_response_headers.push_back(i);
}
}
« no previous file with comments | « chrome/browser/extensions/api/web_request/web_request_api_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698