OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #endif | 10 #endif |
11 | 11 |
12 #include <algorithm> | 12 #include <algorithm> |
13 #include <string> | 13 #include <string> |
14 | 14 |
| 15 #include "base/basictypes.h" |
15 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
16 #include "base/file_util.h" | 17 #include "base/file_util.h" |
17 #include "base/format_macros.h" | 18 #include "base/format_macros.h" |
18 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
19 #include "base/path_service.h" | 20 #include "base/path_service.h" |
20 #include "base/process_util.h" | 21 #include "base/process_util.h" |
21 #include "base/string_number_conversions.h" | 22 #include "base/string_number_conversions.h" |
22 #include "base/string_piece.h" | 23 #include "base/string_piece.h" |
23 #include "base/string_util.h" | 24 #include "base/string_util.h" |
24 #include "base/stringprintf.h" | 25 #include "base/stringprintf.h" |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 EXPECT_EQ(1, d.response_started_count()); | 422 EXPECT_EQ(1, d.response_started_count()); |
422 EXPECT_FALSE(d.received_data_before_response()); | 423 EXPECT_FALSE(d.received_data_before_response()); |
423 EXPECT_NE(0, d.bytes_received()); | 424 EXPECT_NE(0, d.bytes_received()); |
424 EXPECT_EQ(test_server_.host_port_pair().host(), | 425 EXPECT_EQ(test_server_.host_port_pair().host(), |
425 r.GetSocketAddress().host()); | 426 r.GetSocketAddress().host()); |
426 EXPECT_EQ(test_server_.host_port_pair().port(), | 427 EXPECT_EQ(test_server_.host_port_pair().port(), |
427 r.GetSocketAddress().port()); | 428 r.GetSocketAddress().port()); |
428 } | 429 } |
429 } | 430 } |
430 | 431 |
| 432 TEST_F(URLRequestTestHTTP, GetZippedTest) { |
| 433 ASSERT_TRUE(test_server_.Start()); |
| 434 |
| 435 // Parameter that specifies the Content-Length field in the response: |
| 436 // C - Compressed length. |
| 437 // U - Uncompressed length. |
| 438 // L - Large length (larger than both C & U). |
| 439 // M - Medium length (between C & U). |
| 440 // S - Small length (smaller than both C & U). |
| 441 const char test_parameters[] = "CULMS"; |
| 442 const int num_tests = arraysize(test_parameters)- 1; // Skip NULL. |
| 443 // C & U should be OK. |
| 444 // L & M are larger than the data sent, and show an error. |
| 445 // S has too little data, but we seem to accept it. |
| 446 const bool test_expect_success[num_tests] = |
| 447 { true, true, false, false, true }; |
| 448 |
| 449 for (int i = 0; i < num_tests ; i++) { |
| 450 TestDelegate d; |
| 451 { |
| 452 std::string test_file = |
| 453 base::StringPrintf("compressedfiles/BullRunSpeech.txt?%c", |
| 454 test_parameters[i]); |
| 455 TestURLRequest r(test_server_.GetURL(test_file), &d); |
| 456 |
| 457 r.Start(); |
| 458 EXPECT_TRUE(r.is_pending()); |
| 459 |
| 460 MessageLoop::current()->Run(); |
| 461 |
| 462 EXPECT_EQ(1, d.response_started_count()); |
| 463 EXPECT_FALSE(d.received_data_before_response()); |
| 464 VLOG(1) << " Received " << d.bytes_received() << " bytes" |
| 465 << " status = " << r.status().status() |
| 466 << " os_error = " << r.status().os_error(); |
| 467 if (test_expect_success[i]) { |
| 468 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()) |
| 469 << " Parameter = \"" << test_file << "\""; |
| 470 } else { |
| 471 EXPECT_EQ(URLRequestStatus::FAILED, r.status().status()); |
| 472 EXPECT_EQ(-100, r.status().os_error()) |
| 473 << " Parameter = \"" << test_file << "\""; |
| 474 } |
| 475 } |
| 476 } |
| 477 } |
| 478 |
431 TEST_F(URLRequestTestHTTP, HTTPSToHTTPRedirectNoRefererTest) { | 479 TEST_F(URLRequestTestHTTP, HTTPSToHTTPRedirectNoRefererTest) { |
432 ASSERT_TRUE(test_server_.Start()); | 480 ASSERT_TRUE(test_server_.Start()); |
433 | 481 |
434 TestServer https_test_server( | 482 TestServer https_test_server( |
435 TestServer::TYPE_HTTPS, FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 483 TestServer::TYPE_HTTPS, FilePath(FILE_PATH_LITERAL("net/data/ssl"))); |
436 ASSERT_TRUE(https_test_server.Start()); | 484 ASSERT_TRUE(https_test_server.Start()); |
437 | 485 |
438 // An https server is sent a request with an https referer, | 486 // An https server is sent a request with an https referer, |
439 // and responds with a redirect to an http url. The http | 487 // and responds with a redirect to an http url. The http |
440 // server should not be sent the referer. | 488 // server should not be sent the referer. |
(...skipping 2428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2869 req.SetExtraRequestHeaders(headers); | 2917 req.SetExtraRequestHeaders(headers); |
2870 req.Start(); | 2918 req.Start(); |
2871 MessageLoop::current()->Run(); | 2919 MessageLoop::current()->Run(); |
2872 // If the net tests are being run with ChromeFrame then we need to allow for | 2920 // If the net tests are being run with ChromeFrame then we need to allow for |
2873 // the 'chromeframe' suffix which is added to the user agent before the | 2921 // the 'chromeframe' suffix which is added to the user agent before the |
2874 // closing parentheses. | 2922 // closing parentheses. |
2875 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 2923 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
2876 } | 2924 } |
2877 | 2925 |
2878 } // namespace net | 2926 } // namespace net |
OLD | NEW |