| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "net/http/http_util.h" | 8 #include "net/http/http_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 319 |
| 320 "HTTP/1.0 404|" | 320 "HTTP/1.0 404|" |
| 321 " Not Found|" | 321 " Not Found|" |
| 322 "Foo: 1|" | 322 "Foo: 1|" |
| 323 "Bar: 2||" | 323 "Bar: 2||" |
| 324 }, | 324 }, |
| 325 | 325 |
| 326 // Unterminated status line. | 326 // Unterminated status line. |
| 327 { | 327 { |
| 328 "HTTP/1.0 200 OK", | 328 "HTTP/1.0 200 OK", |
| 329 | 329 |
| 330 "HTTP/1.0 200 OK||" | 330 "HTTP/1.0 200 OK||" |
| 331 }, | 331 }, |
| 332 | 332 |
| 333 // Single terminated, with headers | 333 // Single terminated, with headers |
| 334 { | 334 { |
| 335 "HTTP/1.0 200 OK\n" | 335 "HTTP/1.0 200 OK\n" |
| 336 "Foo: 1\n" | 336 "Foo: 1\n" |
| 337 "Bar: 2\n", | 337 "Bar: 2\n", |
| 338 | 338 |
| 339 "HTTP/1.0 200 OK|" | 339 "HTTP/1.0 200 OK|" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 }; | 468 }; |
| 469 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 469 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 470 GURL url(GURL(tests[i].url)); | 470 GURL url(GURL(tests[i].url)); |
| 471 std::string expected_spec(tests[i].expected_spec); | 471 std::string expected_spec(tests[i].expected_spec); |
| 472 std::string expected_path(tests[i].expected_path); | 472 std::string expected_path(tests[i].expected_path); |
| 473 | 473 |
| 474 EXPECT_EQ(expected_spec, HttpUtil::SpecForRequest(url)); | 474 EXPECT_EQ(expected_spec, HttpUtil::SpecForRequest(url)); |
| 475 EXPECT_EQ(expected_path, HttpUtil::PathForRequest(url)); | 475 EXPECT_EQ(expected_path, HttpUtil::PathForRequest(url)); |
| 476 } | 476 } |
| 477 } | 477 } |
| 478 |
| 479 TEST(HttpUtilTest, GenerateAcceptLanguageHeader) { |
| 480 EXPECT_EQ(std::string("en-US,fr;q=0.8,de;q=0.6"), |
| 481 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de")); |
| 482 EXPECT_EQ(std::string("en-US,fr;q=0.8,de;q=0.6,ko;q=0.4,zh-CN;q=0.2," |
| 483 "ja;q=0.2"), |
| 484 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de,ko,zh-CN,ja")); |
| 485 } |
| 486 |
| 487 TEST(HttpUtilTest, GenerateAcceptCharsetHeader) { |
| 488 EXPECT_EQ(std::string("utf-8,*;q=0.5"), |
| 489 HttpUtil::GenerateAcceptCharsetHeader("utf-8")); |
| 490 EXPECT_EQ(std::string("EUC-JP,utf-8;q=0.7,*;q=0.3"), |
| 491 HttpUtil::GenerateAcceptCharsetHeader("EUC-JP")); |
| 492 } |
| 493 |
| OLD | NEW |