Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: net/http/partial_data.cc

Issue 2549143003: Cleaned up the API of HttpUtil::ParseContentRangeHeader(). (Closed)
Patch Set: Fixed unittest Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_util_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/http/partial_data.h" 5 #include "net/http/partial_data.h"
6 6
7 #include <limits> 7 #include <limits>
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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 if (headers->response_code() == 304) { 267 if (headers->response_code() == 304) {
268 if (!byte_range_.IsValid() || truncated_) 268 if (!byte_range_.IsValid() || truncated_)
269 return true; 269 return true;
270 270
271 // We must have a complete range here. 271 // We must have a complete range here.
272 return byte_range_.HasFirstBytePosition() && 272 return byte_range_.HasFirstBytePosition() &&
273 byte_range_.HasLastBytePosition(); 273 byte_range_.HasLastBytePosition();
274 } 274 }
275 275
276 int64_t start, end, total_length; 276 int64_t start, end, total_length;
277 if (!headers->GetContentRange(&start, &end, &total_length)) 277 if (!headers->GetContentRangeFor206(&start, &end, &total_length))
278 return false; 278 return false;
279 if (total_length <= 0) 279 if (total_length <= 0)
280 return false; 280 return false;
281 281
282 DCHECK_EQ(headers->response_code(), 206); 282 DCHECK_EQ(headers->response_code(), 206);
283 283
284 // A server should return a valid content length with a 206 (per the standard) 284 // A server should return a valid content length with a 206 (per the standard)
285 // but relax the requirement because some servers don't do that. 285 // but relax the requirement because some servers don't do that.
286 int64_t content_length = headers->GetContentLength(); 286 int64_t content_length = headers->GetContentLength();
287 if (content_length > 0 && content_length != end - start + 1) 287 if (content_length > 0 && content_length != end - start + 1)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 cached_min_len_ = result; 435 cached_min_len_ = result;
436 if (result >= 0) 436 if (result >= 0)
437 result = 1; // Return success, go ahead and validate the entry. 437 result = 1; // Return success, go ahead and validate the entry.
438 438
439 CompletionCallback cb = callback_; 439 CompletionCallback cb = callback_;
440 callback_.Reset(); 440 callback_.Reset();
441 cb.Run(result); 441 cb.Run(result);
442 } 442 }
443 443
444 } // namespace net 444 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698