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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_response_headers_unittest.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "build/build_config.h" 5 #include "build/build_config.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 6000 matching lines...) Expand 10 before | Expand all | Expand 10 after
6011 TEST_F(URLRequestTestHTTP, Redirect307Tests) { 6011 TEST_F(URLRequestTestHTTP, Redirect307Tests) {
6012 ASSERT_TRUE(test_server_.Start()); 6012 ASSERT_TRUE(test_server_.Start());
6013 6013
6014 const GURL url = test_server_.GetURL("files/redirect307-to-echo"); 6014 const GURL url = test_server_.GetURL("files/redirect307-to-echo");
6015 6015
6016 HTTPRedirectMethodTest(url, "POST", "POST", true); 6016 HTTPRedirectMethodTest(url, "POST", "POST", true);
6017 HTTPRedirectMethodTest(url, "PUT", "PUT", true); 6017 HTTPRedirectMethodTest(url, "PUT", "PUT", true);
6018 HTTPRedirectMethodTest(url, "HEAD", "HEAD", false); 6018 HTTPRedirectMethodTest(url, "HEAD", "HEAD", false);
6019 } 6019 }
6020 6020
6021 TEST_F(URLRequestTestHTTP, Redirect308Tests) {
6022 ASSERT_TRUE(test_server_.Start());
6023
6024 const GURL url = test_server_.GetURL("files/redirect308-to-echo");
6025
6026 HTTPRedirectMethodTest(url, "POST", "POST", true);
6027 HTTPRedirectMethodTest(url, "PUT", "PUT", true);
6028 HTTPRedirectMethodTest(url, "HEAD", "HEAD", false);
6029 }
6030
6031 // Make sure that 308 responses without bodies are not treated as redirects.
6032 // Certain legacy apis that pre-date the response code expect this behavior
6033 // (Like Google Drive).
6034 TEST_F(URLRequestTestHTTP, NoRedirectOn308WithoutLocationHeader) {
6035 ASSERT_TRUE(test_server_.Start());
6036
6037 TestDelegate d;
6038 const GURL url = test_server_.GetURL("files/308-without-location-header");
6039
6040 URLRequest request(url, DEFAULT_PRIORITY, &d, &default_context_);
6041
6042 request.Start();
6043 base::RunLoop().Run();
6044 EXPECT_EQ(URLRequestStatus::SUCCESS, request.status().status());
6045 EXPECT_EQ(OK, request.status().error());
6046 EXPECT_EQ(0, d.received_redirect_count());
6047 EXPECT_EQ(308, request.response_headers()->response_code());
6048 EXPECT_EQ("This is not a redirect.", d.data_received());
6049 }
6050
6021 TEST_F(URLRequestTestHTTP, Redirect302PreserveReferenceFragment) { 6051 TEST_F(URLRequestTestHTTP, Redirect302PreserveReferenceFragment) {
6022 ASSERT_TRUE(test_server_.Start()); 6052 ASSERT_TRUE(test_server_.Start());
6023 6053
6024 GURL original_url(test_server_.GetURL("files/redirect302-to-echo#fragment")); 6054 GURL original_url(test_server_.GetURL("files/redirect302-to-echo#fragment"));
6025 GURL expected_url(test_server_.GetURL("echo#fragment")); 6055 GURL expected_url(test_server_.GetURL("echo#fragment"));
6026 6056
6027 TestDelegate d; 6057 TestDelegate d;
6028 { 6058 {
6029 URLRequest r(original_url, DEFAULT_PRIORITY, &d, &default_context_); 6059 URLRequest r(original_url, DEFAULT_PRIORITY, &d, &default_context_);
6030 6060
(...skipping 1933 matching lines...) Expand 10 before | Expand all | Expand 10 after
7964 7994
7965 EXPECT_FALSE(r.is_pending()); 7995 EXPECT_FALSE(r.is_pending());
7966 EXPECT_EQ(1, d->response_started_count()); 7996 EXPECT_EQ(1, d->response_started_count());
7967 EXPECT_FALSE(d->received_data_before_response()); 7997 EXPECT_FALSE(d->received_data_before_response());
7968 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 7998 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
7969 } 7999 }
7970 } 8000 }
7971 #endif // !defined(DISABLE_FTP_SUPPORT) 8001 #endif // !defined(DISABLE_FTP_SUPPORT)
7972 8002
7973 } // namespace net 8003 } // namespace net
OLDNEW
« 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