Skip to content

Commit 55f57af

Browse files
committed
Update README
1 parent 6b35cd0 commit 55f57af

File tree

1 file changed

+31
-25
lines changed

1 file changed

+31
-25
lines changed

README.md

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,41 +27,21 @@ svr.listen("0.0.0.0", 8080);
2727
#### Client
2828

2929
```c++
30-
httplib::Client cli("http://cpp-httplib-server.yhirose.repl.co");
30+
#define CPPHTTPLIB_OPENSSL_SUPPORT
31+
32+
httplib::Client cli("https://cpp-httplib-server.yhirose.repl.co");
3133

3234
auto res = cli.Get("/hi");
3335

34-
res->status; // 200
35-
res->body; // "Hello World!"
36+
res->status;
37+
res->body;
3638
```
3739
3840
### Try out the examples on Repl.it!
3941
4042
1. Run server at https://repl.it/@yhirose/cpp-httplib-server
4143
2. Run client at https://repl.it/@yhirose/cpp-httplib-client
4244
43-
OpenSSL Support
44-
---------------
45-
46-
SSL support is available with `CPPHTTPLIB_OPENSSL_SUPPORT`. `libssl` and `libcrypto` should be linked.
47-
48-
NOTE: cpp-httplib currently supports only version 1.1.1.
49-
50-
```c++
51-
#define CPPHTTPLIB_OPENSSL_SUPPORT
52-
53-
httplib::SSLServer svr("./cert.pem", "./key.pem");
54-
55-
httplib::SSLClient cli("localhost", 1234); // or `httplib::Client cli("https://localhost:1234");`
56-
cli.set_ca_cert_path("./ca-bundle.crt");
57-
cli.enable_server_certificate_verification(true);
58-
```
59-
60-
Note: When using SSL, it seems impossible to avoid SIGPIPE in all cases, since on some operating systems, SIGPIPE
61-
can only be suppressed on a per-message basis, but there is no way to make the OpenSSL library do so for its
62-
internal communications. If your program needs to avoid being terminated on SIGPIPE, the only fully general way might
63-
be to set up a signal handler for SIGPIPE to handle or ignore it yourself.
64-
6545
Server
6646
------
6747
@@ -392,6 +372,7 @@ httplib::Client cli("localhost:8080");
392372
httplib::Client cli("http://localhost");
393373
httplib::Client cli("http://localhost:8080");
394374
httplib::Client cli("https://localhost");
375+
httplib::SSLClient cli("localhost");
395376
```
396377

397378
### Error code
@@ -693,6 +674,31 @@ res = cli.Get("/resource/foo", {{"Accept-Encoding", "gzip, deflate, br"}});
693674
res->body; // Compressed data
694675
```
695676
677+
SSL Support
678+
-----------
679+
680+
SSL support is available with `CPPHTTPLIB_OPENSSL_SUPPORT`. `libssl` and `libcrypto` should be linked.
681+
682+
NOTE: cpp-httplib currently supports only version 1.1.1.
683+
684+
```c++
685+
#define CPPHTTPLIB_OPENSSL_SUPPORT
686+
687+
// Server
688+
httplib::SSLServer svr("./cert.pem", "./key.pem");
689+
690+
// Client
691+
httplib::Client cli("https://localhost:1234");
692+
693+
// Use your CA bundle
694+
cli.set_ca_cert_path("./ca-bundle.crt");
695+
696+
// Disable cert verification
697+
cli.enable_server_certificate_verification(false);
698+
```
699+
700+
Note: When using SSL, it seems impossible to avoid SIGPIPE in all cases, since on some operating systems, SIGPIPE can only be suppressed on a per-message basis, but there is no way to make the OpenSSL library do so for its internal communications. If your program needs to avoid being terminated on SIGPIPE, the only fully general way might be to set up a signal handler for SIGPIPE to handle or ignore it yourself.
701+
696702
Split httplib.h into .h and .cc
697703
-------------------------------
698704

0 commit comments

Comments
 (0)