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

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

Issue 2459243002: Replace for each loops (Closed)
Patch Set: Replace for each loop Created 4 years, 1 month 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 | « AUTHORS ('k') | no next file » | 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 parsing content-types were borrowed from Firefox: 5 // The rules for parsing content-types were borrowed from Firefox:
6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834
7 7
8 #include "net/http/http_util.h" 8 #include "net/http/http_util.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 "via", 338 "via",
339 }; 339 };
340 } // anonymous namespace 340 } // anonymous namespace
341 341
342 // static 342 // static
343 bool HttpUtil::IsSafeHeader(const std::string& name) { 343 bool HttpUtil::IsSafeHeader(const std::string& name) {
344 std::string lower_name(base::ToLowerASCII(name)); 344 std::string lower_name(base::ToLowerASCII(name));
345 if (base::StartsWith(lower_name, "proxy-", base::CompareCase::SENSITIVE) || 345 if (base::StartsWith(lower_name, "proxy-", base::CompareCase::SENSITIVE) ||
346 base::StartsWith(lower_name, "sec-", base::CompareCase::SENSITIVE)) 346 base::StartsWith(lower_name, "sec-", base::CompareCase::SENSITIVE))
347 return false; 347 return false;
348 for (size_t i = 0; i < arraysize(kForbiddenHeaderFields); ++i) { 348
349 if (lower_name == kForbiddenHeaderFields[i]) 349 for (const char* field : kForbiddenHeaderFields) {
350 if (lower_name == field) {
350 return false; 351 return false;
352 }
mmenke 2016/10/31 14:49:30 nit: Don't use braces for ifs with a single line
351 } 353 }
352 return true; 354 return true;
353 } 355 }
354 356
355 // static 357 // static
356 bool HttpUtil::IsValidHeaderName(const base::StringPiece& name) { 358 bool HttpUtil::IsValidHeaderName(const base::StringPiece& name) {
357 // Check whether the header name is RFC 2616-compliant. 359 // Check whether the header name is RFC 2616-compliant.
358 return HttpUtil::IsToken(name); 360 return HttpUtil::IsToken(name);
359 } 361 }
360 362
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 "retry-after", 409 "retry-after",
408 "set-cookie", 410 "set-cookie",
409 // The format of auth-challenges mixes both space separated tokens and 411 // The format of auth-challenges mixes both space separated tokens and
410 // comma separated properties, so coalescing on comma won't work. 412 // comma separated properties, so coalescing on comma won't work.
411 "www-authenticate", 413 "www-authenticate",
412 "proxy-authenticate", 414 "proxy-authenticate",
413 // STS specifies that UAs must not process any STS headers after the first 415 // STS specifies that UAs must not process any STS headers after the first
414 // one. 416 // one.
415 "strict-transport-security" 417 "strict-transport-security"
416 }; 418 };
417 for (size_t i = 0; i < arraysize(kNonCoalescingHeaders); ++i) { 419
420 for (const char* header : kNonCoalescingHeaders) {
418 if (base::LowerCaseEqualsASCII(base::StringPiece(name_begin, name_end), 421 if (base::LowerCaseEqualsASCII(base::StringPiece(name_begin, name_end),
419 kNonCoalescingHeaders[i])) 422 header))
420 return true; 423 return true;
mmenke 2016/10/31 14:49:30 nit: Mind adding braces to this if, though, while
421 } 424 }
422 return false; 425 return false;
423 } 426 }
424 427
425 bool HttpUtil::IsLWS(char c) { 428 bool HttpUtil::IsLWS(char c) {
426 return strchr(HTTP_LWS, c) != NULL; 429 return strchr(HTTP_LWS, c) != NULL;
427 } 430 }
428 431
429 // static 432 // static
430 void HttpUtil::TrimLWS(std::string::const_iterator* begin, 433 void HttpUtil::TrimLWS(std::string::const_iterator* begin,
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 return true; 1073 return true;
1071 } 1074 }
1072 1075
1073 bool HttpUtil::NameValuePairsIterator::IsQuote(char c) const { 1076 bool HttpUtil::NameValuePairsIterator::IsQuote(char c) const {
1074 if (strict_quotes_) 1077 if (strict_quotes_)
1075 return c == '"'; 1078 return c == '"';
1076 return HttpUtil::IsQuote(c); 1079 return HttpUtil::IsQuote(c);
1077 } 1080 }
1078 1081
1079 } // namespace net 1082 } // namespace net
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698