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

Unified Diff: net/http/http_util.h

Issue 2545213002: Refactor Content-Range response header parsing into http_util (Closed)
Patch Set: Addressed mmenke comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_response_headers.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_util.h
diff --git a/net/http/http_util.h b/net/http/http_util.h
index 8658b57883782b9975ba418be71b38740a52c2c9..fe68423f6085473cd8af01f4bcbae363c063d308 100644
--- a/net/http/http_util.h
+++ b/net/http/http_util.h
@@ -6,6 +6,7 @@
#define NET_HTTP_HTTP_UTIL_H_
#include <stddef.h>
+#include <stdint.h>
#include <string>
#include <vector>
@@ -59,6 +60,21 @@ class NET_EXPORT HttpUtil {
static bool ParseRangeHeader(const std::string& range_specifier,
std::vector<HttpByteRange>* ranges);
+ // Extracts the values in a Content-Range header and returns true if they are
+ // valid for a 206 response; otherwise returns false.
+ // The following values will be outputted:
+ // |*first_byte_position| = inclusive position of the first byte of the range
+ // |*last_byte_position| = inclusive position of the last byte of the range
+ // |*instance_length| = size in bytes of the object requested
+ // If any of the above values is unknown, its value will be -1.
+ // TODO(sclittle): Change this method to only support Content-Range headers
+ // from 206 responses, since right now it only has incomplete support for
+ // Content-Range headers from 416 responses. See crbug.com/670913.
+ static bool ParseContentRangeHeader(base::StringPiece content_range_spec,
+ int64_t* first_byte_position,
+ int64_t* last_byte_position,
+ int64_t* instance_length);
+
// Parses a Retry-After header that is either an absolute date/time or a
// number of seconds in the future. Interprets absolute times as relative to
// |now|. If |retry_after_string| is successfully parsed and indicates a time
« no previous file with comments | « net/http/http_response_headers.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698