@@ -27,41 +27,21 @@ svr.listen("0.0.0.0", 8080);
27
27
#### Client
28
28
29
29
``` 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 ");
31
33
32
34
auto res = cli.Get("/hi");
33
35
34
- res->status; // 200
35
- res->body; // "Hello World!"
36
+ res->status;
37
+ res->body;
36
38
```
37
39
38
40
### Try out the examples on Repl.it!
39
41
40
42
1. Run server at https://repl.it/@yhirose/cpp-httplib-server
41
43
2. Run client at https://repl.it/@yhirose/cpp-httplib-client
42
44
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
-
65
45
Server
66
46
------
67
47
@@ -392,6 +372,7 @@ httplib::Client cli("localhost:8080");
392
372
httplib::Client cli("http://localhost");
393
373
httplib::Client cli("http://localhost:8080");
394
374
httplib::Client cli("https://localhost");
375
+ httplib::SSLClient cli("localhost");
395
376
```
396
377
397
378
### Error code
@@ -693,6 +674,31 @@ res = cli.Get("/resource/foo", {{"Accept-Encoding", "gzip, deflate, br"}});
693
674
res->body; // Compressed data
694
675
```
695
676
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
+
696
702
Split httplib.h into .h and .cc
697
703
-------------------------------
698
704
0 commit comments