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

Unified Diff: chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc

Issue 274075: Sniff 204 responses as text/plain to avoid creating unwanted downloads.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 2 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
« no previous file with comments | « chrome/browser/renderer_host/buffered_resource_handler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc
===================================================================
--- chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc (revision 29247)
+++ chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc (working copy)
@@ -846,3 +846,30 @@
GetResponseHead(msgs[0], &response_head);
ASSERT_EQ("", response_head.mime_type);
}
+
+TEST_F(ResourceDispatcherHostTest, MimeSniff204) {
+ EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
+
+ std::string response("HTTP/1.1 204 No Content\n\n");
+ std::string raw_headers(net::HttpUtil::AssembleRawHeaders(response.data(),
+ response.size()));
+ std::string response_data;
+ SetResponse(raw_headers, response_data);
+
+ HandleScheme("http");
+ MakeTestRequest(0, 1, GURL("http:bla"));
+
+ // Flush all pending requests.
+ while (URLRequestTestJob::ProcessOnePendingMessage());
+
+ EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
+
+ // Sorts out all the messages we saw by request.
+ ResourceIPCAccumulator::ClassifiedMessages msgs;
+ accum_.GetClassifiedMessages(&msgs);
+ ASSERT_EQ(1U, msgs.size());
+
+ ResourceResponseHead response_head;
+ GetResponseHead(msgs[0], &response_head);
+ ASSERT_EQ("text/plain", response_head.mime_type);
+}
« no previous file with comments | « chrome/browser/renderer_host/buffered_resource_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698