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

Unified 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: Merged with trunk 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 side-by-side diff with in-line comments
Download patch
« net/tools/testserver/testserver.py ('K') | « net/url_request/url_request_job.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_unittest.cc
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index ebabe8da4a9bd063ec69ccabd8ad58c6ab6bc850..97ceb0853f16b11a2fc40655c5724126819f870b 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -12,6 +12,7 @@
#include <algorithm>
#include <string>
+#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/file_util.h"
#include "base/format_macros.h"
@@ -428,6 +429,53 @@ TEST_F(URLRequestTestHTTP, GetTest) {
}
}
+TEST_F(URLRequestTestHTTP, GetZippedTest) {
+ ASSERT_TRUE(test_server_.Start());
+
+ // Parameter that specifies the Content-Length field in the response:
+ // C - Compressed length.
+ // U - Uncompressed length.
+ // L - Large length (larger than both C & U).
+ // M - Medium length (between C & U).
+ // S - Small length (smaller than both C & U).
+ const char test_parameters[] = "CULMS";
+ const int num_tests = arraysize(test_parameters)- 1; // Skip NULL.
+ // C & U should be OK.
+ // L & M are larger than the data sent, and show an error.
+ // S has too little data, but we seem to accept it.
+ const bool test_expect_success[num_tests] =
+ { true, true, false, false, true };
+
+ for (int i = 0; i < num_tests ; i++) {
+ TestDelegate d;
+ {
+ std::string test_file =
+ base::StringPrintf("compressedfiles/BullRunSpeech.txt?%c",
+ test_parameters[i]);
+ TestURLRequest r(test_server_.GetURL(test_file), &d);
+
+ r.Start();
+ EXPECT_TRUE(r.is_pending());
+
+ MessageLoop::current()->Run();
+
+ EXPECT_EQ(1, d.response_started_count());
+ EXPECT_FALSE(d.received_data_before_response());
+ VLOG(1) << " Received " << d.bytes_received() << " bytes"
+ << " status = " << r.status().status()
+ << " os_error = " << r.status().os_error();
+ if (test_expect_success[i]) {
+ EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status())
+ << " Parameter = \"" << test_file << "\"";
+ } else {
+ EXPECT_EQ(URLRequestStatus::FAILED, r.status().status());
+ EXPECT_EQ(-100, r.status().os_error())
+ << " Parameter = \"" << test_file << "\"";
+ }
+ }
+ }
+}
+
TEST_F(URLRequestTestHTTP, HTTPSToHTTPRedirectNoRefererTest) {
ASSERT_TRUE(test_server_.Start());
« net/tools/testserver/testserver.py ('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