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

Unified Diff: net/url_request/url_request_unittest.cc

Issue 6065008: Do not override User-Agent header added by WebCore (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | webkit/glue/weburlloader_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_unittest.cc
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index e53a6e310a2253adbd3c0777cf6881d46e5d470e..82efe662e52dc9a36e45fd6554b34f2791160465 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -2642,3 +2642,32 @@ TEST_F(URLRequestTestHTTP, OverrideAcceptCharset) {
MessageLoop::current()->Run();
EXPECT_EQ(std::string("koi-8r"), d.data_received());
}
+
+// Check that default User-Agent header is sent.
+TEST_F(URLRequestTestHTTP, DefaultUserAgent) {
+ ASSERT_TRUE(test_server_.Start());
+
+ TestDelegate d;
+ TestURLRequest req(test_server_.GetURL("echoheader?User-Agent"), &d);
+ req.set_context(new TestURLRequestContext());
+ req.Start();
+ MessageLoop::current()->Run();
+ EXPECT_EQ(req.context()->GetUserAgent(req.url()), d.data_received());
+}
+
+// Check that if request overrides the User-Agent header,
+// the default is not appended.
+TEST_F(URLRequestTestHTTP, OverrideUserAgent) {
+ ASSERT_TRUE(test_server_.Start());
+
+ TestDelegate d;
+ TestURLRequest
+ req(test_server_.GetURL("echoheaderoverride?User-Agent"), &d);
+ req.set_context(new TestURLRequestContext());
+ net::HttpRequestHeaders headers;
+ headers.SetHeader(net::HttpRequestHeaders::kUserAgent, "Lynx (textmode)");
+ req.SetExtraRequestHeaders(headers);
+ req.Start();
+ MessageLoop::current()->Run();
+ EXPECT_EQ(std::string("Lynx (textmode)"), d.data_received());
+}
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | webkit/glue/weburlloader_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698