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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 // Do a final check on the HttpByteRange object. | 283 // Do a final check on the HttpByteRange object. |
284 if (!range.IsValid()) | 284 if (!range.IsValid()) |
285 return false; | 285 return false; |
286 ranges->push_back(range); | 286 ranges->push_back(range); |
287 } | 287 } |
288 return !ranges->empty(); | 288 return !ranges->empty(); |
289 } | 289 } |
290 | 290 |
291 // static | 291 // static |
| 292 std::string HttpUtil::PrintRanges(const std::vector<HttpByteRange>& ranges) { |
| 293 DCHECK(!ranges.empty()); |
| 294 |
| 295 std::vector<std::string> printed_ranges; |
| 296 printed_ranges.reserve(ranges.size()); |
| 297 |
| 298 for (std::vector<HttpByteRange>::const_iterator it = ranges.begin(); |
| 299 it != ranges.end(); |
| 300 ++it) { |
| 301 printed_ranges.push_back(it->PrintInterval()); |
| 302 } |
| 303 |
| 304 return "bytes=" + JoinString(printed_ranges, ','); |
| 305 } |
| 306 |
| 307 // static |
| 308 std::string HttpUtil::PrintRange(const HttpByteRange& range) { |
| 309 return "bytes=" + range.PrintInterval(); |
| 310 } |
| 311 |
| 312 // static |
292 bool HttpUtil::HasHeader(const std::string& headers, const char* name) { | 313 bool HttpUtil::HasHeader(const std::string& headers, const char* name) { |
293 size_t name_len = strlen(name); | 314 size_t name_len = strlen(name); |
294 string::const_iterator it = | 315 string::const_iterator it = |
295 std::search(headers.begin(), | 316 std::search(headers.begin(), |
296 headers.end(), | 317 headers.end(), |
297 name, | 318 name, |
298 name + name_len, | 319 name + name_len, |
299 base::CaseInsensitiveCompareASCII<char>()); | 320 base::CaseInsensitiveCompareASCII<char>()); |
300 if (it == headers.end()) | 321 if (it == headers.end()) |
301 return false; | 322 return false; |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 value_is_quoted_ = true; | 932 value_is_quoted_ = true; |
912 // Do not store iterators into this. See declaration of unquoted_value_. | 933 // Do not store iterators into this. See declaration of unquoted_value_. |
913 unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_); | 934 unquoted_value_ = HttpUtil::Unquote(value_begin_, value_end_); |
914 } | 935 } |
915 } | 936 } |
916 | 937 |
917 return true; | 938 return true; |
918 } | 939 } |
919 | 940 |
920 } // namespace net | 941 } // namespace net |
OLD | NEW |