OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #endif | 10 #endif |
(...skipping 2827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2838 req(test_server_.GetURL("echoheader?Accept-Language"), &d); | 2838 req(test_server_.GetURL("echoheader?Accept-Language"), &d); |
2839 req.set_context(new TestURLRequestContext()); | 2839 req.set_context(new TestURLRequestContext()); |
2840 HttpRequestHeaders headers; | 2840 HttpRequestHeaders headers; |
2841 headers.SetHeader(HttpRequestHeaders::kAcceptLanguage, "ru"); | 2841 headers.SetHeader(HttpRequestHeaders::kAcceptLanguage, "ru"); |
2842 req.SetExtraRequestHeaders(headers); | 2842 req.SetExtraRequestHeaders(headers); |
2843 req.Start(); | 2843 req.Start(); |
2844 MessageLoop::current()->Run(); | 2844 MessageLoop::current()->Run(); |
2845 EXPECT_EQ(std::string("ru"), d.data_received()); | 2845 EXPECT_EQ(std::string("ru"), d.data_received()); |
2846 } | 2846 } |
2847 | 2847 |
2848 // Check that default A-E header is sent. | |
2849 TEST_F(URLRequestTestHTTP, DefaultAcceptEncoding) { | |
2850 ASSERT_TRUE(test_server_.Start()); | |
2851 | |
2852 TestDelegate d; | |
2853 TestURLRequest | |
2854 req(test_server_.GetURL("echoheader?Accept-Encoding"), &d); | |
2855 req.set_context(new TestURLRequestContext()); | |
2856 HttpRequestHeaders headers; | |
2857 req.SetExtraRequestHeaders(headers); | |
2858 req.Start(); | |
2859 MessageLoop::current()->Run(); | |
2860 EXPECT_TRUE(ContainsString(d.data_received(), "gzip")); | |
2861 } | |
2862 | |
2863 // Check that if request overrides the A-E header, the default is not appended. | |
2864 // See http://crbug.com/47381 | |
2865 TEST_F(URLRequestTestHTTP, OverrideAcceptEncoding) { | |
2866 ASSERT_TRUE(test_server_.Start()); | |
2867 | |
2868 TestDelegate d; | |
2869 TestURLRequest | |
2870 req(test_server_.GetURL("echoheader?Accept-Encoding"), &d); | |
2871 req.set_context(new TestURLRequestContext()); | |
2872 HttpRequestHeaders headers; | |
2873 headers.SetHeader(HttpRequestHeaders::kAcceptEncoding, "identity"); | |
2874 req.SetExtraRequestHeaders(headers); | |
2875 req.Start(); | |
2876 MessageLoop::current()->Run(); | |
2877 EXPECT_FALSE(ContainsString(d.data_received(), "gzip")); | |
2878 EXPECT_TRUE(ContainsString(d.data_received(), "identity")); | |
2879 } | |
2880 | |
2881 // Check that default A-C header is sent. | 2848 // Check that default A-C header is sent. |
2882 TEST_F(URLRequestTestHTTP, DefaultAcceptCharset) { | 2849 TEST_F(URLRequestTestHTTP, DefaultAcceptCharset) { |
2883 ASSERT_TRUE(test_server_.Start()); | 2850 ASSERT_TRUE(test_server_.Start()); |
2884 | 2851 |
2885 TestDelegate d; | 2852 TestDelegate d; |
2886 TestURLRequest req(test_server_.GetURL("echoheader?Accept-Charset"), &d); | 2853 TestURLRequest req(test_server_.GetURL("echoheader?Accept-Charset"), &d); |
2887 scoped_refptr<URLRequestContext> context = new TestURLRequestContext; | 2854 scoped_refptr<URLRequestContext> context = new TestURLRequestContext; |
2888 context->set_accept_charset("en"); | 2855 context->set_accept_charset("en"); |
2889 req.set_context(context); | 2856 req.set_context(context); |
2890 req.Start(); | 2857 req.Start(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2950 req.SetExtraRequestHeaders(headers); | 2917 req.SetExtraRequestHeaders(headers); |
2951 req.Start(); | 2918 req.Start(); |
2952 MessageLoop::current()->Run(); | 2919 MessageLoop::current()->Run(); |
2953 // If the net tests are being run with ChromeFrame then we need to allow for | 2920 // If the net tests are being run with ChromeFrame then we need to allow for |
2954 // the 'chromeframe' suffix which is added to the user agent before the | 2921 // the 'chromeframe' suffix which is added to the user agent before the |
2955 // closing parentheses. | 2922 // closing parentheses. |
2956 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 2923 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
2957 } | 2924 } |
2958 | 2925 |
2959 } // namespace net | 2926 } // namespace net |
OLD | NEW |