Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: net/http/http_util.h

Issue 2549143003: Cleaned up the API of HttpUtil::ParseContentRangeHeader(). (Closed)
Patch Set: Initial patch set Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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, 70 static bool ParseContentRangeHeader(base::StringPiece content_range_spec,
74 int64_t* first_byte_position, 71 int64_t* first_byte_position,
75 int64_t* last_byte_position, 72 int64_t* last_byte_position,
76 int64_t* instance_length); 73 int64_t* instance_length);
77 74
78 // Parses a Retry-After header that is either an absolute date/time or a 75 // 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 76 // 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 77 // |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; 78 // that is not in the past, fills in |*retry_after| and returns true;
82 // otherwise, returns false. 79 // otherwise, returns false.
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 // True if quotes values are required to be properly quoted; false if 453 // True if quotes values are required to be properly quoted; false if
457 // mismatched quotes and other problems with quoted values should be more 454 // mismatched quotes and other problems with quoted values should be more
458 // or less gracefully treated as valid. 455 // or less gracefully treated as valid.
459 bool strict_quotes_; 456 bool strict_quotes_;
460 }; 457 };
461 }; 458 };
462 459
463 } // namespace net 460 } // namespace net
464 461
465 #endif // NET_HTTP_HTTP_UTIL_H_ 462 #endif // NET_HTTP_HTTP_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698