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 |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 EXPECT_EQ(1, d.response_started_count()); | 419 EXPECT_EQ(1, d.response_started_count()); |
420 EXPECT_FALSE(d.received_data_before_response()); | 420 EXPECT_FALSE(d.received_data_before_response()); |
421 EXPECT_NE(0, d.bytes_received()); | 421 EXPECT_NE(0, d.bytes_received()); |
422 EXPECT_EQ(test_server_.host_port_pair().host(), | 422 EXPECT_EQ(test_server_.host_port_pair().host(), |
423 r.GetSocketAddress().host()); | 423 r.GetSocketAddress().host()); |
424 EXPECT_EQ(test_server_.host_port_pair().port(), | 424 EXPECT_EQ(test_server_.host_port_pair().port(), |
425 r.GetSocketAddress().port()); | 425 r.GetSocketAddress().port()); |
426 } | 426 } |
427 } | 427 } |
428 | 428 |
| 429 TEST_F(URLRequestTestHTTP, GetZippedTest) { |
| 430 ASSERT_TRUE(test_server_.Start()); |
| 431 |
| 432 // Parameter that specifies the Content-Length field in the response: |
| 433 // C - Compressed length. |
| 434 // U - Uncompressed length. |
| 435 // L - Large length (larger than both C & U). |
| 436 // M - Medium length (between C & U). |
| 437 // S - Small length (smaller than both C & U). |
| 438 const char test_parameters[] = "CULMS"; |
| 439 const int num_tests = ARRAYSIZE(test_parameters) - 1; // Skip the NULL. |
| 440 // C & U should be OK. |
| 441 // L & M are larger than the data sent, and show an error. |
| 442 // S has too little data, but we seem to accept it. |
| 443 const bool test_expect_success[num_tests] = |
| 444 { true, true, false, false, true }; |
| 445 |
| 446 for (int i = 0; i < num_tests ; i++) { |
| 447 TestDelegate d; |
| 448 { |
| 449 std::string test_file = |
| 450 base::StringPrintf("files/Picture_1.doc?%c", test_parameters[i]); |
| 451 TestURLRequest r(test_server_.GetURL(test_file), &d); |
| 452 |
| 453 r.Start(); |
| 454 EXPECT_TRUE(r.is_pending()); |
| 455 |
| 456 MessageLoop::current()->Run(); |
| 457 |
| 458 EXPECT_EQ(1, d.response_started_count()); |
| 459 EXPECT_FALSE(d.received_data_before_response()); |
| 460 VLOG(1) << " Received " << d.bytes_received() << " bytes" |
| 461 << " status = " << r.status().status() |
| 462 << " os_error = " << r.status().os_error(); |
| 463 if (test_expect_success[i]) { |
| 464 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); |
| 465 } else { |
| 466 EXPECT_EQ(URLRequestStatus::FAILED, r.status().status()); |
| 467 EXPECT_EQ(-100, r.status().os_error()); |
| 468 } |
| 469 } |
| 470 } |
| 471 } |
| 472 |
429 TEST_F(URLRequestTestHTTP, HTTPSToHTTPRedirectNoRefererTest) { | 473 TEST_F(URLRequestTestHTTP, HTTPSToHTTPRedirectNoRefererTest) { |
430 ASSERT_TRUE(test_server_.Start()); | 474 ASSERT_TRUE(test_server_.Start()); |
431 | 475 |
432 TestServer https_test_server( | 476 TestServer https_test_server( |
433 TestServer::TYPE_HTTPS, FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 477 TestServer::TYPE_HTTPS, FilePath(FILE_PATH_LITERAL("net/data/ssl"))); |
434 ASSERT_TRUE(https_test_server.Start()); | 478 ASSERT_TRUE(https_test_server.Start()); |
435 | 479 |
436 // An https server is sent a request with an https referer, | 480 // An https server is sent a request with an https referer, |
437 // and responds with a redirect to an http url. The http | 481 // and responds with a redirect to an http url. The http |
438 // server should not be sent the referer. | 482 // server should not be sent the referer. |
(...skipping 2448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2887 req.SetExtraRequestHeaders(headers); | 2931 req.SetExtraRequestHeaders(headers); |
2888 req.Start(); | 2932 req.Start(); |
2889 MessageLoop::current()->Run(); | 2933 MessageLoop::current()->Run(); |
2890 // If the net tests are being run with ChromeFrame then we need to allow for | 2934 // If the net tests are being run with ChromeFrame then we need to allow for |
2891 // the 'chromeframe' suffix which is added to the user agent before the | 2935 // the 'chromeframe' suffix which is added to the user agent before the |
2892 // closing parentheses. | 2936 // closing parentheses. |
2893 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 2937 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
2894 } | 2938 } |
2895 | 2939 |
2896 } // namespace net | 2940 } // namespace net |
OLD | NEW |