Browse Source

Update README

yhirose 1 year ago
parent
commit
8e378779c2
1 changed files with 20 additions and 4 deletions
  1. 20 4
      README.md

+ 20 - 4
README.md

@@ -557,18 +557,18 @@ enum Error {
 
 ```c++
 httplib::Headers headers = {
-  { "Accept-Encoding", "gzip, deflate" }
+  { "Hello", "World!" }
 };
 auto res = cli.Get("/hi", headers);
 ```
 or
 ```c++
-auto res = cli.Get("/hi", {{"Accept-Encoding", "gzip, deflate"}});
+auto res = cli.Get("/hi", {{"Hello", "World!"}});
 ```
 or
 ```c++
 cli.set_default_headers({
-  { "Accept-Encoding", "gzip, deflate" }
+  { "Hello", "World!" }
 });
 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.
 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
 
 ```c++
@@ -834,8 +849,9 @@ res = cli.Post("/resource/foo", "...", "text/plain");
 
 ```c++
 cli.set_decompress(false);
-res = cli.Get("/resource/foo", {{"Accept-Encoding", "gzip, deflate, br"}});
+res = cli.Get("/resource/foo");
 res->body; // Compressed data
+
 ```
 
 Use `poll` instead of `select`