Add fake headers to URLRequestRedirectJobs.
Plugin logic expects redirects to have headers, and gets very confused
when they're missing.
BUG=345160
Review URL: https://codereview.chromium.org/422233006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287901 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 791904e..a66924e 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -2949,9 +2949,23 @@
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 @@
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 @@
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());