| 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 "trailer", | 338 "trailer", |
| 339 "transfer-encoding", | 339 "transfer-encoding", |
| 340 "upgrade", | 340 "upgrade", |
| 341 "user-agent", | 341 "user-agent", |
| 342 "via", | 342 "via", |
| 343 }; | 343 }; |
| 344 | 344 |
| 345 } // namespace | 345 } // namespace |
| 346 | 346 |
| 347 // static | 347 // static |
| 348 bool HttpUtil::IsMethodSafe(const std::string& method) { |
| 349 return method == "GET" || method == "HEAD" || method == "OPTIONS" || |
| 350 method == "TRACE"; |
| 351 } |
| 352 |
| 353 // static |
| 348 bool HttpUtil::IsSafeHeader(const std::string& name) { | 354 bool HttpUtil::IsSafeHeader(const std::string& name) { |
| 349 std::string lower_name(base::ToLowerASCII(name)); | 355 std::string lower_name(base::ToLowerASCII(name)); |
| 350 if (base::StartsWith(lower_name, "proxy-", base::CompareCase::SENSITIVE) || | 356 if (base::StartsWith(lower_name, "proxy-", base::CompareCase::SENSITIVE) || |
| 351 base::StartsWith(lower_name, "sec-", base::CompareCase::SENSITIVE)) | 357 base::StartsWith(lower_name, "sec-", base::CompareCase::SENSITIVE)) |
| 352 return false; | 358 return false; |
| 353 | 359 |
| 354 for (const char* field : kForbiddenHeaderFields) { | 360 for (const char* field : kForbiddenHeaderFields) { |
| 355 if (lower_name == field) | 361 if (lower_name == field) |
| 356 return false; | 362 return false; |
| 357 } | 363 } |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 while (encoding_tokenizer.GetNext()) { | 1153 while (encoding_tokenizer.GetNext()) { |
| 1148 base::StringPiece encoding = TrimLWS(encoding_tokenizer.token_piece()); | 1154 base::StringPiece encoding = TrimLWS(encoding_tokenizer.token_piece()); |
| 1149 if (encoding.find_first_of(HTTP_LWS) != base::StringPiece::npos) | 1155 if (encoding.find_first_of(HTTP_LWS) != base::StringPiece::npos) |
| 1150 return false; | 1156 return false; |
| 1151 used_encodings->insert(base::ToLowerASCII(encoding)); | 1157 used_encodings->insert(base::ToLowerASCII(encoding)); |
| 1152 } | 1158 } |
| 1153 return true; | 1159 return true; |
| 1154 } | 1160 } |
| 1155 | 1161 |
| 1156 } // namespace net | 1162 } // namespace net |
| OLD | NEW |