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

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

Issue 8496016: Report ERR_CONTENT_LENGTH_MISMATCH when the count of bytes received doesn't match Content-Length. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Clear error Created 9 years, 1 month 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
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | webkit/glue/weburlloader_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 // U - Uncompressed length. 872 // U - Uncompressed length.
873 // L - Large length (larger than both C & U). 873 // L - Large length (larger than both C & U).
874 // M - Medium length (between C & U). 874 // M - Medium length (between C & U).
875 // S - Small length (smaller than both C & U). 875 // S - Small length (smaller than both C & U).
876 const char test_parameters[] = "CULMS"; 876 const char test_parameters[] = "CULMS";
877 const int num_tests = arraysize(test_parameters)- 1; // Skip NULL. 877 const int num_tests = arraysize(test_parameters)- 1; // Skip NULL.
878 // C & U should be OK. 878 // C & U should be OK.
879 // L & M are larger than the data sent, and show an error. 879 // L & M are larger than the data sent, and show an error.
880 // S has too little data, but we seem to accept it. 880 // S has too little data, but we seem to accept it.
881 const bool test_expect_success[num_tests] = 881 const bool test_expect_success[num_tests] =
882 { true, true, false, false, true }; 882 { true, false, false, false, true };
883 883
884 for (int i = 0; i < num_tests ; i++) { 884 for (int i = 0; i < num_tests ; i++) {
885 TestDelegate d; 885 TestDelegate d;
886 { 886 {
887 std::string test_file = 887 std::string test_file =
888 base::StringPrintf("compressedfiles/BullRunSpeech.txt?%c", 888 base::StringPrintf("compressedfiles/BullRunSpeech.txt?%c",
889 test_parameters[i]); 889 test_parameters[i]);
890 890
891 TestNetworkDelegate network_delegate; // must outlive URLRequest 891 TestNetworkDelegate network_delegate; // must outlive URLRequest
892 scoped_refptr<TestURLRequestContext> context( 892 scoped_refptr<TestURLRequestContext> context(
(...skipping 11 matching lines...) Expand all
904 EXPECT_EQ(1, d.response_started_count()); 904 EXPECT_EQ(1, d.response_started_count());
905 EXPECT_FALSE(d.received_data_before_response()); 905 EXPECT_FALSE(d.received_data_before_response());
906 VLOG(1) << " Received " << d.bytes_received() << " bytes" 906 VLOG(1) << " Received " << d.bytes_received() << " bytes"
907 << " status = " << r.status().status() 907 << " status = " << r.status().status()
908 << " error = " << r.status().error(); 908 << " error = " << r.status().error();
909 if (test_expect_success[i]) { 909 if (test_expect_success[i]) {
910 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()) 910 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status())
911 << " Parameter = \"" << test_file << "\""; 911 << " Parameter = \"" << test_file << "\"";
912 } else { 912 } else {
913 EXPECT_EQ(URLRequestStatus::FAILED, r.status().status()); 913 EXPECT_EQ(URLRequestStatus::FAILED, r.status().status());
914 EXPECT_EQ(-100, r.status().error()) 914 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, r.status().error())
915 << " Parameter = \"" << test_file << "\""; 915 << " Parameter = \"" << test_file << "\"";
916 } 916 }
917 } 917 }
918 } 918 }
919 } 919 }
920 920
921 TEST_F(URLRequestTestHTTP, HTTPSToHTTPRedirectNoRefererTest) { 921 TEST_F(URLRequestTestHTTP, HTTPSToHTTPRedirectNoRefererTest) {
922 ASSERT_TRUE(test_server_.Start()); 922 ASSERT_TRUE(test_server_.Start());
923 923
924 TestServer https_test_server( 924 TestServer https_test_server(
(...skipping 2697 matching lines...) Expand 10 before | Expand all | Expand 10 after
3622 req.SetExtraRequestHeaders(headers); 3622 req.SetExtraRequestHeaders(headers);
3623 req.Start(); 3623 req.Start();
3624 MessageLoop::current()->Run(); 3624 MessageLoop::current()->Run();
3625 // If the net tests are being run with ChromeFrame then we need to allow for 3625 // If the net tests are being run with ChromeFrame then we need to allow for
3626 // the 'chromeframe' suffix which is added to the user agent before the 3626 // the 'chromeframe' suffix which is added to the user agent before the
3627 // closing parentheses. 3627 // closing parentheses.
3628 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); 3628 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true));
3629 } 3629 }
3630 3630
3631 } // namespace net 3631 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | webkit/glue/weburlloader_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698