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

Unified Diff: net/url_request/url_request_unittest.cc

Issue 422233006: Add fake headers to URLRequestRedirectJobs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 6 years, 4 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/url_request/url_request_redirect_job.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
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 791904eed9b53753dc5e0fe7df8f369a12e10f5b..a66924ef862ff69e35c9fb1ec385d9ef7cd778a9 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -2949,9 +2949,23 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequest) {
GURL original_url(test_server_.GetURL("empty.html"));
URLRequest r(original_url, DEFAULT_PRIORITY, &d, &context);
+ // Quit after hitting the redirect, so can check the headers.
+ d.set_quit_on_redirect(true);
r.Start();
base::RunLoop().Run();
+ // Check headers from URLRequestJob.
+ EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
+ EXPECT_EQ(307, r.GetResponseCode());
+ EXPECT_EQ(307, r.response_headers()->response_code());
+ std::string location;
+ ASSERT_TRUE(r.response_headers()->EnumerateHeader(NULL, "Location",
+ &location));
+ EXPECT_EQ(redirect_url, GURL(location));
+
+ // Let the request finish.
+ r.FollowDeferredRedirect();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_TRUE(r.proxy_server().Equals(test_server_.host_port_pair()));
EXPECT_EQ(
@@ -2988,9 +3002,24 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequestSynchronously) {
GURL original_url(test_server_.GetURL("empty.html"));
URLRequest r(original_url, DEFAULT_PRIORITY, &d, &context);
+ // Quit after hitting the redirect, so can check the headers.
+ d.set_quit_on_redirect(true);
r.Start();
base::RunLoop().Run();
+ // Check headers from URLRequestJob.
+ EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
+ EXPECT_EQ(307, r.GetResponseCode());
+ EXPECT_EQ(307, r.response_headers()->response_code());
+ std::string location;
+ ASSERT_TRUE(r.response_headers()->EnumerateHeader(NULL, "Location",
+ &location));
+ EXPECT_EQ(redirect_url, GURL(location));
+
+ // Let the request finish.
+ r.FollowDeferredRedirect();
+ base::RunLoop().Run();
+
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_TRUE(r.proxy_server().Equals(test_server_.host_port_pair()));
EXPECT_EQ(
@@ -3034,9 +3063,25 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequestPost) {
headers.SetHeader(HttpRequestHeaders::kContentLength,
base::UintToString(arraysize(kData) - 1));
r.SetExtraRequestHeaders(headers);
+
+ // Quit after hitting the redirect, so can check the headers.
+ d.set_quit_on_redirect(true);
r.Start();
base::RunLoop().Run();
+ // Check headers from URLRequestJob.
+ EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
+ EXPECT_EQ(307, r.GetResponseCode());
+ EXPECT_EQ(307, r.response_headers()->response_code());
+ std::string location;
+ ASSERT_TRUE(r.response_headers()->EnumerateHeader(NULL, "Location",
+ &location));
+ EXPECT_EQ(redirect_url, GURL(location));
+
+ // Let the request finish.
+ r.FollowDeferredRedirect();
+ base::RunLoop().Run();
+
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_EQ(0, r.status().error());
EXPECT_EQ(redirect_url, r.url());
« no previous file with comments | « net/url_request/url_request_redirect_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698