|
@@ -557,18 +557,18 @@ enum Error {
|
|
|
|
|
|
|
|
```c++
|
|
```c++
|
|
|
httplib::Headers headers = {
|
|
httplib::Headers headers = {
|
|
|
- { "Accept-Encoding", "gzip, deflate" }
|
|
|
|
|
|
|
+ { "Hello", "World!" }
|
|
|
};
|
|
};
|
|
|
auto res = cli.Get("/hi", headers);
|
|
auto res = cli.Get("/hi", headers);
|
|
|
```
|
|
```
|
|
|
or
|
|
or
|
|
|
```c++
|
|
```c++
|
|
|
-auto res = cli.Get("/hi", {{"Accept-Encoding", "gzip, deflate"}});
|
|
|
|
|
|
|
+auto res = cli.Get("/hi", {{"Hello", "World!"}});
|
|
|
```
|
|
```
|
|
|
or
|
|
or
|
|
|
```c++
|
|
```c++
|
|
|
cli.set_default_headers({
|
|
cli.set_default_headers({
|
|
|
- { "Accept-Encoding", "gzip, deflate" }
|
|
|
|
|
|
|
+ { "Hello", "World!" }
|
|
|
});
|
|
});
|
|
|
auto res = cli.Get("/hi");
|
|
auto res = cli.Get("/hi");
|
|
|
```
|
|
```
|
|
@@ -823,6 +823,21 @@ The server can apply compression to the following MIME type contents:
|
|
|
Brotli compression is available with `CPPHTTPLIB_BROTLI_SUPPORT`. Necessary libraries should be linked.
|
|
Brotli compression is available with `CPPHTTPLIB_BROTLI_SUPPORT`. Necessary libraries should be linked.
|
|
|
Please see https://github.com/google/brotli for more detail.
|
|
Please see https://github.com/google/brotli for more detail.
|
|
|
|
|
|
|
|
|
|
+### Default `Accept-Encoding` value
|
|
|
|
|
+
|
|
|
|
|
+The default `Acdcept-Encoding` value contains all possible compression types. So, the following two examples are same.
|
|
|
|
|
+
|
|
|
|
|
+```c++
|
|
|
|
|
+res = cli.Get("/resource/foo");
|
|
|
|
|
+res = cli.Get("/resource/foo", {{"Accept-Encoding", "gzip, deflate, br"}});
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+If we don't want a response without compression, we have to set `Accept-Encoding` to an empty string. This behavior is similar to curl.
|
|
|
|
|
+
|
|
|
|
|
+```c++
|
|
|
|
|
+res = cli.Get("/resource/foo", {{"Accept-Encoding", ""}});
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
### Compress request body on client
|
|
### Compress request body on client
|
|
|
|
|
|
|
|
```c++
|
|
```c++
|
|
@@ -834,8 +849,9 @@ res = cli.Post("/resource/foo", "...", "text/plain");
|
|
|
|
|
|
|
|
```c++
|
|
```c++
|
|
|
cli.set_decompress(false);
|
|
cli.set_decompress(false);
|
|
|
-res = cli.Get("/resource/foo", {{"Accept-Encoding", "gzip, deflate, br"}});
|
|
|
|
|
|
|
+res = cli.Get("/resource/foo");
|
|
|
res->body; // Compressed data
|
|
res->body; // Compressed data
|
|
|
|
|
+
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
Use `poll` instead of `select`
|
|
Use `poll` instead of `select`
|