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

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 10873: Don't send Content-Type when redirecting from a POST.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request.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 "net/url_request/url_request_unittest.h" 5 #include "net/url_request/url_request_unittest.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 #endif 10 #endif
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 TestURLRequest(const GURL& url, Delegate* delegate) 51 TestURLRequest(const GURL& url, Delegate* delegate)
52 : URLRequest(url, delegate) { 52 : URLRequest(url, delegate) {
53 set_context(new URLRequestHttpCacheContext()); 53 set_context(new URLRequestHttpCacheContext());
54 } 54 }
55 }; 55 };
56 56
57 std::string TestNetResourceProvider(int key) { 57 std::string TestNetResourceProvider(int key) {
58 return "header"; 58 return "header";
59 } 59 }
60 60
61 // Do a case-insensitive search through |haystack| for |needle|.
62 bool ContainsString(const std::string& haystack, const char* needle) {
63 std::string::const_iterator it =
64 std::search(haystack.begin(),
65 haystack.end(),
66 needle,
67 needle + strlen(needle),
68 CaseInsensitiveCompare<char>());
69 return it != haystack.end();
70 }
71
61 } // namespace 72 } // namespace
62 73
63 TEST(URLRequestTest, GetTest_NoCache) { 74 TEST(URLRequestTest, GetTest_NoCache) {
64 TestServer server(L""); 75 TestServer server(L"");
65 TestDelegate d; 76 TestDelegate d;
66 { 77 {
67 TestURLRequest r(server.TestServerPage(""), &d); 78 TestURLRequest r(server.TestServerPage(""), &d);
68 79
69 r.Start(); 80 r.Start();
70 EXPECT_TRUE(r.is_pending()); 81 EXPECT_TRUE(r.is_pending());
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 MessageLoop::current()->Run(); 771 MessageLoop::current()->Run();
761 772
762 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); 773 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos);
763 774
764 // Should be the same cached document, which means that the response time 775 // Should be the same cached document, which means that the response time
765 // should not have changed. 776 // should not have changed.
766 EXPECT_TRUE(response_time == r.response_time()); 777 EXPECT_TRUE(response_time == r.response_time());
767 } 778 }
768 } 779 }
769 780
781 // In this test, we do a POST which the server will 302 redirect.
782 // The subsequent transaction should use GET, and should not send the
783 // Content-Type header.
784 // http://code.google.com/p/chromium/issues/detail?id=843
785 TEST(URLRequestTest, Post302RedirectGet) {
786 TestServer server(L"net/data/url_request_unittest");
787 TestDelegate d;
788 TestURLRequest req(server.TestServerPage("files/redirect-to-echoall"), &d);
789 req.set_method("POST");
790
791 // Set headers (some of which are specific to the POST).
792 // ("Content-Length: 10" is just a junk value to make sure it gets stripped).
793 req.SetExtraRequestHeaders(
794 "Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryAADeAA+NA AWMAAwZ\r\n"
795 "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text /plain;q=0.8,image/png,*/*;q=0.5\r\n"
796 "Accept-Language: en-US,en\r\n"
797 "Accept-Charset: ISO-8859-1,*,utf-8\r\n"
798 "Content-Length: 10\r\n"
799 "Origin: http://localhost:1337/"
800 );
801 req.Start();
802 MessageLoop::current()->Run();
803
804 std::string mime_type;
805 req.GetMimeType(&mime_type);
806 EXPECT_EQ("text/html", mime_type);
807
808 const std::string& data = d.data_received();
809
810 // Check that the post-specific headers were stripped:
811 EXPECT_FALSE(ContainsString(data, "Content-Length:"));
812 EXPECT_FALSE(ContainsString(data, "Content-Type:"));
813 EXPECT_FALSE(ContainsString(data, "Origin:"));
814
815 // These extra request headers should not have been stripped.
816 EXPECT_TRUE(ContainsString(data, "Accept:"));
817 EXPECT_TRUE(ContainsString(data, "Accept-Language:"));
818 EXPECT_TRUE(ContainsString(data, "Accept-Charset:"));
819 }
820
OLDNEW
« no previous file with comments | « net/url_request/url_request.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698