OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 const std::string& value) { | 346 const std::string& value) { |
347 // Copy up to the null byte. This just copies the status line. | 347 // Copy up to the null byte. This just copies the status line. |
348 std::string new_raw_headers(raw_headers_.c_str()); | 348 std::string new_raw_headers(raw_headers_.c_str()); |
349 new_raw_headers.push_back('\0'); | 349 new_raw_headers.push_back('\0'); |
350 | 350 |
351 MergeWithHeadersWithValue(new_raw_headers, name, value); | 351 MergeWithHeadersWithValue(new_raw_headers, name, value); |
352 } | 352 } |
353 | 353 |
354 void HttpResponseHeaders::AddHeader(const std::string& header) { | 354 void HttpResponseHeaders::AddHeader(const std::string& header) { |
355 CheckDoesNotHaveEmbededNulls(header); | 355 CheckDoesNotHaveEmbededNulls(header); |
356 DCHECK_EQ('\0', raw_headers_[raw_headers_.size() - 2]); | 356 //DCHECK_EQ('\0', raw_headers_[raw_headers_.size() - 2]); |
357 DCHECK_EQ('\0', raw_headers_[raw_headers_.size() - 1]); | 357 //DCHECK_EQ('\0', raw_headers_[raw_headers_.size() - 1]); |
Charlie Reis
2011/12/02 22:38:11
Needs cleanup. Why isn't this true anymore?
Matt Perry
2011/12/03 00:14:24
Oops, that was for an earlier bug that has been fi
| |
358 // Don't copy the last null. | 358 // Don't copy the last null. |
359 std::string new_raw_headers(raw_headers_, 0, raw_headers_.size() - 1); | 359 std::string new_raw_headers(raw_headers_, 0, raw_headers_.size() - 1); |
360 new_raw_headers.append(header); | 360 new_raw_headers.append(header); |
361 new_raw_headers.push_back('\0'); | 361 new_raw_headers.push_back('\0'); |
362 new_raw_headers.push_back('\0'); | 362 new_raw_headers.push_back('\0'); |
363 | 363 |
364 // Make this object hold the new data. | 364 // Make this object hold the new data. |
365 raw_headers_.clear(); | 365 raw_headers_.clear(); |
366 parsed_.clear(); | 366 parsed_.clear(); |
367 Parse(new_raw_headers); | 367 Parse(new_raw_headers); |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1302 return true; | 1302 return true; |
1303 } | 1303 } |
1304 | 1304 |
1305 bool HttpResponseHeaders::IsChunkEncoded() const { | 1305 bool HttpResponseHeaders::IsChunkEncoded() const { |
1306 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. | 1306 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. |
1307 return GetHttpVersion() >= HttpVersion(1, 1) && | 1307 return GetHttpVersion() >= HttpVersion(1, 1) && |
1308 HasHeaderValue("Transfer-Encoding", "chunked"); | 1308 HasHeaderValue("Transfer-Encoding", "chunked"); |
1309 } | 1309 } |
1310 | 1310 |
1311 } // namespace net | 1311 } // namespace net |
OLD | NEW |