Index: net/http/http_response_headers.cc |
diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc |
index f26292a08117a1791f1504cf4591884d801d011a..7a448e79c0e517c3a55e5a6d084fc67b28a431df 100644 |
--- a/net/http/http_response_headers.cc |
+++ b/net/http/http_response_headers.cc |
@@ -11,6 +11,7 @@ |
#include <algorithm> |
+#include "base/format_macros.h" |
#include "base/logging.h" |
#include "base/metrics/histogram.h" |
#include "base/pickle.h" |
@@ -21,6 +22,7 @@ |
#include "base/time/time.h" |
#include "base/values.h" |
#include "net/base/escape.h" |
+#include "net/http/http_byte_range.h" |
#include "net/http/http_util.h" |
using base::StringPiece; |
@@ -374,6 +376,30 @@ void HttpResponseHeaders::ReplaceStatusLine(const std::string& new_status) { |
MergeWithHeaders(new_raw_headers, empty_to_remove); |
} |
+void HttpResponseHeaders::UpdateWithNewRange( |
+ const HttpByteRange& byte_range, |
+ int64 resource_size, |
+ bool replace_status_line) { |
+ DCHECK(byte_range.IsValid()); |
mmenke
2014/03/06 18:18:48
Maybe add:
DCHECK(!byte_range.suffix_length());
D
rvargas (doing something else)
2014/03/06 19:24:00
Excellent point. Now that this lives here we canno
kinuko
2014/03/07 05:05:14
Added DCHECKs for HasFirstBytePosition/HasLastByte
|
+ |
+ const char kLengthHeader[] = "Content-Length"; |
+ const char kRangeHeader[] = "Content-Range"; |
+ |
+ RemoveHeader(kLengthHeader); |
+ RemoveHeader(kRangeHeader); |
+ |
+ int64 start = byte_range.first_byte_position(); |
+ int64 end = byte_range.last_byte_position(); |
+ int64 range_len = end - start + 1; |
+ |
+ if (replace_status_line) |
+ ReplaceStatusLine("HTTP/1.1 206 Partial Content"); |
+ |
+ AddHeader(base::StringPrintf("%s: bytes %" PRId64 "-%" PRId64 "/%" PRId64, |
+ kRangeHeader, start, end, resource_size)); |
+ AddHeader(base::StringPrintf("%s: %" PRId64, kLengthHeader, range_len)); |
+} |
+ |
void HttpResponseHeaders::Parse(const std::string& raw_input) { |
raw_headers_.reserve(raw_input.size()); |