| 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 344 |
| 345 } // namespace | 345 } // namespace |
| 346 | 346 |
| 347 // static | 347 // static |
| 348 bool HttpUtil::IsMethodSafe(const std::string& method) { | 348 bool HttpUtil::IsMethodSafe(const std::string& method) { |
| 349 return method == "GET" || method == "HEAD" || method == "OPTIONS" || | 349 return method == "GET" || method == "HEAD" || method == "OPTIONS" || |
| 350 method == "TRACE"; | 350 method == "TRACE"; |
| 351 } | 351 } |
| 352 | 352 |
| 353 // static | 353 // static |
| 354 bool HttpUtil::IsMethodIdempotent(const std::string& method) { |
| 355 return IsMethodSafe(method) || method == "PUT" || method == "DELETE"; |
| 356 } |
| 357 |
| 358 // static |
| 354 bool HttpUtil::IsSafeHeader(const std::string& name) { | 359 bool HttpUtil::IsSafeHeader(const std::string& name) { |
| 355 std::string lower_name(base::ToLowerASCII(name)); | 360 std::string lower_name(base::ToLowerASCII(name)); |
| 356 if (base::StartsWith(lower_name, "proxy-", base::CompareCase::SENSITIVE) || | 361 if (base::StartsWith(lower_name, "proxy-", base::CompareCase::SENSITIVE) || |
| 357 base::StartsWith(lower_name, "sec-", base::CompareCase::SENSITIVE)) | 362 base::StartsWith(lower_name, "sec-", base::CompareCase::SENSITIVE)) |
| 358 return false; | 363 return false; |
| 359 | 364 |
| 360 for (const char* field : kForbiddenHeaderFields) { | 365 for (const char* field : kForbiddenHeaderFields) { |
| 361 if (lower_name == field) | 366 if (lower_name == field) |
| 362 return false; | 367 return false; |
| 363 } | 368 } |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 while (encoding_tokenizer.GetNext()) { | 1158 while (encoding_tokenizer.GetNext()) { |
| 1154 base::StringPiece encoding = TrimLWS(encoding_tokenizer.token_piece()); | 1159 base::StringPiece encoding = TrimLWS(encoding_tokenizer.token_piece()); |
| 1155 if (encoding.find_first_of(HTTP_LWS) != base::StringPiece::npos) | 1160 if (encoding.find_first_of(HTTP_LWS) != base::StringPiece::npos) |
| 1156 return false; | 1161 return false; |
| 1157 used_encodings->insert(base::ToLowerASCII(encoding)); | 1162 used_encodings->insert(base::ToLowerASCII(encoding)); |
| 1158 } | 1163 } |
| 1159 return true; | 1164 return true; |
| 1160 } | 1165 } |
| 1161 | 1166 |
| 1162 } // namespace net | 1167 } // namespace net |
| OLD | NEW |