| 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 #ifndef NET_HTTP_HTTP_UTIL_H_ | 5 #ifndef NET_HTTP_HTTP_UTIL_H_ |
| 6 #define NET_HTTP_HTTP_UTIL_H_ | 6 #define NET_HTTP_HTTP_UTIL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 9 | 10 |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
| 16 #include "base/strings/string_tokenizer.h" | 17 #include "base/strings/string_tokenizer.h" |
| 17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 18 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // "Range" header is defined in RFC 7233 Section 2.1. | 53 // "Range" header is defined in RFC 7233 Section 2.1. |
| 53 // https://tools.ietf.org/html/rfc7233#section-2.1 | 54 // https://tools.ietf.org/html/rfc7233#section-2.1 |
| 54 static bool ParseRanges(const std::string& headers, | 55 static bool ParseRanges(const std::string& headers, |
| 55 std::vector<HttpByteRange>* ranges); | 56 std::vector<HttpByteRange>* ranges); |
| 56 | 57 |
| 57 // Same thing as ParseRanges except the Range header is known and its value | 58 // Same thing as ParseRanges except the Range header is known and its value |
| 58 // is directly passed in, rather than requiring searching through a string. | 59 // is directly passed in, rather than requiring searching through a string. |
| 59 static bool ParseRangeHeader(const std::string& range_specifier, | 60 static bool ParseRangeHeader(const std::string& range_specifier, |
| 60 std::vector<HttpByteRange>* ranges); | 61 std::vector<HttpByteRange>* ranges); |
| 61 | 62 |
| 63 // Extracts the values in a Content-Range header and returns true if they are |
| 64 // valid for a 206 response; otherwise returns false. |
| 65 // The following values will be outputted: |
| 66 // |*first_byte_position| = inclusive position of the first byte of the range |
| 67 // |*last_byte_position| = inclusive position of the last byte of the range |
| 68 // |*instance_length| = size in bytes of the object requested |
| 69 // If any of the above values is unknown, its value will be -1. |
| 70 // TODO(sclittle): Change this method to only support Content-Range headers |
| 71 // from 206 responses, since right now it only has incomplete support for |
| 72 // Content-Range headers from 416 responses. See crbug.com/670913. |
| 73 static bool ParseContentRangeHeader(base::StringPiece content_range_spec, |
| 74 int64_t* first_byte_position, |
| 75 int64_t* last_byte_position, |
| 76 int64_t* instance_length); |
| 77 |
| 62 // Parses a Retry-After header that is either an absolute date/time or a | 78 // Parses a Retry-After header that is either an absolute date/time or a |
| 63 // number of seconds in the future. Interprets absolute times as relative to | 79 // number of seconds in the future. Interprets absolute times as relative to |
| 64 // |now|. If |retry_after_string| is successfully parsed and indicates a time | 80 // |now|. If |retry_after_string| is successfully parsed and indicates a time |
| 65 // that is not in the past, fills in |*retry_after| and returns true; | 81 // that is not in the past, fills in |*retry_after| and returns true; |
| 66 // otherwise, returns false. | 82 // otherwise, returns false. |
| 67 static bool ParseRetryAfterHeader(const std::string& retry_after_string, | 83 static bool ParseRetryAfterHeader(const std::string& retry_after_string, |
| 68 base::Time now, | 84 base::Time now, |
| 69 base::TimeDelta* retry_after); | 85 base::TimeDelta* retry_after); |
| 70 | 86 |
| 71 // Scans the '\r\n'-delimited headers for the given header name. Returns | 87 // Scans the '\r\n'-delimited headers for the given header name. Returns |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 // True if quotes values are required to be properly quoted; false if | 456 // True if quotes values are required to be properly quoted; false if |
| 441 // mismatched quotes and other problems with quoted values should be more | 457 // mismatched quotes and other problems with quoted values should be more |
| 442 // or less gracefully treated as valid. | 458 // or less gracefully treated as valid. |
| 443 bool strict_quotes_; | 459 bool strict_quotes_; |
| 444 }; | 460 }; |
| 445 }; | 461 }; |
| 446 | 462 |
| 447 } // namespace net | 463 } // namespace net |
| 448 | 464 |
| 449 #endif // NET_HTTP_HTTP_UTIL_H_ | 465 #endif // NET_HTTP_HTTP_UTIL_H_ |
| OLD | NEW |