1
0
mirror of synced 2025-04-28 09:25:05 +03:00

Code cleanup

This commit is contained in:
yhirose 2019-09-06 18:16:42 -04:00
parent c9238434e1
commit bfec81998b
2 changed files with 18 additions and 13 deletions

View File

@ -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

View File

@ -441,8 +441,9 @@ TEST(AbsoluteRedirectTest, Redirect) {
#endif #endif
cli.follow_location(true); cli.follow_location(true);
auto ret = cli.Get("/absolute-redirect/3"); auto res = cli.Get("/absolute-redirect/3");
ASSERT_TRUE(ret != nullptr); 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"); auto res = cli.Get("/redirect/3");
ASSERT_TRUE(ret != nullptr); 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"); auto res = cli.Get("/relative-redirect/3");
ASSERT_TRUE(ret != nullptr); 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"); auto res = cli.Get("/redirect/21");
ASSERT_TRUE(ret == nullptr); 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("/"); auto res = cli.Get("/");
ASSERT_TRUE(ret != nullptr); 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"); auto res = cli.Get("/redirect-to?url=http%3A%2F%2Fwww.google.com&status_code=302");
ASSERT_TRUE(ret != nullptr); ASSERT_TRUE(res != nullptr);
} }
#endif #endif