| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <limits> | 6 #include <limits> |
| 7 | 7 |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "net/http/http_util.h" | 9 #include "net/http/http_util.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 } | 744 } |
| 745 } | 745 } |
| 746 | 746 |
| 747 // Test SpecForRequest() for "ftp" scheme. | 747 // Test SpecForRequest() for "ftp" scheme. |
| 748 TEST(HttpUtilTest, SpecForRequestForUrlWithFtpScheme) { | 748 TEST(HttpUtilTest, SpecForRequestForUrlWithFtpScheme) { |
| 749 GURL ftp_url("ftp://user:pass@google.com/pub/chromium/"); | 749 GURL ftp_url("ftp://user:pass@google.com/pub/chromium/"); |
| 750 EXPECT_EQ("ftp://google.com/pub/chromium/", | 750 EXPECT_EQ("ftp://google.com/pub/chromium/", |
| 751 HttpUtil::SpecForRequest(ftp_url)); | 751 HttpUtil::SpecForRequest(ftp_url)); |
| 752 } | 752 } |
| 753 | 753 |
| 754 TEST(HttpUtilTest, GenerateAcceptLanguageHeader) { | |
| 755 EXPECT_EQ(std::string("en-US,fr;q=0.8,de;q=0.6"), | |
| 756 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de")); | |
| 757 EXPECT_EQ(std::string("en-US,fr;q=0.8,de;q=0.6,ko;q=0.4,zh-CN;q=0.2," | |
| 758 "ja;q=0.2"), | |
| 759 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de,ko,zh-CN,ja")); | |
| 760 } | |
| 761 | |
| 762 // HttpResponseHeadersTest.GetMimeType also tests ParseContentType. | 754 // HttpResponseHeadersTest.GetMimeType also tests ParseContentType. |
| 763 TEST(HttpUtilTest, ParseContentType) { | 755 TEST(HttpUtilTest, ParseContentType) { |
| 764 const struct { | 756 const struct { |
| 765 const char* const content_type; | 757 const char* const content_type; |
| 766 const char* const expected_mime_type; | 758 const char* const expected_mime_type; |
| 767 const char* const expected_charset; | 759 const char* const expected_charset; |
| 768 const bool expected_had_charset; | 760 const bool expected_had_charset; |
| 769 const char* const expected_boundary; | 761 const char* const expected_boundary; |
| 770 } tests[] = { | 762 } tests[] = { |
| 771 { "text/html; charset=utf-8", | 763 { "text/html; charset=utf-8", |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1493 EXPECT_FALSE(HttpUtil::IsLWS('a')); | 1485 EXPECT_FALSE(HttpUtil::IsLWS('a')); |
| 1494 EXPECT_FALSE(HttpUtil::IsLWS('.')); | 1486 EXPECT_FALSE(HttpUtil::IsLWS('.')); |
| 1495 EXPECT_FALSE(HttpUtil::IsLWS('\n')); | 1487 EXPECT_FALSE(HttpUtil::IsLWS('\n')); |
| 1496 EXPECT_FALSE(HttpUtil::IsLWS('\r')); | 1488 EXPECT_FALSE(HttpUtil::IsLWS('\r')); |
| 1497 | 1489 |
| 1498 EXPECT_TRUE(HttpUtil::IsLWS('\t')); | 1490 EXPECT_TRUE(HttpUtil::IsLWS('\t')); |
| 1499 EXPECT_TRUE(HttpUtil::IsLWS(' ')); | 1491 EXPECT_TRUE(HttpUtil::IsLWS(' ')); |
| 1500 } | 1492 } |
| 1501 | 1493 |
| 1502 } // namespace net | 1494 } // namespace net |
| OLD | NEW |