| 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 #include <stdint.h> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // "Range" header is defined in RFC 7233 Section 2.1. | 53 // "Range" header is defined in RFC 7233 Section 2.1. |
| 54 // https://tools.ietf.org/html/rfc7233#section-2.1 | 54 // https://tools.ietf.org/html/rfc7233#section-2.1 |
| 55 static bool ParseRanges(const std::string& headers, | 55 static bool ParseRanges(const std::string& headers, |
| 56 std::vector<HttpByteRange>* ranges); | 56 std::vector<HttpByteRange>* ranges); |
| 57 | 57 |
| 58 // 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 |
| 59 // is directly passed in, rather than requiring searching through a string. | 59 // is directly passed in, rather than requiring searching through a string. |
| 60 static bool ParseRangeHeader(const std::string& range_specifier, | 60 static bool ParseRangeHeader(const std::string& range_specifier, |
| 61 std::vector<HttpByteRange>* ranges); | 61 std::vector<HttpByteRange>* ranges); |
| 62 | 62 |
| 63 // Extracts the values in a Content-Range header and returns true if they are | 63 // Extracts the values in a Content-Range header and returns true if all three |
| 64 // valid for a 206 response; otherwise returns false. | 64 // values are present and valid for a 206 response; otherwise returns false. |
| 65 // The following values will be outputted: | 65 // The following values will be outputted: |
| 66 // |*first_byte_position| = inclusive position of the first byte of the range | 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 | 67 // |*last_byte_position| = inclusive position of the last byte of the range |
| 68 // |*instance_length| = size in bytes of the object requested | 68 // |*instance_length| = size in bytes of the object requested |
| 69 // If any of the above values is unknown, its value will be -1. | 69 // If this method returns false, then all of the outputs will be -1. |
| 70 // TODO(sclittle): Change this method to only support Content-Range headers | 70 static bool ParseContentRangeHeaderFor206( |
| 71 // from 206 responses, since right now it only has incomplete support for | 71 base::StringPiece content_range_spec, |
| 72 // Content-Range headers from 416 responses. See crbug.com/670913. | 72 int64_t* first_byte_position, |
| 73 static bool ParseContentRangeHeader(base::StringPiece content_range_spec, | 73 int64_t* last_byte_position, |
| 74 int64_t* first_byte_position, | 74 int64_t* instance_length); |
| 75 int64_t* last_byte_position, | |
| 76 int64_t* instance_length); | |
| 77 | 75 |
| 78 // Parses a Retry-After header that is either an absolute date/time or a | 76 // Parses a Retry-After header that is either an absolute date/time or a |
| 79 // number of seconds in the future. Interprets absolute times as relative to | 77 // number of seconds in the future. Interprets absolute times as relative to |
| 80 // |now|. If |retry_after_string| is successfully parsed and indicates a time | 78 // |now|. If |retry_after_string| is successfully parsed and indicates a time |
| 81 // that is not in the past, fills in |*retry_after| and returns true; | 79 // that is not in the past, fills in |*retry_after| and returns true; |
| 82 // otherwise, returns false. | 80 // otherwise, returns false. |
| 83 static bool ParseRetryAfterHeader(const std::string& retry_after_string, | 81 static bool ParseRetryAfterHeader(const std::string& retry_after_string, |
| 84 base::Time now, | 82 base::Time now, |
| 85 base::TimeDelta* retry_after); | 83 base::TimeDelta* retry_after); |
| 86 | 84 |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 // True if quotes values are required to be properly quoted; false if | 452 // True if quotes values are required to be properly quoted; false if |
| 455 // mismatched quotes and other problems with quoted values should be more | 453 // mismatched quotes and other problems with quoted values should be more |
| 456 // or less gracefully treated as valid. | 454 // or less gracefully treated as valid. |
| 457 bool strict_quotes_; | 455 bool strict_quotes_; |
| 458 }; | 456 }; |
| 459 }; | 457 }; |
| 460 | 458 |
| 461 } // namespace net | 459 } // namespace net |
| 462 | 460 |
| 463 #endif // NET_HTTP_HTTP_UTIL_H_ | 461 #endif // NET_HTTP_HTTP_UTIL_H_ |
| OLD | NEW |