OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "net/http/partial_data.h" | 5 #include "net/http/partial_data.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/disk_cache/disk_cache.h" | 10 #include "net/disk_cache/disk_cache.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 byte_range_.HasLastBytePosition(); | 186 byte_range_.HasLastBytePosition(); |
187 } | 187 } |
188 | 188 |
189 int64 start, end, total_length; | 189 int64 start, end, total_length; |
190 if (!headers->GetContentRange(&start, &end, &total_length)) | 190 if (!headers->GetContentRange(&start, &end, &total_length)) |
191 return false; | 191 return false; |
192 if (total_length <= 0) | 192 if (total_length <= 0) |
193 return false; | 193 return false; |
194 | 194 |
195 int64 content_length = headers->GetContentLength(); | 195 int64 content_length = headers->GetContentLength(); |
196 if (content_length != end - start + 1) | 196 if (content_length < 0 || content_length != end - start + 1) |
197 return false; | 197 return false; |
198 | 198 |
199 if (!resource_size_) { | 199 if (!resource_size_) { |
200 // First response. Update our values with the ones provided by the server. | 200 // First response. Update our values with the ones provided by the server. |
201 resource_size_ = total_length; | 201 resource_size_ = total_length; |
202 if (!byte_range_.HasFirstBytePosition()) { | 202 if (!byte_range_.HasFirstBytePosition()) { |
203 byte_range_.set_first_byte_position(start); | 203 byte_range_.set_first_byte_position(start); |
204 current_range_start_ = start; | 204 current_range_start_ = start; |
205 } | 205 } |
206 if (!byte_range_.HasLastBytePosition()) | 206 if (!byte_range_.HasLastBytePosition()) |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 if (start >= 0) | 310 if (start >= 0) |
311 my_start = Int64ToString(start); | 311 my_start = Int64ToString(start); |
312 if (end >= 0) | 312 if (end >= 0) |
313 my_end = Int64ToString(end); | 313 my_end = Int64ToString(end); |
314 | 314 |
315 headers->append(StringPrintf("Range: bytes=%s-%s\r\n", my_start.c_str(), | 315 headers->append(StringPrintf("Range: bytes=%s-%s\r\n", my_start.c_str(), |
316 my_end.c_str())); | 316 my_end.c_str())); |
317 } | 317 } |
318 | 318 |
319 } // namespace net | 319 } // namespace net |
OLD | NEW |