| 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 // Copy up to the null byte. This just copies the status line. | 300 // Copy up to the null byte. This just copies the status line. |
| 301 std::string new_raw_headers(raw_headers_.c_str()); | 301 std::string new_raw_headers(raw_headers_.c_str()); |
| 302 new_raw_headers.push_back('\0'); | 302 new_raw_headers.push_back('\0'); |
| 303 | 303 |
| 304 std::string lowercase_name = base::ToLowerASCII(name); | 304 std::string lowercase_name = base::ToLowerASCII(name); |
| 305 HeaderSet to_remove; | 305 HeaderSet to_remove; |
| 306 to_remove.insert(lowercase_name); | 306 to_remove.insert(lowercase_name); |
| 307 MergeWithHeaders(new_raw_headers, to_remove); | 307 MergeWithHeaders(new_raw_headers, to_remove); |
| 308 } | 308 } |
| 309 | 309 |
| 310 void HttpResponseHeaders::RemoveHeaders( |
| 311 const std::unordered_set<std::string>& header_names) { |
| 312 // Copy up to the null byte. This just copies the status line. |
| 313 std::string new_raw_headers(raw_headers_.c_str()); |
| 314 new_raw_headers.push_back('\0'); |
| 315 |
| 316 HeaderSet to_remove; |
| 317 for (const auto& header_name : header_names) { |
| 318 to_remove.insert(base::ToLowerASCII(header_name)); |
| 319 } |
| 320 MergeWithHeaders(new_raw_headers, to_remove); |
| 321 } |
| 322 |
| 310 void HttpResponseHeaders::RemoveHeaderLine(const std::string& name, | 323 void HttpResponseHeaders::RemoveHeaderLine(const std::string& name, |
| 311 const std::string& value) { | 324 const std::string& value) { |
| 312 std::string name_lowercase = base::ToLowerASCII(name); | 325 std::string name_lowercase = base::ToLowerASCII(name); |
| 313 | 326 |
| 314 std::string new_raw_headers(GetStatusLine()); | 327 std::string new_raw_headers(GetStatusLine()); |
| 315 new_raw_headers.push_back('\0'); | 328 new_raw_headers.push_back('\0'); |
| 316 | 329 |
| 317 new_raw_headers.reserve(raw_headers_.size()); | 330 new_raw_headers.reserve(raw_headers_.size()); |
| 318 | 331 |
| 319 size_t iter = 0; | 332 size_t iter = 0; |
| (...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 return true; | 1383 return true; |
| 1371 } | 1384 } |
| 1372 | 1385 |
| 1373 bool HttpResponseHeaders::IsChunkEncoded() const { | 1386 bool HttpResponseHeaders::IsChunkEncoded() const { |
| 1374 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. | 1387 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. |
| 1375 return GetHttpVersion() >= HttpVersion(1, 1) && | 1388 return GetHttpVersion() >= HttpVersion(1, 1) && |
| 1376 HasHeaderValue("Transfer-Encoding", "chunked"); | 1389 HasHeaderValue("Transfer-Encoding", "chunked"); |
| 1377 } | 1390 } |
| 1378 | 1391 |
| 1379 } // namespace net | 1392 } // namespace net |
| OLD | NEW |