OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 285 } |
286 | 286 |
287 // static | 287 // static |
288 bool HttpUtil::HasHeader(const std::string& headers, const char* name) { | 288 bool HttpUtil::HasHeader(const std::string& headers, const char* name) { |
289 size_t name_len = strlen(name); | 289 size_t name_len = strlen(name); |
290 string::const_iterator it = | 290 string::const_iterator it = |
291 std::search(headers.begin(), | 291 std::search(headers.begin(), |
292 headers.end(), | 292 headers.end(), |
293 name, | 293 name, |
294 name + name_len, | 294 name + name_len, |
295 CaseInsensitiveCompareASCII<char>()); | 295 base::CaseInsensitiveCompareASCII<char>()); |
296 if (it == headers.end()) | 296 if (it == headers.end()) |
297 return false; | 297 return false; |
298 | 298 |
299 // ensure match is prefixed by newline | 299 // ensure match is prefixed by newline |
300 if (it != headers.begin() && it[-1] != '\n') | 300 if (it != headers.begin() && it[-1] != '\n') |
301 return false; | 301 return false; |
302 | 302 |
303 // ensure match is suffixed by colon | 303 // ensure match is suffixed by colon |
304 if (it + name_len >= headers.end() || it[name_len] != ':') | 304 if (it + name_len >= headers.end() || it[name_len] != ':') |
305 return false; | 305 return false; |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 value_is_quoted_ = true; | 861 value_is_quoted_ = true; |
862 // Do not store iterators into this. See declaration of unquoted_value_. | 862 // Do not store iterators into this. See declaration of unquoted_value_. |
863 unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_); | 863 unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_); |
864 } | 864 } |
865 } | 865 } |
866 | 866 |
867 return true; | 867 return true; |
868 } | 868 } |
869 | 869 |
870 } // namespace net | 870 } // namespace net |
OLD | NEW |