| 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 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 return -1; | 1296 return -1; |
| 1297 | 1297 |
| 1298 int64_t result; | 1298 int64_t result; |
| 1299 bool ok = base::StringToInt64(content_length_val, &result); | 1299 bool ok = base::StringToInt64(content_length_val, &result); |
| 1300 if (!ok || result < 0) | 1300 if (!ok || result < 0) |
| 1301 return -1; | 1301 return -1; |
| 1302 | 1302 |
| 1303 return result; | 1303 return result; |
| 1304 } | 1304 } |
| 1305 | 1305 |
| 1306 bool HttpResponseHeaders::GetContentRange(int64_t* first_byte_position, | 1306 bool HttpResponseHeaders::GetContentRangeFor206( |
| 1307 int64_t* last_byte_position, | 1307 int64_t* first_byte_position, |
| 1308 int64_t* instance_length) const { | 1308 int64_t* last_byte_position, |
| 1309 int64_t* instance_length) const { |
| 1309 size_t iter = 0; | 1310 size_t iter = 0; |
| 1310 std::string content_range_spec; | 1311 std::string content_range_spec; |
| 1311 if (!EnumerateHeader(&iter, kContentRange, &content_range_spec)) { | 1312 if (!EnumerateHeader(&iter, kContentRange, &content_range_spec)) { |
| 1312 *first_byte_position = *last_byte_position = *instance_length = -1; | 1313 *first_byte_position = *last_byte_position = *instance_length = -1; |
| 1313 return false; | 1314 return false; |
| 1314 } | 1315 } |
| 1315 | 1316 |
| 1316 return HttpUtil::ParseContentRangeHeader(content_range_spec, | 1317 return HttpUtil::ParseContentRangeHeaderFor206( |
| 1317 first_byte_position, | 1318 content_range_spec, first_byte_position, last_byte_position, |
| 1318 last_byte_position, instance_length); | 1319 instance_length); |
| 1319 } | 1320 } |
| 1320 | 1321 |
| 1321 std::unique_ptr<base::Value> HttpResponseHeaders::NetLogCallback( | 1322 std::unique_ptr<base::Value> HttpResponseHeaders::NetLogCallback( |
| 1322 NetLogCaptureMode capture_mode) const { | 1323 NetLogCaptureMode capture_mode) const { |
| 1323 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 1324 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 1324 base::ListValue* headers = new base::ListValue(); | 1325 base::ListValue* headers = new base::ListValue(); |
| 1325 headers->AppendString(EscapeNonASCII(GetStatusLine())); | 1326 headers->AppendString(EscapeNonASCII(GetStatusLine())); |
| 1326 size_t iterator = 0; | 1327 size_t iterator = 0; |
| 1327 std::string name; | 1328 std::string name; |
| 1328 std::string value; | 1329 std::string value; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 return true; | 1370 return true; |
| 1370 } | 1371 } |
| 1371 | 1372 |
| 1372 bool HttpResponseHeaders::IsChunkEncoded() const { | 1373 bool HttpResponseHeaders::IsChunkEncoded() const { |
| 1373 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. | 1374 // Ignore spurious chunked responses from HTTP/1.0 servers and proxies. |
| 1374 return GetHttpVersion() >= HttpVersion(1, 1) && | 1375 return GetHttpVersion() >= HttpVersion(1, 1) && |
| 1375 HasHeaderValue("Transfer-Encoding", "chunked"); | 1376 HasHeaderValue("Transfer-Encoding", "chunked"); |
| 1376 } | 1377 } |
| 1377 | 1378 |
| 1378 } // namespace net | 1379 } // namespace net |
| OLD | NEW |