diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-23 16:09:41 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-23 16:09:41 +0000 |
commit | eb834fb878a343d3ff67ba087e783a6e796d6fd5 (patch) | |
tree | 1c730e3d447ec4bee84b402ad98a5518fe46172e /net/url_request | |
parent | 596284a3e66f287144f397cc733ca32447f92df9 (diff) | |
download | chromium_src-eb834fb878a343d3ff67ba087e783a6e796d6fd5.zip chromium_src-eb834fb878a343d3ff67ba087e783a6e796d6fd5.tar.gz chromium_src-eb834fb878a343d3ff67ba087e783a6e796d6fd5.tar.bz2 |
Fixes ChromeFrame net tests which run the URLRequest unit tests by launching IE and having it issue
the corresponding HTTP requests via automation. Fixes as below:-
1. The DefaultAcceptCharset and DefaultAcceptLanguage tests were failing because the URL request automation
job would only read the extra headers from the request. These tests set these headers in the URLRequestContext.
We needed to mimic the functionality in the URLRequestHttpJob to add in these headers if they were not
already present. As part of this I moved the AppendHeaderIfMissing function from url_request_http_job.cc
to HttpUtil as it is needed by the automation job as well.
2. The OverrideAcceptLanguage and OverrideAcceptCharset tests started failing in chrome frame net tests
after the fixes to get the default versions of these tests to pass. These tests basically pass in the
Accept-Language and Accept-Charset headers and expect the same values to be echoed back. IE ends up
caching the responses from the default versions of these tests and thus echoes back the old response
which causes these tests to fail. I tried passing in the no-cache header from our HTTP server for
the EchoHeader tests but this did not work. To fix this we now pass in the echoheaderoverride
parameter for the OverrideAcceptLanguage and OverrideAcceptCharset tests. The HTTP server has been
updated to support this.
3. NotifyDone can be called on the job if the original request was redirected. Added a check for whether
NotifyDone was already called on the job in URLRequestAutomationJob
Review URL: http://codereview.chromium.org/322004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29895 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request')
-rw-r--r-- | net/url_request/url_request_http_job.cc | 24 | ||||
-rw-r--r-- | net/url_request/url_request_unittest.cc | 6 |
2 files changed, 10 insertions, 20 deletions
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index aa75574..84d5709 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -584,18 +584,6 @@ void URLRequestHttpJob::StartTransaction() { this, &URLRequestHttpJob::OnStartCompleted, rv)); } -// 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, - const std::string& header_value, - std::string* headers) { - if (header_value.empty()) - return; - if (net::HttpUtil::HasHeader(*headers, header_name)) - return; - *headers += std::string(header_name) + ": " + header_value + "\r\n"; -} - void URLRequestHttpJob::AddExtraHeaders() { // TODO(jar): Consider optimizing away SDCH advertising bytes when the URL is // probably an img or such (and SDCH encoding is not likely). @@ -655,12 +643,12 @@ void URLRequestHttpJob::AddExtraHeaders() { // Only add default Accept-Language and Accept-Charset if the request // didn't have them specified. - AppendHeaderIfMissing("Accept-Language", - context->accept_language(), - &request_info_.extra_headers); - AppendHeaderIfMissing("Accept-Charset", - context->accept_charset(), - &request_info_.extra_headers); + net::HttpUtil::AppendHeaderIfMissing("Accept-Language", + context->accept_language(), + &request_info_.extra_headers); + net::HttpUtil::AppendHeaderIfMissing("Accept-Charset", + context->accept_charset(), + &request_info_.extra_headers); } } diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 0693ac1..6aee61a 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -2177,7 +2177,8 @@ TEST_F(URLRequestTestHTTP, DefaultAcceptLanguage) { TEST_F(URLRequestTestHTTP, OverrideAcceptLanguage) { ASSERT_TRUE(NULL != server_.get()); TestDelegate d; - TestURLRequest req(server_->TestServerPage("echoheader?Accept-Language"), &d); + TestURLRequest + req(server_->TestServerPage("echoheaderoverride?Accept-Language"), &d); req.set_context(new URLRequestTestContext()); req.SetExtraRequestHeaders("Accept-Language: ru"); req.Start(); @@ -2201,7 +2202,8 @@ TEST_F(URLRequestTestHTTP, DefaultAcceptCharset) { TEST_F(URLRequestTestHTTP, OverrideAcceptCharset) { ASSERT_TRUE(NULL != server_.get()); TestDelegate d; - TestURLRequest req(server_->TestServerPage("echoheader?Accept-Charset"), &d); + TestURLRequest + req(server_->TestServerPage("echoheaderoverride?Accept-Charset"), &d); req.set_context(new URLRequestTestContext()); req.SetExtraRequestHeaders("Accept-Charset: koi-8r"); req.Start(); |