OLD | NEW |
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 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 // "close" in 1.0 is not strictly standards-compliant, but we'd like to | 1207 // "close" in 1.0 is not strictly standards-compliant, but we'd like to |
1208 // avoid looking at the Proxy-Connection header whenever it is reasonable to do | 1208 // avoid looking at the Proxy-Connection header whenever it is reasonable to do |
1209 // so. | 1209 // so. |
1210 // TODO(ricea): Measure real-world usage of the "Proxy-Connection" header, | 1210 // TODO(ricea): Measure real-world usage of the "Proxy-Connection" header, |
1211 // with a view to reducing support for it in order to make our Connection header | 1211 // with a view to reducing support for it in order to make our Connection header |
1212 // handling more RFC 7230 compliant. | 1212 // handling more RFC 7230 compliant. |
1213 bool HttpResponseHeaders::IsKeepAlive() const { | 1213 bool HttpResponseHeaders::IsKeepAlive() const { |
1214 // NOTE: It is perhaps risky to assume that a Proxy-Connection header is | 1214 // NOTE: It is perhaps risky to assume that a Proxy-Connection header is |
1215 // meaningful when we don't know that this response was from a proxy, but | 1215 // meaningful when we don't know that this response was from a proxy, but |
1216 // Mozilla also does this, so we'll do the same. | 1216 // Mozilla also does this, so we'll do the same. |
1217 static const char* kConnectionHeaders[] = {"connection", "proxy-connection"}; | 1217 static const char* const kConnectionHeaders[] = { |
| 1218 "connection", "proxy-connection"}; |
1218 struct KeepAliveToken { | 1219 struct KeepAliveToken { |
1219 const char* token; | 1220 const char* const token; |
1220 bool keep_alive; | 1221 bool keep_alive; |
1221 }; | 1222 }; |
1222 static const KeepAliveToken kKeepAliveTokens[] = {{"keep-alive", true}, | 1223 static const KeepAliveToken kKeepAliveTokens[] = {{"keep-alive", true}, |
1223 {"close", false}}; | 1224 {"close", false}}; |
1224 | 1225 |
1225 if (http_version_ < HttpVersion(1, 0)) | 1226 if (http_version_ < HttpVersion(1, 0)) |
1226 return false; | 1227 return false; |
1227 | 1228 |
1228 for (const char* header : kConnectionHeaders) { | 1229 for (const char* header : kConnectionHeaders) { |
1229 void* iterator = nullptr; | 1230 void* iterator = nullptr; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 return true; | 1443 return true; |
1443 } | 1444 } |
1444 | 1445 |
1445 bool HttpResponseHeaders::IsChunkEncoded() const { | 1446 bool HttpResponseHeaders::IsChunkEncoded() const { |
1446 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. | 1447 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. |
1447 return GetHttpVersion() >= HttpVersion(1, 1) && | 1448 return GetHttpVersion() >= HttpVersion(1, 1) && |
1448 HasHeaderValue("Transfer-Encoding", "chunked"); | 1449 HasHeaderValue("Transfer-Encoding", "chunked"); |
1449 } | 1450 } |
1450 | 1451 |
1451 } // namespace net | 1452 } // namespace net |
OLD | NEW |