diff --git a/README.md b/README.md index 149cf98..f2d6ebf 100644 --- a/README.md +++ b/README.md @@ -337,8 +337,12 @@ if (cli.send(requests, responses)) { ```cpp httplib::Client cli("yahoo.com"); -cli.follow_location(true); + auto res = cli.Get("/"); +res->status; // 301 + +cli.follow_location(true); +res = cli.Get("/"); res->status; // 200 ``` diff --git a/test/test.cc b/test/test.cc index d103ca2..57049c3 100644 --- a/test/test.cc +++ b/test/test.cc @@ -493,9 +493,14 @@ TEST(TooManyRedirectTest, Redirect) { #ifdef CPPHTTPLIB_OPENSSL_SUPPORT TEST(YahooRedirectTest, Redirect) { httplib::Client cli("yahoo.com"); - cli.follow_location(true); + auto res = cli.Get("/"); ASSERT_TRUE(res != nullptr); + EXPECT_EQ(301, res->status); + + cli.follow_location(true); + res = cli.Get("/"); + ASSERT_TRUE(res != nullptr); EXPECT_EQ(200, res->status); }