Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 6881106: Treat ERR_CONNECTION_CLOSED as end-of-data marker for downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pick 91c11da Forced logging on again. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 EXPECT_EQ(1, d.response_started_count()); 421 EXPECT_EQ(1, d.response_started_count());
422 EXPECT_FALSE(d.received_data_before_response()); 422 EXPECT_FALSE(d.received_data_before_response());
423 EXPECT_NE(0, d.bytes_received()); 423 EXPECT_NE(0, d.bytes_received());
424 EXPECT_EQ(test_server_.host_port_pair().host(), 424 EXPECT_EQ(test_server_.host_port_pair().host(),
425 r.GetSocketAddress().host()); 425 r.GetSocketAddress().host());
426 EXPECT_EQ(test_server_.host_port_pair().port(), 426 EXPECT_EQ(test_server_.host_port_pair().port(),
427 r.GetSocketAddress().port()); 427 r.GetSocketAddress().port());
428 } 428 }
429 } 429 }
430 430
431 TEST_F(URLRequestTestHTTP, GetZippedTest) {
432 ASSERT_TRUE(test_server_.Start());
433
434 // Parameter that specifies the Content-Length field in the response:
435 // C - Compressed length.
436 // U - Uncompressed length.
437 // L - Large length (larger than both C & U).
438 // M - Medium length (between C & U).
439 // S - Small length (smaller than both C & U).
440 const char test_parameters[] = "CULMS";
441 const int num_tests =
442 (sizeof(test_parameters) / sizeof(test_parameters[0])) - 1; // Skip NULL.
willchan no longer on Chromium 2011/05/23 22:12:26 Use arraysize() instead.
ahendrickson 2011/05/24 04:58:37 Done.
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
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
OLDNEW
« net/url_request/url_request_http_job.cc ('K') | « net/url_request/url_request_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698