Skip to content

Commit bfec819

Browse files
committed
Code cleanup
1 parent c923843 commit bfec819

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ if (cli.send(requests, responses)) {
338338
```cpp
339339
httplib::Client cli("yahoo.com");
340340
cli.follow_location(true);
341-
auto ret = cli.Get("/");
341+
auto res = cli.Get("/");
342+
res->status; // 200
342343
```
343344
344345
OpenSSL Support

test/test.cc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,9 @@ TEST(AbsoluteRedirectTest, Redirect) {
441441
#endif
442442

443443
cli.follow_location(true);
444-
auto ret = cli.Get("/absolute-redirect/3");
445-
ASSERT_TRUE(ret != nullptr);
444+
auto res = cli.Get("/absolute-redirect/3");
445+
ASSERT_TRUE(res != nullptr);
446+
EXPECT_EQ(200, res->status);
446447
}
447448

448449
TEST(RedirectTest, Redirect) {
@@ -455,8 +456,9 @@ TEST(RedirectTest, Redirect) {
455456
#endif
456457

457458
cli.follow_location(true);
458-
auto ret = cli.Get("/redirect/3");
459-
ASSERT_TRUE(ret != nullptr);
459+
auto res = cli.Get("/redirect/3");
460+
ASSERT_TRUE(res != nullptr);
461+
EXPECT_EQ(200, res->status);
460462
}
461463

462464
TEST(RelativeRedirectTest, Redirect) {
@@ -469,8 +471,9 @@ TEST(RelativeRedirectTest, Redirect) {
469471
#endif
470472

471473
cli.follow_location(true);
472-
auto ret = cli.Get("/relative-redirect/3");
473-
ASSERT_TRUE(ret != nullptr);
474+
auto res = cli.Get("/relative-redirect/3");
475+
ASSERT_TRUE(res != nullptr);
476+
EXPECT_EQ(200, res->status);
474477
}
475478

476479
TEST(TooManyRedirectTest, Redirect) {
@@ -483,23 +486,24 @@ TEST(TooManyRedirectTest, Redirect) {
483486
#endif
484487

485488
cli.follow_location(true);
486-
auto ret = cli.Get("/redirect/21");
487-
ASSERT_TRUE(ret == nullptr);
489+
auto res = cli.Get("/redirect/21");
490+
ASSERT_TRUE(res == nullptr);
488491
}
489492

490493
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
491494
TEST(YahooRedirectTest, Redirect) {
492495
httplib::Client cli("yahoo.com");
493496
cli.follow_location(true);
494-
auto ret = cli.Get("/");
495-
ASSERT_TRUE(ret != nullptr);
497+
auto res = cli.Get("/");
498+
ASSERT_TRUE(res != nullptr);
499+
EXPECT_EQ(200, res->status);
496500
}
497501

498502
TEST(Https2HttpRedirectTest, Redirect) {
499503
httplib::SSLClient cli("httpbin.org");
500504
cli.follow_location(true);
501-
auto ret = cli.Get("/redirect-to?url=http%3A%2F%2Fwww.google.com&status_code=302");
502-
ASSERT_TRUE(ret != nullptr);
505+
auto res = cli.Get("/redirect-to?url=http%3A%2F%2Fwww.google.com&status_code=302");
506+
ASSERT_TRUE(res != nullptr);
503507
}
504508
#endif
505509

0 commit comments

Comments
 (0)