Stop sending Accept-Charset HTTP header as its not relevant anymore. Remove it from HttpUserAgentSettings as well as this is no longer needed.
BUG=112804 Review URL: https://chromiumcodereview.appspot.com/12463021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188237 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
android_webview/browser/net
chrome
browser
automation
io_thread.ccnet
basic_http_user_agent_settings.ccbasic_http_user_agent_settings.hchrome_http_user_agent_settings.ccchrome_http_user_agent_settings.h
policy
service
content/shell
net
http
url_request
sync/internal_api
webkit/tools/test_shell
@ -58,9 +58,6 @@ void AwURLRequestContextGetter::Init() {
|
||||
content::GetContentClient()->browser()->GetAcceptLangs(
|
||||
browser_context_)));
|
||||
|
||||
builder.set_accept_charset(
|
||||
net::HttpUtil::GenerateAcceptCharsetHeader("utf-8"));
|
||||
|
||||
url_request_context_.reset(builder.Build());
|
||||
|
||||
// TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads.
|
||||
|
@ -460,8 +460,7 @@ void URLRequestAutomationJob::StartAsync() {
|
||||
for (size_t i = 0; i < arraysize(kFilteredHeaderStrings); ++i)
|
||||
new_request_headers.RemoveHeader(kFilteredHeaderStrings[i]);
|
||||
|
||||
// Only add default Accept-Language and Accept-Charset if the request
|
||||
// didn't have them specified.
|
||||
// Only add default Accept-Language if the request didn't have it specified.
|
||||
if (!new_request_headers.HasHeader(
|
||||
net::HttpRequestHeaders::kAcceptLanguage) &&
|
||||
http_user_agent_settings_) {
|
||||
@ -472,15 +471,6 @@ void URLRequestAutomationJob::StartAsync() {
|
||||
accept_language);
|
||||
}
|
||||
}
|
||||
if (!new_request_headers.HasHeader(
|
||||
net::HttpRequestHeaders::kAcceptCharset) &&
|
||||
http_user_agent_settings_) {
|
||||
std::string accept_charset = http_user_agent_settings_->GetAcceptCharset();
|
||||
if (!accept_charset.empty()) {
|
||||
new_request_headers.SetHeader(net::HttpRequestHeaders::kAcceptCharset,
|
||||
accept_charset);
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that we do not send username and password fields in the referrer.
|
||||
GURL referrer(request_->GetSanitizedReferrer());
|
||||
|
@ -511,7 +511,7 @@ void IOThread::Init() {
|
||||
globals_->load_time_stats.reset(new chrome_browser_net::LoadTimeStats());
|
||||
globals_->host_mapping_rules.reset(new net::HostMappingRules());
|
||||
globals_->http_user_agent_settings.reset(
|
||||
new BasicHttpUserAgentSettings(EmptyString(), EmptyString()));
|
||||
new BasicHttpUserAgentSettings(std::string()));
|
||||
if (command_line.HasSwitch(switches::kHostRules)) {
|
||||
globals_->host_mapping_rules->SetRulesFromString(
|
||||
command_line.GetSwitchValueASCII(switches::kHostRules));
|
||||
|
@ -7,9 +7,8 @@
|
||||
#include "content/public/common/content_client.h"
|
||||
|
||||
BasicHttpUserAgentSettings::BasicHttpUserAgentSettings(
|
||||
const std::string& accept_language, const std::string& accept_charset)
|
||||
: accept_language_(accept_language),
|
||||
accept_charset_(accept_charset) {
|
||||
const std::string& accept_language)
|
||||
: accept_language_(accept_language) {
|
||||
}
|
||||
|
||||
BasicHttpUserAgentSettings::~BasicHttpUserAgentSettings() {
|
||||
@ -19,10 +18,6 @@ std::string BasicHttpUserAgentSettings::GetAcceptLanguage() const {
|
||||
return accept_language_;
|
||||
}
|
||||
|
||||
std::string BasicHttpUserAgentSettings::GetAcceptCharset() const {
|
||||
return accept_charset_;
|
||||
}
|
||||
|
||||
std::string BasicHttpUserAgentSettings::GetUserAgent(const GURL& url) const {
|
||||
return content::GetUserAgent(url);
|
||||
}
|
||||
|
@ -11,23 +11,20 @@
|
||||
#include "base/compiler_specific.h"
|
||||
#include "net/url_request/http_user_agent_settings.h"
|
||||
|
||||
// An implementation of |HttpUserAgentSettings| that provides fixed values for
|
||||
// the HTTP headers Accept-Language and Accept-Charset and uses
|
||||
// |content::GetUserAgent| to provide the HTTP User-Agent header value.
|
||||
// An implementation of |HttpUserAgentSettings| that provides fixed value for
|
||||
// the Accept-Language HTTP header and uses |content::GetUserAgent| to provide
|
||||
// the HTTP User-Agent header value.
|
||||
class BasicHttpUserAgentSettings : public net::HttpUserAgentSettings {
|
||||
public:
|
||||
BasicHttpUserAgentSettings(const std::string& accept_language,
|
||||
const std::string& accept_charset);
|
||||
explicit BasicHttpUserAgentSettings(const std::string& accept_language);
|
||||
virtual ~BasicHttpUserAgentSettings();
|
||||
|
||||
// HttpUserAgentSettings implementation
|
||||
virtual std::string GetAcceptLanguage() const OVERRIDE;
|
||||
virtual std::string GetAcceptCharset() const OVERRIDE;
|
||||
virtual std::string GetUserAgent(const GURL& url) const OVERRIDE;
|
||||
|
||||
private:
|
||||
const std::string accept_language_;
|
||||
const std::string accept_charset_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(BasicHttpUserAgentSettings);
|
||||
};
|
||||
|
@ -13,19 +13,12 @@
|
||||
ChromeHttpUserAgentSettings::ChromeHttpUserAgentSettings(PrefService* prefs) {
|
||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
||||
pref_accept_language_.Init(prefs::kAcceptLanguages, prefs);
|
||||
pref_accept_charset_.Init(prefs::kDefaultCharset, prefs);
|
||||
last_pref_accept_language_ = *pref_accept_language_;
|
||||
last_http_accept_language_ =
|
||||
net::HttpUtil::GenerateAcceptLanguageHeader(last_pref_accept_language_);
|
||||
last_pref_accept_charset_ = *pref_accept_charset_;
|
||||
last_http_accept_charset_ =
|
||||
net::HttpUtil::GenerateAcceptCharsetHeader(last_pref_accept_charset_);
|
||||
pref_accept_language_.MoveToThread(
|
||||
content::BrowserThread::GetMessageLoopProxyForThread(
|
||||
content::BrowserThread::IO));
|
||||
pref_accept_charset_.MoveToThread(
|
||||
content::BrowserThread::GetMessageLoopProxyForThread(
|
||||
content::BrowserThread::IO));
|
||||
}
|
||||
|
||||
ChromeHttpUserAgentSettings::~ChromeHttpUserAgentSettings() {
|
||||
@ -35,7 +28,6 @@ ChromeHttpUserAgentSettings::~ChromeHttpUserAgentSettings() {
|
||||
void ChromeHttpUserAgentSettings::CleanupOnUIThread() {
|
||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
||||
pref_accept_language_.Destroy();
|
||||
pref_accept_charset_.Destroy();
|
||||
}
|
||||
|
||||
std::string ChromeHttpUserAgentSettings::GetAcceptLanguage() const {
|
||||
@ -49,17 +41,6 @@ std::string ChromeHttpUserAgentSettings::GetAcceptLanguage() const {
|
||||
return last_http_accept_language_;
|
||||
}
|
||||
|
||||
std::string ChromeHttpUserAgentSettings::GetAcceptCharset() const {
|
||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
||||
std::string new_pref_accept_charset = *pref_accept_charset_;
|
||||
if (new_pref_accept_charset != last_pref_accept_charset_) {
|
||||
last_http_accept_charset_ =
|
||||
net::HttpUtil::GenerateAcceptCharsetHeader(new_pref_accept_charset);
|
||||
last_pref_accept_charset_ = new_pref_accept_charset;
|
||||
}
|
||||
return last_http_accept_charset_;
|
||||
}
|
||||
|
||||
std::string ChromeHttpUserAgentSettings::GetUserAgent(const GURL& url) const {
|
||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
||||
return content::GetUserAgent(url);
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
class PrefService;
|
||||
|
||||
// An implementation of |HttpUserAgentSettings| that provides HTTP headers
|
||||
// Accept-Language and Accept-Charset values that track Pref settings and uses
|
||||
// An implementation of |HttpUserAgentSettings| that provides HTTP header
|
||||
// Accept-Language value that tracks Pref settings and uses
|
||||
// |content::GetUserAgent| to provide the HTTP User-Agent header value.
|
||||
class ChromeHttpUserAgentSettings : public net::HttpUserAgentSettings {
|
||||
public:
|
||||
@ -28,19 +28,15 @@ class ChromeHttpUserAgentSettings : public net::HttpUserAgentSettings {
|
||||
|
||||
// net::HttpUserAgentSettings implementation
|
||||
virtual std::string GetAcceptLanguage() const OVERRIDE;
|
||||
virtual std::string GetAcceptCharset() const OVERRIDE;
|
||||
virtual std::string GetUserAgent(const GURL& url) const OVERRIDE;
|
||||
|
||||
private:
|
||||
StringPrefMember pref_accept_language_;
|
||||
StringPrefMember pref_accept_charset_;
|
||||
|
||||
// Avoid re-processing by caching the last value from the preferences and the
|
||||
// last result of processing via net::HttpUtil::GenerateAccept*Header().
|
||||
mutable std::string last_pref_accept_language_;
|
||||
mutable std::string last_http_accept_language_;
|
||||
mutable std::string last_pref_accept_charset_;
|
||||
mutable std::string last_http_accept_charset_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ChromeHttpUserAgentSettings);
|
||||
};
|
||||
|
@ -221,8 +221,8 @@ class DeviceManagementRequestContext : public net::URLRequestContext {
|
||||
|
||||
DeviceManagementRequestContext::DeviceManagementRequestContext(
|
||||
net::URLRequestContext* base_context)
|
||||
// Use sane Accept-Language and Accept-Charset values for our purposes.
|
||||
: basic_http_user_agent_settings_("*", "*") {
|
||||
// Use sane Accept-Language value for our purposes.
|
||||
: basic_http_user_agent_settings_("*") {
|
||||
// Share resolver, proxy service and ssl bits with the baseline context. This
|
||||
// is important so we don't make redundant requests (e.g. when resolving proxy
|
||||
// auto configuration).
|
||||
|
@ -139,7 +139,7 @@ ServiceURLRequestContext::ServiceURLRequestContext(
|
||||
// In-memory cookie store.
|
||||
storage_.set_cookie_store(new net::CookieMonster(NULL, NULL));
|
||||
storage_.set_http_user_agent_settings(new net::StaticHttpUserAgentSettings(
|
||||
"en-us,fr", "iso-8859-1,*,utf-8", user_agent));
|
||||
"en-us,fr", user_agent));
|
||||
}
|
||||
|
||||
ServiceURLRequestContext::~ServiceURLRequestContext() {
|
||||
|
@ -98,8 +98,7 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
|
||||
new net::DefaultServerBoundCertStore(NULL),
|
||||
base::WorkerPool::GetTaskRunner(true)));
|
||||
storage_->set_http_user_agent_settings(
|
||||
new net::StaticHttpUserAgentSettings(
|
||||
"en-us,en", "iso-8859-1,*,utf-8", EmptyString()));
|
||||
new net::StaticHttpUserAgentSettings("en-us,en", EmptyString()));
|
||||
|
||||
scoped_ptr<net::HostResolver> host_resolver(
|
||||
net::HostResolver::CreateDefaultResolver(NULL));
|
||||
|
@ -684,16 +684,6 @@ std::string HttpUtil::GenerateAcceptLanguageHeader(
|
||||
return lang_list_with_q;
|
||||
}
|
||||
|
||||
std::string HttpUtil::GenerateAcceptCharsetHeader(const std::string& charset) {
|
||||
std::string charset_with_q = charset;
|
||||
if (LowerCaseEqualsASCII(charset, "utf-8")) {
|
||||
charset_with_q += ",*;q=0.5";
|
||||
} else {
|
||||
charset_with_q += ",utf-8;q=0.7,*;q=0.3";
|
||||
}
|
||||
return charset_with_q;
|
||||
}
|
||||
|
||||
void HttpUtil::AppendHeaderIfMissing(const char* header_name,
|
||||
const std::string& header_value,
|
||||
std::string* headers) {
|
||||
|
@ -176,11 +176,6 @@ class NET_EXPORT HttpUtil {
|
||||
static std::string GenerateAcceptLanguageHeader(
|
||||
const std::string& raw_language_list);
|
||||
|
||||
// Given a charset, return the list with a qvalue. If charset is utf-8,
|
||||
// it will return 'utf-8,*;q=0.5'. Otherwise (e.g. 'euc-jp'), it'll return
|
||||
// 'euc-jp,utf-8;q=0.7,*;q=0.3'.
|
||||
static std::string GenerateAcceptCharsetHeader(const std::string& charset);
|
||||
|
||||
// Helper. If |*headers| already contains |header_name| do nothing,
|
||||
// otherwise add <header_name> ": " <header_value> to the end of the list.
|
||||
static void AppendHeaderIfMissing(const char* header_name,
|
||||
|
@ -632,13 +632,6 @@ TEST(HttpUtilTest, GenerateAcceptLanguageHeader) {
|
||||
HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de,ko,zh-CN,ja"));
|
||||
}
|
||||
|
||||
TEST(HttpUtilTest, GenerateAcceptCharsetHeader) {
|
||||
EXPECT_EQ(std::string("utf-8,*;q=0.5"),
|
||||
HttpUtil::GenerateAcceptCharsetHeader("utf-8"));
|
||||
EXPECT_EQ(std::string("EUC-JP,utf-8;q=0.7,*;q=0.3"),
|
||||
HttpUtil::GenerateAcceptCharsetHeader("EUC-JP"));
|
||||
}
|
||||
|
||||
// HttpResponseHeadersTest.GetMimeType also tests ParseContentType.
|
||||
TEST(HttpUtilTest, ParseContentType) {
|
||||
const struct {
|
||||
|
@ -14,8 +14,8 @@ class GURL;
|
||||
|
||||
namespace net {
|
||||
|
||||
// The interface used by HTTP jobs to retrieve HTTP Accept-Language,
|
||||
// Accept-Charset and User-Agent header values.
|
||||
// The interface used by HTTP jobs to retrieve HTTP Accept-Language
|
||||
// and User-Agent header values.
|
||||
class NET_EXPORT HttpUserAgentSettings {
|
||||
public:
|
||||
HttpUserAgentSettings() {}
|
||||
@ -24,9 +24,6 @@ class NET_EXPORT HttpUserAgentSettings {
|
||||
// Gets the value of 'Accept-Language' header field.
|
||||
virtual std::string GetAcceptLanguage() const = 0;
|
||||
|
||||
// Gets the value of 'Accept-Charset' header field.
|
||||
virtual std::string GetAcceptCharset() const = 0;
|
||||
|
||||
// Gets the UA string to use for the given URL. Pass an empty URL to get
|
||||
// the default UA string.
|
||||
virtual std::string GetUserAgent(const GURL& url) const = 0;
|
||||
|
@ -8,10 +8,8 @@ namespace net {
|
||||
|
||||
StaticHttpUserAgentSettings::StaticHttpUserAgentSettings(
|
||||
const std::string& accept_language,
|
||||
const std::string& accept_charset,
|
||||
const std::string& user_agent)
|
||||
: accept_language_(accept_language),
|
||||
accept_charset_(accept_charset),
|
||||
user_agent_(user_agent) {
|
||||
}
|
||||
|
||||
@ -22,10 +20,6 @@ std::string StaticHttpUserAgentSettings::GetAcceptLanguage() const {
|
||||
return accept_language_;
|
||||
}
|
||||
|
||||
std::string StaticHttpUserAgentSettings::GetAcceptCharset() const {
|
||||
return accept_charset_;
|
||||
}
|
||||
|
||||
std::string StaticHttpUserAgentSettings::GetUserAgent(const GURL& url) const {
|
||||
return user_agent_;
|
||||
}
|
||||
|
@ -15,23 +15,19 @@
|
||||
namespace net {
|
||||
|
||||
// An implementation of |HttpUserAgentSettings| that always provides the
|
||||
// same constant values for the HTTP Accept-Language, Accept-Charset, and
|
||||
// User-Agent headers.
|
||||
// same constant values for the HTTP Accept-Language and User-Agent headers.
|
||||
class NET_EXPORT StaticHttpUserAgentSettings : public HttpUserAgentSettings {
|
||||
public:
|
||||
StaticHttpUserAgentSettings(const std::string& accept_language,
|
||||
const std::string& accept_charset,
|
||||
const std::string& user_agent);
|
||||
virtual ~StaticHttpUserAgentSettings();
|
||||
|
||||
// HttpUserAgentSettings implementation
|
||||
virtual std::string GetAcceptLanguage() const OVERRIDE;
|
||||
virtual std::string GetAcceptCharset() const OVERRIDE;
|
||||
virtual std::string GetUserAgent(const GURL& url) const OVERRIDE;
|
||||
|
||||
private:
|
||||
const std::string accept_language_;
|
||||
const std::string accept_charset_;
|
||||
const std::string user_agent_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(StaticHttpUserAgentSettings);
|
||||
|
@ -85,11 +85,6 @@ void URLRequestContext::set_cookie_store(CookieStore* cookie_store) {
|
||||
cookie_store_ = cookie_store;
|
||||
}
|
||||
|
||||
std::string URLRequestContext::GetAcceptCharset() const {
|
||||
return http_user_agent_settings_ ?
|
||||
http_user_agent_settings_->GetAcceptCharset() : EmptyString();
|
||||
}
|
||||
|
||||
std::string URLRequestContext::GetAcceptLanguage() const {
|
||||
return http_user_agent_settings_ ?
|
||||
http_user_agent_settings_->GetAcceptLanguage() : EmptyString();
|
||||
|
@ -178,8 +178,6 @@ class NET_EXPORT URLRequestContext
|
||||
// Legacy accessors that delegate to http_user_agent_settings_.
|
||||
// TODO(pauljensen): Remove after all clients are updated to directly access
|
||||
// http_user_agent_settings_.
|
||||
// Gets the value of 'Accept-Charset' header field.
|
||||
std::string GetAcceptCharset() const;
|
||||
// Gets the value of 'Accept-Language' header field.
|
||||
std::string GetAcceptLanguage() const;
|
||||
// Gets the UA string to use for the given URL. Pass an invalid URL (such as
|
||||
@ -209,7 +207,7 @@ class NET_EXPORT URLRequestContext
|
||||
void AssertNoURLRequests() const;
|
||||
|
||||
// Get the underlying |HttpUserAgentSettings| implementation that provides
|
||||
// the HTTP Accept-Language, Accept-Charset and User-Agent header values.
|
||||
// the HTTP Accept-Language and User-Agent header values.
|
||||
const HttpUserAgentSettings* http_user_agent_settings() const {
|
||||
return http_user_agent_settings_;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ URLRequestContext* URLRequestContextBuilder::Build() {
|
||||
URLRequestContextStorage* storage = context->storage();
|
||||
|
||||
storage->set_http_user_agent_settings(new StaticHttpUserAgentSettings(
|
||||
accept_language_, accept_charset_, user_agent_));
|
||||
accept_language_, user_agent_));
|
||||
|
||||
if (!network_delegate_)
|
||||
network_delegate_.reset(new BasicNetworkDelegate);
|
||||
|
@ -72,15 +72,12 @@ class NET_EXPORT URLRequestContextBuilder {
|
||||
void set_proxy_config_service(ProxyConfigService* proxy_config_service);
|
||||
#endif // defined(OS_LINUX) || defined(OS_ANDROID)
|
||||
|
||||
// Call these functions to specify hard-coded Accept-Language,
|
||||
// Accept-Charset, or User-Agent header values for all requests that don't
|
||||
// Call these functions to specify hard-coded Accept-Language
|
||||
// or User-Agent header values for all requests that don't
|
||||
// have the headers already set.
|
||||
void set_accept_language(const std::string& accept_language) {
|
||||
accept_language_ = accept_language;
|
||||
}
|
||||
void set_accept_charset(const std::string& accept_charset) {
|
||||
accept_charset_ = accept_charset;
|
||||
}
|
||||
void set_user_agent(const std::string& user_agent) {
|
||||
user_agent_ = user_agent;
|
||||
}
|
||||
@ -116,7 +113,6 @@ class NET_EXPORT URLRequestContextBuilder {
|
||||
|
||||
private:
|
||||
std::string accept_language_;
|
||||
std::string accept_charset_;
|
||||
std::string user_agent_;
|
||||
bool ftp_enabled_;
|
||||
bool http_cache_enabled_;
|
||||
|
@ -307,8 +307,7 @@ TEST_F(URLRequestFtpJobTest, FtpProxyRequestDoNotReuseSocket) {
|
||||
"Connection: keep-alive\r\n"
|
||||
"User-Agent:\r\n"
|
||||
"Accept-Encoding: gzip,deflate\r\n"
|
||||
"Accept-Language: en-us,fr\r\n"
|
||||
"Accept-Charset: iso-8859-1,*,utf-8\r\n\r\n"),
|
||||
"Accept-Language: en-us,fr\r\n\r\n"),
|
||||
};
|
||||
MockRead reads1[] = {
|
||||
MockRead(ASYNC, 1, "HTTP/1.1 200 OK\r\n"),
|
||||
|
@ -484,8 +484,8 @@ void URLRequestHttpJob::AddExtraHeaders() {
|
||||
}
|
||||
|
||||
if (http_user_agent_settings_) {
|
||||
// Only add default Accept-Language and Accept-Charset if the request
|
||||
// didn't have them specified.
|
||||
// Only add default Accept-Language if the request didn't have it
|
||||
// specified.
|
||||
std::string accept_language =
|
||||
http_user_agent_settings_->GetAcceptLanguage();
|
||||
if (!accept_language.empty()) {
|
||||
@ -493,12 +493,6 @@ void URLRequestHttpJob::AddExtraHeaders() {
|
||||
HttpRequestHeaders::kAcceptLanguage,
|
||||
accept_language);
|
||||
}
|
||||
std::string accept_charset = http_user_agent_settings_->GetAcceptCharset();
|
||||
if (!accept_charset.empty()) {
|
||||
request_info_.extra_headers.SetHeaderIfMissing(
|
||||
HttpRequestHeaders::kAcceptCharset,
|
||||
accept_charset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,8 +124,7 @@ void TestURLRequestContext::Init() {
|
||||
}
|
||||
if (!http_user_agent_settings()) {
|
||||
context_storage_.set_http_user_agent_settings(
|
||||
new StaticHttpUserAgentSettings(
|
||||
"en-us,fr", "iso-8859-1,*,utf-8", EmptyString()));
|
||||
new StaticHttpUserAgentSettings("en-us,fr", EmptyString()));
|
||||
}
|
||||
if (!job_factory())
|
||||
context_storage_.set_job_factory(new URLRequestJobFactoryImpl);
|
||||
|
@ -3919,7 +3919,7 @@ TEST_F(URLRequestTestHTTP, InterceptPost307RedirectPost) {
|
||||
TEST_F(URLRequestTestHTTP, DefaultAcceptLanguage) {
|
||||
ASSERT_TRUE(test_server_.Start());
|
||||
|
||||
StaticHttpUserAgentSettings settings("en", EmptyString(), EmptyString());
|
||||
StaticHttpUserAgentSettings settings("en", EmptyString());
|
||||
TestNetworkDelegate network_delegate; // Must outlive URLRequests.
|
||||
TestURLRequestContext context(true);
|
||||
context.set_network_delegate(&network_delegate);
|
||||
@ -3938,8 +3938,7 @@ TEST_F(URLRequestTestHTTP, DefaultAcceptLanguage) {
|
||||
TEST_F(URLRequestTestHTTP, EmptyAcceptLanguage) {
|
||||
ASSERT_TRUE(test_server_.Start());
|
||||
|
||||
StaticHttpUserAgentSettings settings(
|
||||
EmptyString(), EmptyString(), EmptyString());
|
||||
StaticHttpUserAgentSettings settings(EmptyString(), EmptyString());
|
||||
TestNetworkDelegate network_delegate; // Must outlive URLRequests.
|
||||
TestURLRequestContext context(true);
|
||||
context.set_network_delegate(&network_delegate);
|
||||
@ -4006,52 +4005,8 @@ TEST_F(URLRequestTestHTTP, OverrideAcceptEncoding) {
|
||||
EXPECT_TRUE(ContainsString(d.data_received(), "identity"));
|
||||
}
|
||||
|
||||
// Check that default A-C header is sent.
|
||||
TEST_F(URLRequestTestHTTP, DefaultAcceptCharset) {
|
||||
ASSERT_TRUE(test_server_.Start());
|
||||
|
||||
StaticHttpUserAgentSettings settings(EmptyString(), "en", EmptyString());
|
||||
TestNetworkDelegate network_delegate; // Must outlive URLRequests.
|
||||
TestURLRequestContext context(true);
|
||||
context.set_network_delegate(&network_delegate);
|
||||
context.set_http_user_agent_settings(&settings);
|
||||
context.Init();
|
||||
|
||||
TestDelegate d;
|
||||
URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"),
|
||||
&d,
|
||||
&context);
|
||||
req.Start();
|
||||
MessageLoop::current()->Run();
|
||||
EXPECT_EQ("en", d.data_received());
|
||||
}
|
||||
|
||||
// Check that an empty A-C header is not sent. http://crbug.com/77365.
|
||||
TEST_F(URLRequestTestHTTP, EmptyAcceptCharset) {
|
||||
ASSERT_TRUE(test_server_.Start());
|
||||
|
||||
StaticHttpUserAgentSettings settings(
|
||||
EmptyString(), EmptyString(), EmptyString());
|
||||
TestNetworkDelegate network_delegate; // Must outlive URLRequests.
|
||||
TestURLRequestContext context(true);
|
||||
context.set_network_delegate(&network_delegate);
|
||||
context.Init();
|
||||
// We override the accepted charset after initialization because empty
|
||||
// entries get overridden otherwise.
|
||||
context.set_http_user_agent_settings(&settings);
|
||||
|
||||
TestDelegate d;
|
||||
URLRequest req(test_server_.GetURL("echoheader?Accept-Charset"),
|
||||
&d,
|
||||
&context);
|
||||
req.Start();
|
||||
MessageLoop::current()->Run();
|
||||
EXPECT_EQ("None", d.data_received());
|
||||
}
|
||||
|
||||
// Check that if request overrides the A-C header, the default is not appended.
|
||||
// See http://crbug.com/20894
|
||||
TEST_F(URLRequestTestHTTP, OverrideAcceptCharset) {
|
||||
// Check that setting the A-C header sends the proper header.
|
||||
TEST_F(URLRequestTestHTTP, SetAcceptCharset) {
|
||||
ASSERT_TRUE(test_server_.Start());
|
||||
|
||||
TestDelegate d;
|
||||
|
@ -111,7 +111,6 @@ HttpBridge::RequestContext::RequestContext(
|
||||
// figure out if we need to give the user explicit control over policies etc.
|
||||
http_user_agent_settings_.reset(new net::StaticHttpUserAgentSettings(
|
||||
baseline_context->GetAcceptLanguage(),
|
||||
baseline_context->GetAcceptCharset(),
|
||||
user_agent));
|
||||
set_http_user_agent_settings(http_user_agent_settings_.get());
|
||||
|
||||
|
@ -50,8 +50,8 @@ class SYNC_EXPORT_PRIVATE HttpBridge
|
||||
// not use a cache. Thus the same type can be used for incognito mode.
|
||||
class RequestContext : public net::URLRequestContext {
|
||||
public:
|
||||
// |baseline_context| is used to obtain the accept-language,
|
||||
// accept-charsets, and proxy service information for bridged requests.
|
||||
// |baseline_context| is used to obtain the accept-language
|
||||
// and proxy service information for bridged requests.
|
||||
// Typically |baseline_context| should be the net::URLRequestContext of the
|
||||
// currently active profile.
|
||||
RequestContext(
|
||||
|
@ -40,13 +40,10 @@ class TestShellHttpUserAgentSettings : public net::HttpUserAgentSettings {
|
||||
TestShellHttpUserAgentSettings() {}
|
||||
virtual ~TestShellHttpUserAgentSettings() {}
|
||||
|
||||
// hard-code A-L and A-C for test shells
|
||||
// Hard-code Accept-Language for test shells.
|
||||
virtual std::string GetAcceptLanguage() const OVERRIDE {
|
||||
return "en-us,en";
|
||||
}
|
||||
virtual std::string GetAcceptCharset() const OVERRIDE {
|
||||
return "iso-8859-1,*,utf-8";
|
||||
}
|
||||
|
||||
virtual std::string GetUserAgent(const GURL& url) const OVERRIDE {
|
||||
return webkit_glue::GetUserAgent(url);
|
||||
|
Reference in New Issue
Block a user