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

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

Issue 402107: ChromeFrame's host network stack implementation for IE full tab mode implicit... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_response_headers.h ('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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 // The rules for header parsing were borrowed from Firefox: 5 // The rules for header parsing were borrowed from Firefox:
6 // http://lxr.mozilla.org/seamonkey/source/netwerk/protocol/http/src/nsHttpRespo nseHead.cpp 6 // http://lxr.mozilla.org/seamonkey/source/netwerk/protocol/http/src/nsHttpRespo nseHead.cpp
7 // The rules for parsing content-types were also borrowed from Firefox: 7 // The rules for parsing content-types were also borrowed from Firefox:
8 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 8 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834
9 9
10 #include "net/http/http_response_headers.h" 10 #include "net/http/http_response_headers.h"
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 return !mime_type->empty(); 717 return !mime_type->empty();
718 } 718 }
719 719
720 bool HttpResponseHeaders::GetCharset(std::string* charset) const { 720 bool HttpResponseHeaders::GetCharset(std::string* charset) const {
721 std::string unused; 721 std::string unused;
722 GetMimeTypeAndCharset(&unused, charset); 722 GetMimeTypeAndCharset(&unused, charset);
723 return !charset->empty(); 723 return !charset->empty();
724 } 724 }
725 725
726 bool HttpResponseHeaders::IsRedirect(std::string* location) const { 726 bool HttpResponseHeaders::IsRedirect(std::string* location) const {
727 // Users probably want to see 300 (multiple choice) pages, so we don't count 727 if (!IsRedirectResponseCode(response_code_))
728 // them as redirects that need to be followed.
729 if (!(response_code_ == 301 ||
730 response_code_ == 302 ||
731 response_code_ == 303 ||
732 response_code_ == 307))
733 return false; 728 return false;
734 729
735 // If we lack a Location header, then we can't treat this as a redirect. 730 // If we lack a Location header, then we can't treat this as a redirect.
736 // We assume that the first non-empty location value is the target URL that 731 // We assume that the first non-empty location value is the target URL that
737 // we want to follow. TODO(darin): Is this consistent with other browsers? 732 // we want to follow. TODO(darin): Is this consistent with other browsers?
738 size_t i = std::string::npos; 733 size_t i = std::string::npos;
739 do { 734 do {
740 i = FindHeader(++i, "location"); 735 i = FindHeader(++i, "location");
741 if (i == std::string::npos) 736 if (i == std::string::npos)
742 return false; 737 return false;
743 // If the location value is empty, then it doesn't count. 738 // If the location value is empty, then it doesn't count.
744 } while (parsed_[i].value_begin == parsed_[i].value_end); 739 } while (parsed_[i].value_begin == parsed_[i].value_end);
745 740
746 if (location) { 741 if (location) {
747 // Escape any non-ASCII characters to preserve them. The server should 742 // Escape any non-ASCII characters to preserve them. The server should
748 // only be returning ASCII here, but for compat we need to do this. 743 // only be returning ASCII here, but for compat we need to do this.
749 *location = EscapeNonASCII( 744 *location = EscapeNonASCII(
750 std::string(parsed_[i].value_begin, parsed_[i].value_end)); 745 std::string(parsed_[i].value_begin, parsed_[i].value_end));
751 } 746 }
752 747
753 return true; 748 return true;
754 } 749 }
755 750
751 // static
752 bool HttpResponseHeaders::IsRedirectResponseCode(int response_code) {
753 // Users probably want to see 300 (multiple choice) pages, so we don't count
754 // them as redirects that need to be followed.
755 return (response_code == 301 ||
756 response_code == 302 ||
757 response_code == 303 ||
758 response_code == 307);
759 }
760
756 // From RFC 2616 section 13.2.4: 761 // From RFC 2616 section 13.2.4:
757 // 762 //
758 // The calculation to determine if a response has expired is quite simple: 763 // The calculation to determine if a response has expired is quite simple:
759 // 764 //
760 // response_is_fresh = (freshness_lifetime > current_age) 765 // response_is_fresh = (freshness_lifetime > current_age)
761 // 766 //
762 // Of course, there are other factors that can force a response to always be 767 // Of course, there are other factors that can force a response to always be
763 // validated or re-fetched. 768 // validated or re-fetched.
764 // 769 //
765 bool HttpResponseHeaders::RequiresValidation(const Time& request_time, 770 bool HttpResponseHeaders::RequiresValidation(const Time& request_time,
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 // We have all the values; let's verify that they make sense for a 206 1129 // We have all the values; let's verify that they make sense for a 206
1125 // response. 1130 // response.
1126 if (*first_byte_position < 0 || *last_byte_position < 0 || 1131 if (*first_byte_position < 0 || *last_byte_position < 0 ||
1127 *instance_length < 0 || *instance_length - 1 < *last_byte_position) 1132 *instance_length < 0 || *instance_length - 1 < *last_byte_position)
1128 return false; 1133 return false;
1129 1134
1130 return true; 1135 return true;
1131 } 1136 }
1132 1137
1133 } // namespace net 1138 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_response_headers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698