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 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 | 1292 |
1293 // We have all the values; let's verify that they make sense for a 206 | 1293 // We have all the values; let's verify that they make sense for a 206 |
1294 // response. | 1294 // response. |
1295 if (*first_byte_position < 0 || *last_byte_position < 0 || | 1295 if (*first_byte_position < 0 || *last_byte_position < 0 || |
1296 *instance_length < 0 || *instance_length - 1 < *last_byte_position) | 1296 *instance_length < 0 || *instance_length - 1 < *last_byte_position) |
1297 return false; | 1297 return false; |
1298 | 1298 |
1299 return true; | 1299 return true; |
1300 } | 1300 } |
1301 | 1301 |
1302 Value* HttpResponseHeaders::NetLogCallback( | 1302 base::Value* HttpResponseHeaders::NetLogCallback( |
1303 NetLog::LogLevel /* log_level */) const { | 1303 NetLog::LogLevel /* log_level */) const { |
1304 DictionaryValue* dict = new DictionaryValue(); | 1304 base::DictionaryValue* dict = new base::DictionaryValue(); |
1305 ListValue* headers = new ListValue(); | 1305 base::ListValue* headers = new base::ListValue(); |
1306 headers->Append(new StringValue(GetStatusLine())); | 1306 headers->Append(new base::StringValue(GetStatusLine())); |
1307 void* iterator = NULL; | 1307 void* iterator = NULL; |
1308 std::string name; | 1308 std::string name; |
1309 std::string value; | 1309 std::string value; |
1310 while (EnumerateHeaderLines(&iterator, &name, &value)) { | 1310 while (EnumerateHeaderLines(&iterator, &name, &value)) { |
1311 headers->Append( | 1311 headers->Append( |
1312 new StringValue(base::StringPrintf("%s: %s", | 1312 new base::StringValue(base::StringPrintf("%s: %s", |
1313 name.c_str(), | 1313 name.c_str(), |
1314 value.c_str()))); | 1314 value.c_str()))); |
1315 } | 1315 } |
1316 dict->Set("headers", headers); | 1316 dict->Set("headers", headers); |
1317 return dict; | 1317 return dict; |
1318 } | 1318 } |
1319 | 1319 |
1320 // static | 1320 // static |
1321 bool HttpResponseHeaders::FromNetLogParam( | 1321 bool HttpResponseHeaders::FromNetLogParam( |
1322 const base::Value* event_param, | 1322 const base::Value* event_param, |
1323 scoped_refptr<HttpResponseHeaders>* http_response_headers) { | 1323 scoped_refptr<HttpResponseHeaders>* http_response_headers) { |
1324 *http_response_headers = NULL; | 1324 *http_response_headers = NULL; |
(...skipping 23 matching lines...) Expand all Loading... |
1348 return true; | 1348 return true; |
1349 } | 1349 } |
1350 | 1350 |
1351 bool HttpResponseHeaders::IsChunkEncoded() const { | 1351 bool HttpResponseHeaders::IsChunkEncoded() const { |
1352 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. | 1352 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. |
1353 return GetHttpVersion() >= HttpVersion(1, 1) && | 1353 return GetHttpVersion() >= HttpVersion(1, 1) && |
1354 HasHeaderValue("Transfer-Encoding", "chunked"); | 1354 HasHeaderValue("Transfer-Encoding", "chunked"); |
1355 } | 1355 } |
1356 | 1356 |
1357 } // namespace net | 1357 } // namespace net |
OLD | NEW |