Don't overwrite the last redirected location (#1589)

* Don't overwrite the last redirected location

* Check the last redirected location
This commit is contained in:
Jiwoo Park authored and GitHub committed 2023-06-16 14:56:16 -04:00
1 parent 067890133c
commit 4a61f68fa4
2 files changed
+4 -3

No files matched your search

+2 -1
View File
@@ -3920,7 +3920,8 @@ inline bool redirect(T &cli, Request &req, Response &res,
if (ret) { if (ret) {
req = new_req; req = new_req;
res = new_res; res = new_res;
res.location = location;
if (res.location.empty()) res.location = location;
} }
return ret; return ret;
} }
+2 -2
View File
@@ -972,7 +972,7 @@ TEST(YahooRedirectTest, Redirect_Online) {
res = cli.Get("/"); res = cli.Get("/");
ASSERT_TRUE(res); ASSERT_TRUE(res);
EXPECT_EQ(200, res->status); EXPECT_EQ(200, res->status);
EXPECT_EQ("https://yahoo.com/", res->location); EXPECT_EQ("https://www.yahoo.com/", res->location);
} }
TEST(HttpsToHttpRedirectTest, Redirect_Online) { TEST(HttpsToHttpRedirectTest, Redirect_Online) {
@@ -5301,7 +5301,7 @@ TEST(YahooRedirectTest2, SimpleInterface_Online) {
res = cli.Get("/"); res = cli.Get("/");
ASSERT_TRUE(res); ASSERT_TRUE(res);
EXPECT_EQ(200, res->status); EXPECT_EQ(200, res->status);
EXPECT_EQ("https://yahoo.com/", res->location); EXPECT_EQ("https://www.yahoo.com/", res->location);
} }
TEST(YahooRedirectTest3, SimpleInterface_Online) { TEST(YahooRedirectTest3, SimpleInterface_Online) {