| 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 #include "net/http/http_response_headers.h" | 5 #include "net/http/http_response_headers.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iostream> | 10 #include <iostream> |
| (...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1356 EXPECT_EQ(test.expected_last_byte_position, last_byte_position); | 1356 EXPECT_EQ(test.expected_last_byte_position, last_byte_position); |
| 1357 EXPECT_EQ(test.expected_instance_size, instance_size); | 1357 EXPECT_EQ(test.expected_instance_size, instance_size); |
| 1358 } | 1358 } |
| 1359 | 1359 |
| 1360 const ContentRangeTestData content_range_tests[] = { | 1360 const ContentRangeTestData content_range_tests[] = { |
| 1361 {"HTTP/1.1 206 Partial Content", false, -1, -1, -1}, | 1361 {"HTTP/1.1 206 Partial Content", false, -1, -1, -1}, |
| 1362 {"HTTP/1.1 206 Partial Content\n" | 1362 {"HTTP/1.1 206 Partial Content\n" |
| 1363 "Content-Range:", | 1363 "Content-Range:", |
| 1364 false, -1, -1, -1}, | 1364 false, -1, -1, -1}, |
| 1365 {"HTTP/1.1 206 Partial Content\n" | 1365 {"HTTP/1.1 206 Partial Content\n" |
| 1366 "Content-Range: megabytes 0-10/50", | |
| 1367 false, -1, -1, -1}, | |
| 1368 {"HTTP/1.1 206 Partial Content\n" | |
| 1369 "Content-Range: 0-10/50", | |
| 1370 false, -1, -1, -1}, | |
| 1371 {"HTTP/1.1 206 Partial Content\n" | |
| 1372 "Content-Range: Bytes 0-50/51", | |
| 1373 true, 0, 50, 51}, | |
| 1374 {"HTTP/1.1 206 Partial Content\n" | |
| 1375 "Content-Range: bytes 0-50/51", | 1366 "Content-Range: bytes 0-50/51", |
| 1376 true, 0, 50, 51}, | 1367 true, 0, 50, 51}, |
| 1377 {"HTTP/1.1 206 Partial Content\n" | 1368 {"HTTP/1.1 206 Partial Content\n" |
| 1378 "Content-Range: bytes\t0-50/51", | |
| 1379 false, -1, -1, -1}, | |
| 1380 {"HTTP/1.1 206 Partial Content\n" | |
| 1381 "Content-Range: bytes 0-50/51", | |
| 1382 true, 0, 50, 51}, | |
| 1383 {"HTTP/1.1 206 Partial Content\n" | |
| 1384 "Content-Range: bytes 0 - 50 \t / \t51", | |
| 1385 true, 0, 50, 51}, | |
| 1386 {"HTTP/1.1 206 Partial Content\n" | |
| 1387 "Content-Range: bytes 0\t-\t50\t/\t51\t", | |
| 1388 true, 0, 50, 51}, | |
| 1389 {"HTTP/1.1 206 Partial Content\n" | |
| 1390 "Content-Range: \tbytes\t\t\t 0\t-\t50\t/\t51\t", | |
| 1391 true, 0, 50, 51}, | |
| 1392 {"HTTP/1.1 206 Partial Content\n" | |
| 1393 "Content-Range: \t bytes \t 0 - 50 / 5 1", | |
| 1394 false, 0, 50, -1}, | |
| 1395 {"HTTP/1.1 206 Partial Content\n" | |
| 1396 "Content-Range: \t bytes \t 0 - 5 0 / 51", | |
| 1397 false, -1, -1, -1}, | |
| 1398 {"HTTP/1.1 206 Partial Content\n" | |
| 1399 "Content-Range: bytes 50-0/51", | 1369 "Content-Range: bytes 50-0/51", |
| 1400 false, 50, 0, -1}, | |
| 1401 {"HTTP/1.1 416 Requested range not satisfiable\n" | |
| 1402 "Content-Range: bytes * /*", | |
| 1403 false, -1, -1, -1}, | 1370 false, -1, -1, -1}, |
| 1404 {"HTTP/1.1 416 Requested range not satisfiable\n" | 1371 {"HTTP/1.1 416 Requested range not satisfiable\n" |
| 1405 "Content-Range: bytes * / * ", | 1372 "Content-Range: bytes */*", |
| 1406 false, -1, -1, -1}, | 1373 false, -1, -1, -1}, |
| 1407 {"HTTP/1.1 206 Partial Content\n" | 1374 {"HTTP/1.1 206 Partial Content\n" |
| 1408 "Content-Range: bytes 0-50/*", | 1375 "Content-Range: bytes 0-50/*", |
| 1409 false, 0, 50, -1}, | |
| 1410 {"HTTP/1.1 206 Partial Content\n" | |
| 1411 "Content-Range: bytes 0-50 / * ", | |
| 1412 false, 0, 50, -1}, | |
| 1413 {"HTTP/1.1 206 Partial Content\n" | |
| 1414 "Content-Range: bytes 0-10000000000/10000000001", | |
| 1415 true, 0, 10000000000ll, 10000000001ll}, | |
| 1416 {"HTTP/1.1 206 Partial Content\n" | |
| 1417 "Content-Range: bytes 0-10000000000/10000000000", | |
| 1418 false, 0, 10000000000ll, 10000000000ll}, | |
| 1419 // 64 bit wraparound. | |
| 1420 {"HTTP/1.1 206 Partial Content\n" | |
| 1421 "Content-Range: bytes 0 - 9223372036854775807 / 100", | |
| 1422 false, 0, std::numeric_limits<int64_t>::max(), 100}, | |
| 1423 // 64 bit wraparound. | |
| 1424 {"HTTP/1.1 206 Partial Content\n" | |
| 1425 "Content-Range: bytes 0 - 100 / -9223372036854775808", | |
| 1426 false, 0, 100, std::numeric_limits<int64_t>::min()}, | |
| 1427 {"HTTP/1.1 206 Partial Content\n" | |
| 1428 "Content-Range: bytes */50", | |
| 1429 false, -1, -1, 50}, | |
| 1430 {"HTTP/1.1 206 Partial Content\n" | |
| 1431 "Content-Range: bytes 0-50/10", | |
| 1432 false, 0, 50, 10}, | |
| 1433 {"HTTP/1.1 206 Partial Content\n" | |
| 1434 "Content-Range: bytes 40-50/45", | |
| 1435 false, 40, 50, 45}, | |
| 1436 {"HTTP/1.1 206 Partial Content\n" | |
| 1437 "Content-Range: bytes 0-50/-10", | |
| 1438 false, 0, 50, -10}, | |
| 1439 {"HTTP/1.1 206 Partial Content\n" | |
| 1440 "Content-Range: bytes 0-0/1", | |
| 1441 true, 0, 0, 1}, | |
| 1442 {"HTTP/1.1 206 Partial Content\n" | |
| 1443 "Content-Range: bytes 0-40000000000000000000/40000000000000000001", | |
| 1444 false, -1, -1, -1}, | |
| 1445 {"HTTP/1.1 206 Partial Content\n" | |
| 1446 "Content-Range: bytes 1-/100", | |
| 1447 false, -1, -1, -1}, | |
| 1448 {"HTTP/1.1 206 Partial Content\n" | |
| 1449 "Content-Range: bytes -/100", | |
| 1450 false, -1, -1, -1}, | |
| 1451 {"HTTP/1.1 206 Partial Content\n" | |
| 1452 "Content-Range: bytes -1/100", | |
| 1453 false, -1, -1, -1}, | |
| 1454 {"HTTP/1.1 206 Partial Content\n" | |
| 1455 "Content-Range: bytes 0-1233/*", | |
| 1456 false, 0, 1233, -1}, | |
| 1457 {"HTTP/1.1 206 Partial Content\n" | |
| 1458 "Content-Range: bytes -123 - -1/100", | |
| 1459 false, -1, -1, -1}, | 1376 false, -1, -1, -1}, |
| 1460 }; | 1377 }; |
| 1461 | 1378 |
| 1462 INSTANTIATE_TEST_CASE_P(HttpResponseHeaders, | 1379 INSTANTIATE_TEST_CASE_P(HttpResponseHeaders, |
| 1463 ContentRangeTest, | 1380 ContentRangeTest, |
| 1464 testing::ValuesIn(content_range_tests)); | 1381 testing::ValuesIn(content_range_tests)); |
| 1465 | 1382 |
| 1466 struct KeepAliveTestData { | 1383 struct KeepAliveTestData { |
| 1467 const char* headers; | 1384 const char* headers; |
| 1468 bool expected_keep_alive; | 1385 bool expected_keep_alive; |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2215 TEST_F(HttpResponseHeadersCacheControlTest, | 2132 TEST_F(HttpResponseHeadersCacheControlTest, |
| 2216 FirstStaleWhileRevalidateValueUsed) { | 2133 FirstStaleWhileRevalidateValueUsed) { |
| 2217 InitializeHeadersWithCacheControl( | 2134 InitializeHeadersWithCacheControl( |
| 2218 "stale-while-revalidate=1,stale-while-revalidate=7200"); | 2135 "stale-while-revalidate=1,stale-while-revalidate=7200"); |
| 2219 EXPECT_EQ(TimeDelta::FromSeconds(1), GetStaleWhileRevalidateValue()); | 2136 EXPECT_EQ(TimeDelta::FromSeconds(1), GetStaleWhileRevalidateValue()); |
| 2220 } | 2137 } |
| 2221 | 2138 |
| 2222 } // namespace | 2139 } // namespace |
| 2223 | 2140 |
| 2224 } // namespace net | 2141 } // namespace net |
| OLD | NEW |