| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 "net/proxy/proxy_script_fetcher.h" | 5 #include "net/proxy/proxy_script_fetcher.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 GURL url = server->TestServerPage("files/pac.nsproxy"); | 282 GURL url = server->TestServerPage("files/pac.nsproxy"); |
| 283 std::string bytes; | 283 std::string bytes; |
| 284 TestCompletionCallback callback; | 284 TestCompletionCallback callback; |
| 285 int result = pac_fetcher->Fetch(url, &bytes, &callback); | 285 int result = pac_fetcher->Fetch(url, &bytes, &callback); |
| 286 EXPECT_EQ(ERR_IO_PENDING, result); | 286 EXPECT_EQ(ERR_IO_PENDING, result); |
| 287 EXPECT_EQ(OK, callback.WaitForResult()); | 287 EXPECT_EQ(OK, callback.WaitForResult()); |
| 288 EXPECT_EQ("-pac.nsproxy-\n", bytes); | 288 EXPECT_EQ("-pac.nsproxy-\n", bytes); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 | 291 |
| 292 // The ProxyScriptFetcher should decode any content-codings |
| 293 // (like gzip, bzip, etc.), and apply any charset conversions to yield |
| 294 // UTF8. |
| 295 TEST_F(ProxyScriptFetcherTest, Encodings) { |
| 296 scoped_refptr<HTTPTestServer> server = |
| 297 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 298 ASSERT_TRUE(NULL != server.get()); |
| 299 scoped_refptr<URLRequestContext> context = new RequestContext; |
| 300 scoped_ptr<ProxyScriptFetcher> pac_fetcher( |
| 301 ProxyScriptFetcher::Create(context)); |
| 302 |
| 303 // Test a response that is gzip-encoded -- should get inflated. |
| 304 { |
| 305 GURL url = server->TestServerPage("files/gzipped_pac"); |
| 306 std::string bytes; |
| 307 TestCompletionCallback callback; |
| 308 int result = pac_fetcher->Fetch(url, &bytes, &callback); |
| 309 EXPECT_EQ(ERR_IO_PENDING, result); |
| 310 EXPECT_EQ(OK, callback.WaitForResult()); |
| 311 EXPECT_EQ("This data was gzipped.\n", bytes); |
| 312 } |
| 313 |
| 314 // Test a response that was served as UTF-16 (BE). It should |
| 315 // be converted to UTF8. |
| 316 { |
| 317 GURL url = server->TestServerPage("files/utf16be_pac"); |
| 318 std::string bytes; |
| 319 TestCompletionCallback callback; |
| 320 int result = pac_fetcher->Fetch(url, &bytes, &callback); |
| 321 EXPECT_EQ(ERR_IO_PENDING, result); |
| 322 EXPECT_EQ(OK, callback.WaitForResult()); |
| 323 EXPECT_EQ("This was encoded as UTF-16BE.\n", bytes); |
| 324 } |
| 325 } |
| 326 |
| 292 } // namespace net | 327 } // namespace net |
| OLD | NEW |