Browse Source

Code cleanup

yhirose 6 years ago
parent
commit
bfec81998b
2 changed files with 18 additions and 13 deletions
  1. 2 1
      README.md
  2. 16 12
      test/test.cc

+ 2 - 1
README.md

@@ -338,7 +338,8 @@ if (cli.send(requests, responses)) {
 ```cpp
 ```cpp
 httplib::Client cli("yahoo.com");
 httplib::Client cli("yahoo.com");
 cli.follow_location(true);
 cli.follow_location(true);
-auto ret = cli.Get("/");
+auto res = cli.Get("/");
+res->status; // 200
 ```
 ```
 
 
 OpenSSL Support
 OpenSSL Support

+ 16 - 12
test/test.cc

@@ -441,8 +441,9 @@ TEST(AbsoluteRedirectTest, Redirect) {
 #endif
 #endif
 
 
   cli.follow_location(true);
   cli.follow_location(true);
-  auto ret = cli.Get("/absolute-redirect/3");
-  ASSERT_TRUE(ret != nullptr);
+  auto res = cli.Get("/absolute-redirect/3");
+  ASSERT_TRUE(res != nullptr);
+  EXPECT_EQ(200, res->status);
 }
 }
 
 
 TEST(RedirectTest, Redirect) {
 TEST(RedirectTest, Redirect) {
@@ -455,8 +456,9 @@ TEST(RedirectTest, Redirect) {
 #endif
 #endif
 
 
   cli.follow_location(true);
   cli.follow_location(true);
-  auto ret = cli.Get("/redirect/3");
-  ASSERT_TRUE(ret != nullptr);
+  auto res = cli.Get("/redirect/3");
+  ASSERT_TRUE(res != nullptr);
+  EXPECT_EQ(200, res->status);
 }
 }
 
 
 TEST(RelativeRedirectTest, Redirect) {
 TEST(RelativeRedirectTest, Redirect) {
@@ -469,8 +471,9 @@ TEST(RelativeRedirectTest, Redirect) {
 #endif
 #endif
 
 
   cli.follow_location(true);
   cli.follow_location(true);
-  auto ret = cli.Get("/relative-redirect/3");
-  ASSERT_TRUE(ret != nullptr);
+  auto res = cli.Get("/relative-redirect/3");
+  ASSERT_TRUE(res != nullptr);
+  EXPECT_EQ(200, res->status);
 }
 }
 
 
 TEST(TooManyRedirectTest, Redirect) {
 TEST(TooManyRedirectTest, Redirect) {
@@ -483,23 +486,24 @@ TEST(TooManyRedirectTest, Redirect) {
 #endif
 #endif
 
 
   cli.follow_location(true);
   cli.follow_location(true);
-  auto ret = cli.Get("/redirect/21");
-  ASSERT_TRUE(ret == nullptr);
+  auto res = cli.Get("/redirect/21");
+  ASSERT_TRUE(res == nullptr);
 }
 }
 
 
 #ifdef CPPHTTPLIB_OPENSSL_SUPPORT
 #ifdef CPPHTTPLIB_OPENSSL_SUPPORT
 TEST(YahooRedirectTest, Redirect) {
 TEST(YahooRedirectTest, Redirect) {
   httplib::Client cli("yahoo.com");
   httplib::Client cli("yahoo.com");
   cli.follow_location(true);
   cli.follow_location(true);
-  auto ret = cli.Get("/");
-  ASSERT_TRUE(ret != nullptr);
+  auto res = cli.Get("/");
+  ASSERT_TRUE(res != nullptr);
+  EXPECT_EQ(200, res->status);
 }
 }
 
 
 TEST(Https2HttpRedirectTest, Redirect) {
 TEST(Https2HttpRedirectTest, Redirect) {
   httplib::SSLClient cli("httpbin.org");
   httplib::SSLClient cli("httpbin.org");
   cli.follow_location(true);
   cli.follow_location(true);
-  auto ret = cli.Get("/redirect-to?url=http%3A%2F%2Fwww.google.com&status_code=302");
-  ASSERT_TRUE(ret != nullptr);
+  auto res = cli.Get("/redirect-to?url=http%3A%2F%2Fwww.google.com&status_code=302");
+  ASSERT_TRUE(res != nullptr);
 }
 }
 #endif
 #endif