From 8e378779c247e5a7fa8edea7bea86c2c19abf94e Mon Sep 17 00:00:00 2001 From: yhirose Date: Sat, 16 Nov 2024 09:45:04 -0500 Subject: [PATCH] Update README --- README.md | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7148e5502a..eb8b075c4e 100644 --- a/README.md +++ b/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`