| OLD | NEW |
| 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 Loading... |
| 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; |
| 351 } | 352 } |
| 352 return true; | 353 return true; |
| 353 } | 354 } |
| 354 | 355 |
| 355 // static | 356 // static |
| 356 bool HttpUtil::IsValidHeaderName(const base::StringPiece& name) { | 357 bool HttpUtil::IsValidHeaderName(const base::StringPiece& name) { |
| 357 // Check whether the header name is RFC 2616-compliant. | 358 // Check whether the header name is RFC 2616-compliant. |
| 358 return HttpUtil::IsToken(name); | 359 return HttpUtil::IsToken(name); |
| 359 } | 360 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 "retry-after", | 408 "retry-after", |
| 408 "set-cookie", | 409 "set-cookie", |
| 409 // The format of auth-challenges mixes both space separated tokens and | 410 // The format of auth-challenges mixes both space separated tokens and |
| 410 // comma separated properties, so coalescing on comma won't work. | 411 // comma separated properties, so coalescing on comma won't work. |
| 411 "www-authenticate", | 412 "www-authenticate", |
| 412 "proxy-authenticate", | 413 "proxy-authenticate", |
| 413 // STS specifies that UAs must not process any STS headers after the first | 414 // STS specifies that UAs must not process any STS headers after the first |
| 414 // one. | 415 // one. |
| 415 "strict-transport-security" | 416 "strict-transport-security" |
| 416 }; | 417 }; |
| 417 for (size_t i = 0; i < arraysize(kNonCoalescingHeaders); ++i) { | 418 |
| 419 for (const char* header : kNonCoalescingHeaders) { |
| 418 if (base::LowerCaseEqualsASCII(base::StringPiece(name_begin, name_end), | 420 if (base::LowerCaseEqualsASCII(base::StringPiece(name_begin, name_end), |
| 419 kNonCoalescingHeaders[i])) | 421 header)) { |
| 420 return true; | 422 return true; |
| 423 } |
| 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 Loading... |
| 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 |
| OLD | NEW |