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

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

Issue 10387200: Suppress pause-and-buffer behavior when the HTTP response won't satisfy future requests via cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: %zu is win-unfriendly; use %PRIuS instead. Created 8 years, 7 months 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 | « content/content_tests.gypi ('k') | net/http/http_util.h » ('j') | 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 // 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 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 keep_alive = LowerCaseEqualsASCII(connection_val, "keep-alive"); 1153 keep_alive = LowerCaseEqualsASCII(connection_val, "keep-alive");
1154 } else { 1154 } else {
1155 // HTTP/1.1 responses default to keep-alive 1155 // HTTP/1.1 responses default to keep-alive
1156 keep_alive = !LowerCaseEqualsASCII(connection_val, "close"); 1156 keep_alive = !LowerCaseEqualsASCII(connection_val, "close");
1157 } 1157 }
1158 1158
1159 return keep_alive; 1159 return keep_alive;
1160 } 1160 }
1161 1161
1162 bool HttpResponseHeaders::HasStrongValidators() const { 1162 bool HttpResponseHeaders::HasStrongValidators() const {
1163 if (GetHttpVersion() < HttpVersion(1, 1)) 1163 std::string etag_header;
1164 return false; 1164 EnumerateHeader(NULL, "etag", &etag_header);
1165 1165 std::string last_modified_header;
1166 std::string etag_value; 1166 EnumerateHeader(NULL, "Last-Modified", &last_modified_header);
1167 EnumerateHeader(NULL, "etag", &etag_value); 1167 std::string date_header;
1168 if (!etag_value.empty()) { 1168 EnumerateHeader(NULL, "Date", &date_header);
1169 size_t slash = etag_value.find('/'); 1169 return HttpUtil::HasStrongValidators(GetHttpVersion(),
1170 if (slash == std::string::npos || slash == 0) 1170 etag_header,
1171 return true; 1171 last_modified_header,
1172 1172 date_header);
1173 std::string::const_iterator i = etag_value.begin();
1174 std::string::const_iterator j = etag_value.begin() + slash;
1175 HttpUtil::TrimLWS(&i, &j);
1176 if (!LowerCaseEqualsASCII(i, j, "w"))
1177 return true;
1178 }
1179
1180 Time last_modified;
1181 if (!GetLastModifiedValue(&last_modified))
1182 return false;
1183
1184 Time date;
1185 if (!GetDateValue(&date))
1186 return false;
1187
1188 return ((date - last_modified).InSeconds() >= 60);
1189 } 1173 }
1190 1174
1191 // From RFC 2616: 1175 // From RFC 2616:
1192 // Content-Length = "Content-Length" ":" 1*DIGIT 1176 // Content-Length = "Content-Length" ":" 1*DIGIT
1193 int64 HttpResponseHeaders::GetContentLength() const { 1177 int64 HttpResponseHeaders::GetContentLength() const {
1194 void* iter = NULL; 1178 void* iter = NULL;
1195 std::string content_length_val; 1179 std::string content_length_val;
1196 if (!EnumerateHeader(&iter, "content-length", &content_length_val)) 1180 if (!EnumerateHeader(&iter, "content-length", &content_length_val))
1197 return -1; 1181 return -1;
1198 1182
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 return true; 1306 return true;
1323 } 1307 }
1324 1308
1325 bool HttpResponseHeaders::IsChunkEncoded() const { 1309 bool HttpResponseHeaders::IsChunkEncoded() const {
1326 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. 1310 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies.
1327 return GetHttpVersion() >= HttpVersion(1, 1) && 1311 return GetHttpVersion() >= HttpVersion(1, 1) &&
1328 HasHeaderValue("Transfer-Encoding", "chunked"); 1312 HasHeaderValue("Transfer-Encoding", "chunked");
1329 } 1313 }
1330 1314
1331 } // namespace net 1315 } // namespace net
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | net/http/http_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698