| Index: net/http/partial_data.cc
|
| diff --git a/net/http/partial_data.cc b/net/http/partial_data.cc
|
| index d199c28290b3e5d982ca6c4ee9963f7ec260f4ae..ee3678b5ea05c69ed49dd11d0309c346a1fbfec2 100644
|
| --- a/net/http/partial_data.cc
|
| +++ b/net/http/partial_data.cc
|
| @@ -25,19 +25,6 @@ const char kLengthHeader[] = "Content-Length";
|
| const char kRangeHeader[] = "Content-Range";
|
| const int kDataStream = 1;
|
|
|
| -void AddRangeHeader(int64 start, int64 end, HttpRequestHeaders* headers) {
|
| - DCHECK(start >= 0 || end >= 0);
|
| - std::string my_start, my_end;
|
| - if (start >= 0)
|
| - my_start = base::Int64ToString(start);
|
| - if (end >= 0)
|
| - my_end = base::Int64ToString(end);
|
| -
|
| - headers->SetHeader(
|
| - HttpRequestHeaders::kRange,
|
| - base::StringPrintf("bytes=%s-%s", my_start.c_str(), my_end.c_str()));
|
| -}
|
| -
|
| } // namespace
|
|
|
| // A core object that can be detached from the Partialdata object at destruction
|
| @@ -156,8 +143,17 @@ void PartialData::RestoreHeaders(HttpRequestHeaders* headers) const {
|
| byte_range_.suffix_length() : byte_range_.last_byte_position();
|
|
|
| headers->CopyFrom(extra_headers_);
|
| - if (!truncated_ && byte_range_.IsValid())
|
| - AddRangeHeader(current_range_start_, end, headers);
|
| + if (truncated_ || !byte_range_.IsValid())
|
| + return;
|
| +
|
| + if (current_range_start_ < 0) {
|
| + headers->SetHeader(HttpRequestHeaders::kRange,
|
| + HttpByteRange::Suffix(end).GetHeaderValue());
|
| + } else {
|
| + headers->SetHeader(HttpRequestHeaders::kRange,
|
| + HttpByteRange::Bounded(
|
| + current_range_start_, end).GetHeaderValue());
|
| + }
|
| }
|
|
|
| int PartialData::ShouldValidateCache(disk_cache::Entry* entry,
|
| @@ -222,11 +218,17 @@ void PartialData::PrepareCacheValidation(disk_cache::Entry* entry,
|
| range_present_ = true;
|
| if (len == cached_min_len_)
|
| final_range_ = true;
|
| - AddRangeHeader(current_range_start_, cached_start_ + cached_min_len_ - 1,
|
| - headers);
|
| + headers->SetHeader(
|
| + HttpRequestHeaders::kRange,
|
| + net::HttpByteRange::Bounded(
|
| + current_range_start_,
|
| + cached_start_ + cached_min_len_ - 1).GetHeaderValue());
|
| } else {
|
| // This range is not in the cache.
|
| - AddRangeHeader(current_range_start_, cached_start_ - 1, headers);
|
| + headers->SetHeader(
|
| + HttpRequestHeaders::kRange,
|
| + net::HttpByteRange::Bounded(
|
| + current_range_start_, cached_start_ - 1).GetHeaderValue());
|
| }
|
| }
|
|
|
|
|