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

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

Issue 159034: Change URLRequest to return net::ERR_INVALID_URL on redirects to invalid urls. (Closed)
Patch Set: Address minor nits. Created 11 years, 5 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
« 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-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 TestDelegate d; 1016 TestDelegate d;
1017 TestURLRequest req(server->TestServerPage( 1017 TestURLRequest req(server->TestServerPage(
1018 "files/redirect-to-file.html"), &d); 1018 "files/redirect-to-file.html"), &d);
1019 req.Start(); 1019 req.Start();
1020 MessageLoop::current()->Run(); 1020 MessageLoop::current()->Run();
1021 1021
1022 EXPECT_EQ(URLRequestStatus::FAILED, req.status().status()); 1022 EXPECT_EQ(URLRequestStatus::FAILED, req.status().status());
1023 EXPECT_EQ(net::ERR_UNSAFE_REDIRECT, req.status().os_error()); 1023 EXPECT_EQ(net::ERR_UNSAFE_REDIRECT, req.status().os_error());
1024 } 1024 }
1025 1025
1026 TEST_F(URLRequestTest, RedirectToInvalidURL) {
1027 scoped_refptr<HTTPTestServer> server =
1028 HTTPTestServer::CreateServer(L"net/data/url_request_unittest", NULL);
1029 ASSERT_TRUE(NULL != server.get());
1030
1031 TestDelegate d;
1032 TestURLRequest req(server->TestServerPage(
1033 "files/redirect-to-invalid-url.html"), &d);
1034 req.Start();
1035 MessageLoop::current()->Run();
1036
1037 EXPECT_EQ(URLRequestStatus::FAILED, req.status().status());
1038 EXPECT_EQ(net::ERR_INVALID_URL, req.status().os_error());
1039 }
1040
1026 TEST_F(URLRequestTest, NoUserPassInReferrer) { 1041 TEST_F(URLRequestTest, NoUserPassInReferrer) {
1027 scoped_refptr<HTTPTestServer> server = 1042 scoped_refptr<HTTPTestServer> server =
1028 HTTPTestServer::CreateServer(L"net/data/url_request_unittest", NULL); 1043 HTTPTestServer::CreateServer(L"net/data/url_request_unittest", NULL);
1029 ASSERT_TRUE(NULL != server.get()); 1044 ASSERT_TRUE(NULL != server.get());
1030 TestDelegate d; 1045 TestDelegate d;
1031 TestURLRequest req(server->TestServerPage( 1046 TestURLRequest req(server->TestServerPage(
1032 "echoheader?Referer"), &d); 1047 "echoheader?Referer"), &d);
1033 req.set_referrer("http://user:pass@foo.com/"); 1048 req.set_referrer("http://user:pass@foo.com/");
1034 req.Start(); 1049 req.Start();
1035 MessageLoop::current()->Run(); 1050 MessageLoop::current()->Run();
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 1839
1825 int64 file_size = 0; 1840 int64 file_size = 0;
1826 file_util::GetFileSize(app_path, &file_size); 1841 file_util::GetFileSize(app_path, &file_size);
1827 1842
1828 EXPECT_TRUE(!r.is_pending()); 1843 EXPECT_TRUE(!r.is_pending());
1829 EXPECT_EQ(1, d.response_started_count()); 1844 EXPECT_EQ(1, d.response_started_count());
1830 EXPECT_FALSE(d.received_data_before_response()); 1845 EXPECT_FALSE(d.received_data_before_response());
1831 EXPECT_EQ(d.bytes_received(), 0); 1846 EXPECT_EQ(d.bytes_received(), 0);
1832 } 1847 }
1833 } 1848 }
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