Skip to content

Commit 72b20c0

Browse files
committed
Better API names
1 parent afd6d5f commit 72b20c0

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ httplib::Client cli("yahoo.com");
387387
auto res = cli.Get("/");
388388
res->status; // 301
389389

390-
cli.follow_location(true);
390+
cli.set_follow_location(true);
391391
res = cli.Get("/");
392392
res->status; // 200
393393
```
@@ -426,7 +426,7 @@ The server applies gzip compression to the following MIME type contents:
426426
### Compress content on client
427427

428428
```c++
429-
cli.compress(true);
429+
cli.set_compress(true);
430430
res = cli.Post("/resource/foo", "...", "text/plain");
431431
```
432432

httplib.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,9 @@ class Client {
741741

742742
void set_auth(const char *username, const char *password);
743743

744-
void follow_location(bool on);
744+
void set_follow_location(bool on);
745745

746-
void compress(bool on);
746+
void set_compress(bool on);
747747

748748
protected:
749749
bool process_request(Stream &strm, const Request &req, Response &res,
@@ -3464,14 +3464,14 @@ inline bool Client::redirect(const Request &req, Response &res) {
34643464
if (next_scheme == "https") {
34653465
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
34663466
SSLClient cli(next_host.c_str());
3467-
cli.follow_location(true);
3467+
cli.set_follow_location(true);
34683468
return detail::redirect(cli, req, res, next_path);
34693469
#else
34703470
return false;
34713471
#endif
34723472
} else {
34733473
Client cli(next_host.c_str());
3474-
cli.follow_location(true);
3474+
cli.set_follow_location(true);
34753475
return detail::redirect(cli, req, res, next_path);
34763476
}
34773477
}
@@ -3951,9 +3951,9 @@ inline void Client::set_auth(const char *username, const char *password) {
39513951
password_ = password;
39523952
}
39533953

3954-
inline void Client::follow_location(bool on) { follow_location_ = on; }
3954+
inline void Client::set_follow_location(bool on) { follow_location_ = on; }
39553955

3956-
inline void Client::compress(bool on) { compress_ = on; }
3956+
inline void Client::set_compress(bool on) { compress_ = on; }
39573957

39583958
/*
39593959
* SSL Implementation

test/test.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ TEST(AbsoluteRedirectTest, Redirect) {
524524
httplib::Client cli(host);
525525
#endif
526526

527-
cli.follow_location(true);
527+
cli.set_follow_location(true);
528528
auto res = cli.Get("/absolute-redirect/3");
529529
ASSERT_TRUE(res != nullptr);
530530
EXPECT_EQ(200, res->status);
@@ -539,7 +539,7 @@ TEST(RedirectTest, Redirect) {
539539
httplib::Client cli(host);
540540
#endif
541541

542-
cli.follow_location(true);
542+
cli.set_follow_location(true);
543543
auto res = cli.Get("/redirect/3");
544544
ASSERT_TRUE(res != nullptr);
545545
EXPECT_EQ(200, res->status);
@@ -554,7 +554,7 @@ TEST(RelativeRedirectTest, Redirect) {
554554
httplib::Client cli(host);
555555
#endif
556556

557-
cli.follow_location(true);
557+
cli.set_follow_location(true);
558558
auto res = cli.Get("/relative-redirect/3");
559559
ASSERT_TRUE(res != nullptr);
560560
EXPECT_EQ(200, res->status);
@@ -569,7 +569,7 @@ TEST(TooManyRedirectTest, Redirect) {
569569
httplib::Client cli(host);
570570
#endif
571571

572-
cli.follow_location(true);
572+
cli.set_follow_location(true);
573573
auto res = cli.Get("/redirect/21");
574574
ASSERT_TRUE(res == nullptr);
575575
}
@@ -582,15 +582,15 @@ TEST(YahooRedirectTest, Redirect) {
582582
ASSERT_TRUE(res != nullptr);
583583
EXPECT_EQ(301, res->status);
584584

585-
cli.follow_location(true);
585+
cli.set_follow_location(true);
586586
res = cli.Get("/");
587587
ASSERT_TRUE(res != nullptr);
588588
EXPECT_EQ(200, res->status);
589589
}
590590

591591
TEST(HttpsToHttpRedirectTest, Redirect) {
592592
httplib::SSLClient cli("httpbin.org");
593-
cli.follow_location(true);
593+
cli.set_follow_location(true);
594594
auto res =
595595
cli.Get("/redirect-to?url=http%3A%2F%2Fwww.google.com&status_code=302");
596596
ASSERT_TRUE(res != nullptr);
@@ -1535,7 +1535,7 @@ TEST_F(ServerTest, PutWithContentProvider) {
15351535

15361536
#ifdef CPPHTTPLIB_ZLIB_SUPPORT
15371537
TEST_F(ServerTest, PutWithContentProviderWithGzip) {
1538-
cli_.compress(true);
1538+
cli_.set_compress(true);
15391539
auto res = cli_.Put(
15401540
"/put", 3,
15411541
[](size_t /*offset*/, size_t /*length*/, DataSink sink) {
@@ -1549,7 +1549,7 @@ TEST_F(ServerTest, PutWithContentProviderWithGzip) {
15491549
}
15501550

15511551
TEST_F(ServerTest, PutLargeFileWithGzip) {
1552-
cli_.compress(true);
1552+
cli_.set_compress(true);
15531553
auto res = cli_.Put("/put-large", LARGE_DATA, "text/plain");
15541554

15551555
ASSERT_TRUE(res != nullptr);
@@ -1623,7 +1623,7 @@ TEST_F(ServerTest, PostMulitpartFilsContentReceiver) {
16231623
}
16241624

16251625
TEST_F(ServerTest, PostContentReceiverGzip) {
1626-
cli_.compress(true);
1626+
cli_.set_compress(true);
16271627
auto res = cli_.Post("/content_receiver", "content", "text/plain");
16281628
ASSERT_TRUE(res != nullptr);
16291629
ASSERT_EQ(200, res->status);
@@ -1805,7 +1805,7 @@ TEST_F(ServerTest, MultipartFormDataGzip) {
18051805
{"key2", "--abcdefg123", "", ""},
18061806
};
18071807

1808-
cli_.compress(true);
1808+
cli_.set_compress(true);
18091809
auto res = cli_.Post("/gzipmultipart", items);
18101810

18111811
ASSERT_TRUE(res != nullptr);

0 commit comments

Comments
 (0)