OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 new_raw_headers.append(header); | 249 new_raw_headers.append(header); |
250 new_raw_headers.push_back('\0'); | 250 new_raw_headers.push_back('\0'); |
251 new_raw_headers.push_back('\0'); | 251 new_raw_headers.push_back('\0'); |
252 | 252 |
253 // Make this object hold the new data. | 253 // Make this object hold the new data. |
254 raw_headers_.clear(); | 254 raw_headers_.clear(); |
255 parsed_.clear(); | 255 parsed_.clear(); |
256 Parse(new_raw_headers); | 256 Parse(new_raw_headers); |
257 } | 257 } |
258 | 258 |
| 259 void HttpResponseHeaders::ReplaceStatusLine(const std::string& new_status) { |
| 260 // Copy up to the null byte. This just copies the status line. |
| 261 std::string new_raw_headers(new_status); |
| 262 new_raw_headers.push_back('\0'); |
| 263 |
| 264 HeaderSet empty_to_remove; |
| 265 MergeWithHeaders(new_raw_headers, empty_to_remove); |
| 266 } |
| 267 |
259 void HttpResponseHeaders::Parse(const std::string& raw_input) { | 268 void HttpResponseHeaders::Parse(const std::string& raw_input) { |
260 raw_headers_.reserve(raw_input.size()); | 269 raw_headers_.reserve(raw_input.size()); |
261 | 270 |
262 // ParseStatusLine adds a normalized status line to raw_headers_ | 271 // ParseStatusLine adds a normalized status line to raw_headers_ |
263 std::string::const_iterator line_begin = raw_input.begin(); | 272 std::string::const_iterator line_begin = raw_input.begin(); |
264 std::string::const_iterator line_end = | 273 std::string::const_iterator line_end = |
265 find(line_begin, raw_input.end(), '\0'); | 274 find(line_begin, raw_input.end(), '\0'); |
266 // has_headers = true, if there is any data following the status line. | 275 // has_headers = true, if there is any data following the status line. |
267 // Used by ParseStatusLine() to decide if a HTTP/0.9 is really a HTTP/1.0. | 276 // Used by ParseStatusLine() to decide if a HTTP/0.9 is really a HTTP/1.0. |
268 bool has_headers = line_end != raw_input.end() && | 277 bool has_headers = line_end != raw_input.end() && |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 } else if (*instance_length < 0 || | 1124 } else if (*instance_length < 0 || |
1116 *instance_length < | 1125 *instance_length < |
1117 *last_byte_position - *first_byte_position + 1) { | 1126 *last_byte_position - *first_byte_position + 1) { |
1118 return false; | 1127 return false; |
1119 } | 1128 } |
1120 | 1129 |
1121 return true; | 1130 return true; |
1122 } | 1131 } |
1123 | 1132 |
1124 } // namespace net | 1133 } // namespace net |
OLD | NEW |