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

Unified Diff: net/url_request/url_request_job_unittest.cc

Issue 1439953006: Reland: URLRequestJob: change ReadRawData contract (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Created 5 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 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 f9ea1fe6170e34d08926435bb08cf97daeb3f0b4..5cde9adfad51fce9faa850e8ed0c2343635c44a0 100644
--- a/net/url_request/url_request_job_unittest.cc
+++ b/net/url_request/url_request_job_unittest.cc
@@ -76,6 +76,24 @@ const MockTransaction kRedirect_Transaction = {
OK,
};
+const MockTransaction kEmptyBody_Transaction = {
mmenke 2015/11/17 18:57:32 Maybe kEmptyBodyGzip_Transaction?
xunjieli 2015/11/17 20:28:35 Done.
+ "http://www.google.com/empty_body",
+ "GET",
+ base::Time(),
+ "",
+ LOAD_NORMAL,
+ "HTTP/1.1 200 OK",
+ "Content-Encoding: gzip\n",
+ base::Time(),
+ "",
+ TEST_MODE_NORMAL,
+ nullptr,
+ nullptr,
+ 0,
+ 0,
+ OK,
+};
+
} // namespace
TEST(URLRequestJob, TransactionNotifiedWhenDone) {
@@ -187,4 +205,30 @@ TEST(URLRequestJob, TransactionNotCachedWhenNetworkDelegateRedirects) {
RemoveMockTransaction(&kGZip_Transaction);
}
+// Makes sure that ReadRawDataComplete correctly updates request status before
+// calling ReadFilteredData.
+// Regression test for crbug.com/553300.
+TEST(URLRequestJob, EmptyBodySkipFilter) {
+ MockNetworkLayer network_layer;
+ TestURLRequestContext context;
+ context.set_http_transaction_factory(&network_layer);
+
+ TestDelegate d;
+ scoped_ptr<URLRequest> req(context.CreateRequest(
+ GURL(kEmptyBody_Transaction.url), DEFAULT_PRIORITY, &d));
+ AddMockTransaction(&kEmptyBody_Transaction);
+
+ req->set_method("GET");
+ req->Start();
+
+ base::MessageLoop::current()->Run();
+
+ EXPECT_FALSE(d.request_failed());
+ EXPECT_EQ(200, req->GetResponseCode());
+ EXPECT_TRUE(d.data_received().empty());
+ EXPECT_TRUE(network_layer.done_reading_called());
+
+ RemoveMockTransaction(&kEmptyBody_Transaction);
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698