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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/renderer_host/buffered_resource_handler.cc ('k') | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <vector> 5 #include <vector>
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "chrome/browser/child_process_security_policy.h" 10 #include "chrome/browser/child_process_security_policy.h"
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 839
840 // Sorts out all the messages we saw by request. 840 // Sorts out all the messages we saw by request.
841 ResourceIPCAccumulator::ClassifiedMessages msgs; 841 ResourceIPCAccumulator::ClassifiedMessages msgs;
842 accum_.GetClassifiedMessages(&msgs); 842 accum_.GetClassifiedMessages(&msgs);
843 ASSERT_EQ(1U, msgs.size()); 843 ASSERT_EQ(1U, msgs.size());
844 844
845 ResourceResponseHead response_head; 845 ResourceResponseHead response_head;
846 GetResponseHead(msgs[0], &response_head); 846 GetResponseHead(msgs[0], &response_head);
847 ASSERT_EQ("", response_head.mime_type); 847 ASSERT_EQ("", response_head.mime_type);
848 } 848 }
849
850 TEST_F(ResourceDispatcherHostTest, MimeSniff204) {
851 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
852
853 std::string response("HTTP/1.1 204 No Content\n\n");
854 std::string raw_headers(net::HttpUtil::AssembleRawHeaders(response.data(),
855 response.size()));
856 std::string response_data;
857 SetResponse(raw_headers, response_data);
858
859 HandleScheme("http");
860 MakeTestRequest(0, 1, GURL("http:bla"));
861
862 // Flush all pending requests.
863 while (URLRequestTestJob::ProcessOnePendingMessage());
864
865 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
866
867 // Sorts out all the messages we saw by request.
868 ResourceIPCAccumulator::ClassifiedMessages msgs;
869 accum_.GetClassifiedMessages(&msgs);
870 ASSERT_EQ(1U, msgs.size());
871
872 ResourceResponseHead response_head;
873 GetResponseHead(msgs[0], &response_head);
874 ASSERT_EQ("text/plain", response_head.mime_type);
875 }
OLDNEW
« 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