OLD | NEW |
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 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "webkit/appcache/appcache_url_request_job.h" | 7 #include "webkit/appcache/appcache_url_request_job.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // Tell the reader about the range to read. | 170 // Tell the reader about the range to read. |
171 reader_->SetReadRange(offset, length); | 171 reader_->SetReadRange(offset, length); |
172 | 172 |
173 // Make a copy of the full response headers and fix them up | 173 // Make a copy of the full response headers and fix them up |
174 // for the range we'll be returning. | 174 // for the range we'll be returning. |
175 const char kLengthHeader[] = "Content-Length"; | 175 const char kLengthHeader[] = "Content-Length"; |
176 const char kRangeHeader[] = "Content-Range"; | 176 const char kRangeHeader[] = "Content-Range"; |
177 const char kPartialStatusLine[] = "HTTP/1.1 206 Partial Content"; | 177 const char kPartialStatusLine[] = "HTTP/1.1 206 Partial Content"; |
178 range_response_info_.reset( | 178 range_response_info_.reset( |
179 new net::HttpResponseInfo(*info_->http_response_info())); | 179 new net::HttpResponseInfo(*info_->http_response_info())); |
180 net::HttpResponseHeaders* headers = range_response_info_->headers; | 180 net::HttpResponseHeaders* headers = range_response_info_->headers.get(); |
181 headers->RemoveHeader(kLengthHeader); | 181 headers->RemoveHeader(kLengthHeader); |
182 headers->RemoveHeader(kRangeHeader); | 182 headers->RemoveHeader(kRangeHeader); |
183 headers->ReplaceStatusLine(kPartialStatusLine); | 183 headers->ReplaceStatusLine(kPartialStatusLine); |
184 headers->AddHeader( | 184 headers->AddHeader( |
185 base::StringPrintf("%s: %d", kLengthHeader, length)); | 185 base::StringPrintf("%s: %d", kLengthHeader, length)); |
186 headers->AddHeader( | 186 headers->AddHeader( |
187 base::StringPrintf("%s: bytes %d-%d/%d", | 187 base::StringPrintf("%s: bytes %d-%d/%d", |
188 kRangeHeader, | 188 kRangeHeader, |
189 offset, | 189 offset, |
190 offset + length - 1, | 190 offset + length - 1, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 return; | 286 return; |
287 } | 287 } |
288 | 288 |
289 // If multiple ranges are requested, we play dumb and | 289 // If multiple ranges are requested, we play dumb and |
290 // return the entire response with 200 OK. | 290 // return the entire response with 200 OK. |
291 if (ranges.size() == 1U) | 291 if (ranges.size() == 1U) |
292 range_requested_ = ranges[0]; | 292 range_requested_ = ranges[0]; |
293 } | 293 } |
294 | 294 |
295 } // namespace appcache | 295 } // namespace appcache |
OLD | NEW |