| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 "x-webkit-" | 95 "x-webkit-" |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 bool ShouldUpdateHeader(const std::string::const_iterator& name_begin, | 98 bool ShouldUpdateHeader(const std::string::const_iterator& name_begin, |
| 99 const std::string::const_iterator& name_end) { | 99 const std::string::const_iterator& name_end) { |
| 100 for (size_t i = 0; i < arraysize(kNonUpdatedHeaders); ++i) { | 100 for (size_t i = 0; i < arraysize(kNonUpdatedHeaders); ++i) { |
| 101 if (base::LowerCaseEqualsASCII(name_begin, name_end, kNonUpdatedHeaders[i])) | 101 if (base::LowerCaseEqualsASCII(name_begin, name_end, kNonUpdatedHeaders[i])) |
| 102 return false; | 102 return false; |
| 103 } | 103 } |
| 104 for (size_t i = 0; i < arraysize(kNonUpdatedHeaderPrefixes); ++i) { | 104 for (size_t i = 0; i < arraysize(kNonUpdatedHeaderPrefixes); ++i) { |
| 105 if (base::StartsWithASCII(std::string(name_begin, name_end), | 105 if (base::StartsWith(base::StringPiece(name_begin, name_end), |
| 106 kNonUpdatedHeaderPrefixes[i], false)) | 106 kNonUpdatedHeaderPrefixes[i], |
| 107 base::CompareCase::INSENSITIVE_ASCII)) |
| 107 return false; | 108 return false; |
| 108 } | 109 } |
| 109 return true; | 110 return true; |
| 110 } | 111 } |
| 111 | 112 |
| 112 void CheckDoesNotHaveEmbededNulls(const std::string& str) { | 113 void CheckDoesNotHaveEmbededNulls(const std::string& str) { |
| 113 // Care needs to be taken when adding values to the raw headers string to | 114 // Care needs to be taken when adding values to the raw headers string to |
| 114 // make sure it does not contain embeded NULLs. Any embeded '\0' may be | 115 // make sure it does not contain embeded NULLs. Any embeded '\0' may be |
| 115 // understood as line terminators and change how header lines get tokenized. | 116 // understood as line terminators and change how header lines get tokenized. |
| 116 CHECK(str.find('\0') == std::string::npos); | 117 CHECK(str.find('\0') == std::string::npos); |
| (...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 return true; | 1445 return true; |
| 1445 } | 1446 } |
| 1446 | 1447 |
| 1447 bool HttpResponseHeaders::IsChunkEncoded() const { | 1448 bool HttpResponseHeaders::IsChunkEncoded() const { |
| 1448 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. | 1449 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. |
| 1449 return GetHttpVersion() >= HttpVersion(1, 1) && | 1450 return GetHttpVersion() >= HttpVersion(1, 1) && |
| 1450 HasHeaderValue("Transfer-Encoding", "chunked"); | 1451 HasHeaderValue("Transfer-Encoding", "chunked"); |
| 1451 } | 1452 } |
| 1452 | 1453 |
| 1453 } // namespace net | 1454 } // namespace net |
| OLD | NEW |