@@ -74,7 +74,7 @@ svr.set_logger([](const auto& req, const auto& res) {
74
74
75
75
``` cpp
76
76
svr.set_error_handler([](const auto & req, auto & res) {
77
- const char* fmt = "<p>Error Status: <span style='color:red;'>%d</span></p>";
77
+ auto fmt = "<p>Error Status: <span style='color:red;'>%d</span></p>";
78
78
char buf[BUFSIZ];
79
79
snprintf (buf, sizeof(buf), fmt, res.status);
80
80
res.set_content(buf, "text/html");
@@ -325,23 +325,30 @@ This feature was contributed by [underscorediscovery](https://github.com/yhirose
325
325
326
326
### Authentication
327
327
328
- NOTE: OpenSSL is required for Digest Authentication, since cpp-httplib uses message digest functions in OpenSSL.
328
+ ``` cpp
329
+ // Basic Authentication
330
+ cli.set_basic_auth(" user" , " pass" );
331
+
332
+ // Digest Authentication
333
+ cli.set_digest_auth(" user" , " pass" );
334
+ ```
335
+
336
+ NOTE: OpenSSL is required for Digest Authentication.
337
+
338
+ ### Proxy server support
329
339
330
340
``` cpp
331
- httplib::Client cli ("httplib.org");
332
- cli.set_auth("user", "pass");
341
+ cli.set_proxy(" host" , port);
333
342
334
- // Basic
335
- auto res = cli.Get("/basic-auth/user/pass");
336
- // res->status should be 200
337
- // res->body should be "{\n \" authenticated\" : true, \n \" user\" : \" user\" \n}\n".
343
+ // Basic Authentication
344
+ cli.set_proxy_basic_auth(" user" , " pass" );
338
345
339
- // Digest
340
- res = cli.Get("/digest-auth/auth/user/pass/SHA-256");
341
- // res->status should be 200
342
- // res->body should be "{\n \" authenticated\" : true, \n \" user\" : \" user\" \n}\n".
346
+ // Digest Authentication
347
+ cli.set_proxy_digest_auth(" user" , " pass" );
343
348
```
344
349
350
+ NOTE: OpenSSL is required for Digest Authentication.
351
+
345
352
### Range
346
353
347
354
``` cpp
0 commit comments