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

Side by Side Diff: content/browser/download/download_request_core.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
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 "content/browser/download/download_request_core.h" 5 #include "content/browser/download/download_request_core.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 // Requested a partial range, but received the entire response. 603 // Requested a partial range, but received the entire response.
604 save_info->offset = 0; 604 save_info->offset = 0;
605 save_info->hash_of_partial_file.clear(); 605 save_info->hash_of_partial_file.clear();
606 save_info->hash_state.reset(); 606 save_info->hash_state.reset();
607 return DOWNLOAD_INTERRUPT_REASON_NONE; 607 return DOWNLOAD_INTERRUPT_REASON_NONE;
608 } 608 }
609 609
610 int64_t first_byte = -1; 610 int64_t first_byte = -1;
611 int64_t last_byte = -1; 611 int64_t last_byte = -1;
612 int64_t length = -1; 612 int64_t length = -1;
613 if (!http_headers.GetContentRange(&first_byte, &last_byte, &length)) 613 if (!http_headers.GetContentRangeFor206(&first_byte, &last_byte, &length))
614 return DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT; 614 return DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT;
615 DCHECK_GE(first_byte, 0); 615 DCHECK_GE(first_byte, 0);
616 616
617 if (first_byte != save_info->offset) { 617 if (first_byte != save_info->offset) {
618 // The server returned a different range than the one we requested. Assume 618 // The server returned a different range than the one we requested. Assume
619 // the response is bad. 619 // the response is bad.
620 // 620 //
621 // In the future we should consider allowing offsets that are less than 621 // In the future we should consider allowing offsets that are less than
622 // the offset we've requested, since in theory we can truncate the partial 622 // the offset we've requested, since in theory we can truncate the partial
623 // file at the offset and continue. 623 // file at the offset and continue.
624 return DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT; 624 return DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT;
625 } 625 }
626 626
627 return DOWNLOAD_INTERRUPT_REASON_NONE; 627 return DOWNLOAD_INTERRUPT_REASON_NONE;
628 } 628 }
629 629
630 if (http_headers.response_code() == net::HTTP_PARTIAL_CONTENT) 630 if (http_headers.response_code() == net::HTTP_PARTIAL_CONTENT)
631 return DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT; 631 return DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT;
632 632
633 return DOWNLOAD_INTERRUPT_REASON_NONE; 633 return DOWNLOAD_INTERRUPT_REASON_NONE;
634 } 634 }
635 635
636 } // namespace content 636 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/blob_storage/blob_url_request_job_unittest.cc ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698