diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-22 03:06:54 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-22 03:06:54 +0000 |
commit | 8f3c963473091104513c05328fe2fe98989e8339 (patch) | |
tree | 6dcf38d7305ee622a13b56c5f30143eb833148ef /net/proxy/proxy_script_fetcher_unittest.cc | |
parent | 0f3dfb420337c569091ac303081c30c9e060f842 (diff) | |
download | chromium_src-8f3c963473091104513c05328fe2fe98989e8339.zip chromium_src-8f3c963473091104513c05328fe2fe98989e8339.tar.gz chromium_src-8f3c963473091104513c05328fe2fe98989e8339.tar.bz2 |
Respect the charset specified in PAC file responses.
I have updated the documentation of ProxyResolver and ProxyScriptFetcher to indicate that the response must always be given as UTF8. So ProxyScriptFetcher is responsible for any charset conversions internally.
This CL also adds a unit-test to make sure that content-encodings are respected (like gzip). This was not previously broken, but it is a related area (and wasn't being tested.)
BUG=http://crbug.com/22310
Review URL: http://codereview.chromium.org/210028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26790 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_script_fetcher_unittest.cc')
-rw-r--r-- | net/proxy/proxy_script_fetcher_unittest.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/net/proxy/proxy_script_fetcher_unittest.cc b/net/proxy/proxy_script_fetcher_unittest.cc index e94e20b..87f6a9a 100644 --- a/net/proxy/proxy_script_fetcher_unittest.cc +++ b/net/proxy/proxy_script_fetcher_unittest.cc @@ -289,4 +289,39 @@ TEST_F(ProxyScriptFetcherTest, Hang) { } } +// The ProxyScriptFetcher should decode any content-codings +// (like gzip, bzip, etc.), and apply any charset conversions to yield +// UTF8. +TEST_F(ProxyScriptFetcherTest, Encodings) { + scoped_refptr<HTTPTestServer> server = + HTTPTestServer::CreateServer(kDocRoot, NULL); + ASSERT_TRUE(NULL != server.get()); + scoped_refptr<URLRequestContext> context = new RequestContext; + scoped_ptr<ProxyScriptFetcher> pac_fetcher( + ProxyScriptFetcher::Create(context)); + + // Test a response that is gzip-encoded -- should get inflated. + { + GURL url = server->TestServerPage("files/gzipped_pac"); + std::string bytes; + TestCompletionCallback callback; + int result = pac_fetcher->Fetch(url, &bytes, &callback); + EXPECT_EQ(ERR_IO_PENDING, result); + EXPECT_EQ(OK, callback.WaitForResult()); + EXPECT_EQ("This data was gzipped.\n", bytes); + } + + // Test a response that was served as UTF-16 (BE). It should + // be converted to UTF8. + { + GURL url = server->TestServerPage("files/utf16be_pac"); + std::string bytes; + TestCompletionCallback callback; + int result = pac_fetcher->Fetch(url, &bytes, &callback); + EXPECT_EQ(ERR_IO_PENDING, result); + EXPECT_EQ(OK, callback.WaitForResult()); + EXPECT_EQ("This was encoded as UTF-16BE.\n", bytes); + } +} + } // namespace net |