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

Unified Diff: net/url_request/url_request_unittest.cc

Issue 9816011: Add support for 308 permanent redirects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Add response code check Created 6 years, 8 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 | « net/http/http_response_headers_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_unittest.cc
===================================================================
--- net/url_request/url_request_unittest.cc (revision 264191)
+++ net/url_request/url_request_unittest.cc (working copy)
@@ -6018,6 +6018,36 @@
HTTPRedirectMethodTest(url, "HEAD", "HEAD", false);
}
+TEST_F(URLRequestTestHTTP, Redirect308Tests) {
+ ASSERT_TRUE(test_server_.Start());
+
+ const GURL url = test_server_.GetURL("files/redirect308-to-echo");
+
+ HTTPRedirectMethodTest(url, "POST", "POST", true);
+ HTTPRedirectMethodTest(url, "PUT", "PUT", true);
+ HTTPRedirectMethodTest(url, "HEAD", "HEAD", false);
+}
+
+// Make sure that 308 responses without bodies are not treated as redirects.
+// Certain legacy apis that pre-date the response code expect this behavior
+// (Like Google Drive).
+TEST_F(URLRequestTestHTTP, NoRedirectOn308WithoutLocationHeader) {
+ ASSERT_TRUE(test_server_.Start());
+
+ TestDelegate d;
+ const GURL url = test_server_.GetURL("files/308-without-location-header");
+
+ URLRequest request(url, DEFAULT_PRIORITY, &d, &default_context_);
+
+ request.Start();
+ base::RunLoop().Run();
+ EXPECT_EQ(URLRequestStatus::SUCCESS, request.status().status());
+ EXPECT_EQ(OK, request.status().error());
+ EXPECT_EQ(0, d.received_redirect_count());
+ EXPECT_EQ(308, request.response_headers()->response_code());
+ EXPECT_EQ("This is not a redirect.", d.data_received());
+}
+
TEST_F(URLRequestTestHTTP, Redirect302PreserveReferenceFragment) {
ASSERT_TRUE(test_server_.Start());
« no previous file with comments | « net/http/http_response_headers_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698