Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 12463021: Stop sending Accept-Charset HTTP header. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync (r188089) Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request_test_util.cc ('k') | sync/internal_api/http_bridge.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 #endif 10 #endif
(...skipping 3901 matching lines...) Expand 10 before | Expand all | Expand 10 after
3912 req.Start(); 3912 req.Start();
3913 MessageLoop::current()->Run(); 3913 MessageLoop::current()->Run();
3914 EXPECT_EQ("POST", req.method()); 3914 EXPECT_EQ("POST", req.method());
3915 EXPECT_EQ(kData, d.data_received()); 3915 EXPECT_EQ(kData, d.data_received());
3916 } 3916 }
3917 3917
3918 // Check that default A-L header is sent. 3918 // Check that default A-L header is sent.
3919 TEST_F(URLRequestTestHTTP, DefaultAcceptLanguage) { 3919 TEST_F(URLRequestTestHTTP, DefaultAcceptLanguage) {
3920 ASSERT_TRUE(test_server_.Start()); 3920 ASSERT_TRUE(test_server_.Start());
3921 3921
3922 StaticHttpUserAgentSettings settings("en", EmptyString(), EmptyString()); 3922 StaticHttpUserAgentSettings settings("en", EmptyString());
3923 TestNetworkDelegate network_delegate; // Must outlive URLRequests. 3923 TestNetworkDelegate network_delegate; // Must outlive URLRequests.
3924 TestURLRequestContext context(true); 3924 TestURLRequestContext context(true);
3925 context.set_network_delegate(&network_delegate); 3925 context.set_network_delegate(&network_delegate);
3926 context.set_http_user_agent_settings(&settings); 3926 context.set_http_user_agent_settings(&settings);
3927 context.Init(); 3927 context.Init();
3928 3928
3929 TestDelegate d; 3929 TestDelegate d;
3930 URLRequest req( 3930 URLRequest req(
3931 test_server_.GetURL("echoheader?Accept-Language"), &d, &context); 3931 test_server_.GetURL("echoheader?Accept-Language"), &d, &context);
3932 req.Start(); 3932 req.Start();
3933 MessageLoop::current()->Run(); 3933 MessageLoop::current()->Run();
3934 EXPECT_EQ("en", d.data_received()); 3934 EXPECT_EQ("en", d.data_received());
3935 } 3935 }
3936 3936
3937 // Check that an empty A-L header is not sent. http://crbug.com/77365. 3937 // Check that an empty A-L header is not sent. http://crbug.com/77365.
3938 TEST_F(URLRequestTestHTTP, EmptyAcceptLanguage) { 3938 TEST_F(URLRequestTestHTTP, EmptyAcceptLanguage) {
3939 ASSERT_TRUE(test_server_.Start()); 3939 ASSERT_TRUE(test_server_.Start());
3940 3940
3941 StaticHttpUserAgentSettings settings( 3941 StaticHttpUserAgentSettings settings(EmptyString(), EmptyString());
3942 EmptyString(), EmptyString(), EmptyString());
3943 TestNetworkDelegate network_delegate; // Must outlive URLRequests. 3942 TestNetworkDelegate network_delegate; // Must outlive URLRequests.
3944 TestURLRequestContext context(true); 3943 TestURLRequestContext context(true);
3945 context.set_network_delegate(&network_delegate); 3944 context.set_network_delegate(&network_delegate);
3946 context.Init(); 3945 context.Init();
3947 // We override the language after initialization because empty entries 3946 // We override the language after initialization because empty entries
3948 // get overridden by Init(). 3947 // get overridden by Init().
3949 context.set_http_user_agent_settings(&settings); 3948 context.set_http_user_agent_settings(&settings);
3950 3949
3951 TestDelegate d; 3950 TestDelegate d;
3952 URLRequest req( 3951 URLRequest req(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3999 &default_context_); 3998 &default_context_);
4000 HttpRequestHeaders headers; 3999 HttpRequestHeaders headers;
4001 headers.SetHeader(HttpRequestHeaders::kAcceptEncoding, "identity"); 4000 headers.SetHeader(HttpRequestHeaders::kAcceptEncoding, "identity");
4002 req.SetExtraRequestHeaders(headers); 4001 req.SetExtraRequestHeaders(headers);
4003 req.Start(); 4002 req.Start();
4004 MessageLoop::current()->Run(); 4003 MessageLoop::current()->Run();
4005 EXPECT_FALSE(ContainsString(d.data_received(), "gzip")); 4004 EXPECT_FALSE(ContainsString(d.data_received(), "gzip"));
4006 EXPECT_TRUE(ContainsString(d.data_received(), "identity")); 4005 EXPECT_TRUE(ContainsString(d.data_received(), "identity"));
4007 } 4006 }
4008 4007
4009 // Check that default A-C header is sent. 4008 // Check that setting the A-C header sends the proper header.
4010 TEST_F(URLRequestTestHTTP, DefaultAcceptCharset) { 4009 TEST_F(URLRequestTestHTTP, SetAcceptCharset) {
4011 ASSERT_TRUE(test_server_.Start());
4012
4013 StaticHttpUserAgentSettings settings(EmptyString(), "en", EmptyString());
4014 TestNetworkDelegate network_delegate; // Must outlive URLRequests.
4015 TestURLRequestContext context(true);
4016 context.set_network_delegate(&network_delegate);
4017 context.set_http_user_agent_settings(&settings);
4018 context.Init();
4019
4020 TestDelegate d;
4021 URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"),
4022 &d,
4023 &context);
4024 req.Start();
4025 MessageLoop::current()->Run();
4026 EXPECT_EQ("en", d.data_received());
4027 }
4028
4029 // Check that an empty A-C header is not sent. http://crbug.com/77365.
4030 TEST_F(URLRequestTestHTTP, EmptyAcceptCharset) {
4031 ASSERT_TRUE(test_server_.Start());
4032
4033 StaticHttpUserAgentSettings settings(
4034 EmptyString(), EmptyString(), EmptyString());
4035 TestNetworkDelegate network_delegate; // Must outlive URLRequests.
4036 TestURLRequestContext context(true);
4037 context.set_network_delegate(&network_delegate);
4038 context.Init();
4039 // We override the accepted charset after initialization because empty
4040 // entries get overridden otherwise.
4041 context.set_http_user_agent_settings(&settings);
4042
4043 TestDelegate d;
4044 URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"),
4045 &d,
4046 &context);
4047 req.Start();
4048 MessageLoop::current()->Run();
4049 EXPECT_EQ("None", d.data_received());
4050 }
4051
4052 // Check that if request overrides the A-C header, the default is not appended.
4053 // See http://crbug.com/20894
4054 TEST_F(URLRequestTestHTTP, OverrideAcceptCharset) {
4055 ASSERT_TRUE(test_server_.Start()); 4010 ASSERT_TRUE(test_server_.Start());
4056 4011
4057 TestDelegate d; 4012 TestDelegate d;
4058 URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"), 4013 URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"),
4059 &d, 4014 &d,
4060 &default_context_); 4015 &default_context_);
4061 HttpRequestHeaders headers; 4016 HttpRequestHeaders headers;
4062 headers.SetHeader(HttpRequestHeaders::kAcceptCharset, "koi-8r"); 4017 headers.SetHeader(HttpRequestHeaders::kAcceptCharset, "koi-8r");
4063 req.SetExtraRequestHeaders(headers); 4018 req.SetExtraRequestHeaders(headers);
4064 req.Start(); 4019 req.Start();
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
5367 5322
5368 EXPECT_FALSE(r.is_pending()); 5323 EXPECT_FALSE(r.is_pending());
5369 EXPECT_EQ(1, d->response_started_count()); 5324 EXPECT_EQ(1, d->response_started_count());
5370 EXPECT_FALSE(d->received_data_before_response()); 5325 EXPECT_FALSE(d->received_data_before_response());
5371 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 5326 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
5372 } 5327 }
5373 } 5328 }
5374 #endif // !defined(DISABLE_FTP_SUPPORT) 5329 #endif // !defined(DISABLE_FTP_SUPPORT)
5375 5330
5376 } // namespace net 5331 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_test_util.cc ('k') | sync/internal_api/http_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698