| Index: net/http/http_response_headers.cc
|
| diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc
|
| index 2d74b38efc767f13bcaacdbfc811970de8f2946e..dbe09a6734b65a5d8e6f994949b3ef2901cd53ad 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,32 @@ 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());
|
| + DCHECK(byte_range.HasFirstBytePosition());
|
| + DCHECK(byte_range.HasLastBytePosition());
|
| +
|
| + 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());
|
|
|
|
|