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

Unified Diff: net/url_request/url_request_job_unittest.cc

Issue 1563633002: Make URLRequestJob::SetStatus private. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to comments Created 4 years, 11 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
Index: net/url_request/url_request_job_unittest.cc
diff --git a/net/url_request/url_request_job_unittest.cc b/net/url_request/url_request_job_unittest.cc
index f3796bdb4c9ccfe8770b64c8b194e66f5e9f1adb..37a457f5090e724bcedee005eaefeb11d934a7ec 100644
--- a/net/url_request/url_request_job_unittest.cc
+++ b/net/url_request/url_request_job_unittest.cc
@@ -126,6 +126,15 @@ const MockTransaction kEmptyBodyGzip_Transaction = {
OK,
};
+const MockTransaction kInvalidContentGZip_Transaction = {
+ "http://www.google.com/gzyp", "GET", base::Time(), "", LOAD_NORMAL,
+ "HTTP/1.1 200 OK",
+ "Content-Encoding: gzip\n"
+ "Content-Length: 21\n",
+ base::Time(), "not a valid gzip body", TEST_MODE_NORMAL, nullptr, nullptr,
+ 0, 0, OK,
+};
+
const MockTransaction kBrotli_Slow_Transaction = {
"http://www.google.com/brotli", "GET", base::Time(), "", LOAD_NORMAL,
"HTTP/1.1 200 OK",
@@ -272,6 +281,34 @@ TEST(URLRequestJob, EmptyBodySkipFilter) {
RemoveMockTransaction(&kEmptyBodyGzip_Transaction);
}
+// Regression test for crbug.com/575213.
+TEST(URLRequestJob, InvalidContentGZipTransaction) {
+ MockNetworkLayer network_layer;
+ TestURLRequestContext context;
+ context.set_http_transaction_factory(&network_layer);
+
+ TestDelegate d;
+ scoped_ptr<URLRequest> req(context.CreateRequest(
+ GURL(kInvalidContentGZip_Transaction.url), DEFAULT_PRIORITY, &d));
+ AddMockTransaction(&kInvalidContentGZip_Transaction);
+
+ req->set_method("GET");
+ req->Start();
+
+ base::MessageLoop::current()->Run();
+
+ // Request failed indicates the request failed before headers were received,
+ // so should be false.
+ EXPECT_FALSE(d.request_failed());
+ EXPECT_EQ(200, req->GetResponseCode());
+ EXPECT_FALSE(req->status().is_success());
+ EXPECT_EQ(ERR_CONTENT_DECODING_FAILED, req->status().error());
+ EXPECT_TRUE(d.data_received().empty());
+ EXPECT_FALSE(network_layer.done_reading_called());
+
+ RemoveMockTransaction(&kInvalidContentGZip_Transaction);
+}
+
// Regression test for crbug.com/553300.
TEST(URLRequestJob, SlowFilterRead) {
MockNetworkLayer network_layer;

Powered by Google App Engine
This is Rietveld 408576698