From 509b8570b0ff09985354a11deefefd35dc34bbf2 Mon Sep 17 00:00:00 2001 From: yhirose Date: Sat, 23 May 2020 19:08:17 -0400 Subject: [PATCH] Updated README --- README.md | 63 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index c8c5ecd..95dbe2d 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,44 @@ svr.Get("/chunked", [&](const Request& req, Response& res) { }); ``` +### 'Expect: 100-continue' handler + +As default, the server sends `100 Continue` response for `Expect: 100-continue` header. + +```cpp +// Send a '417 Expectation Failed' response. +svr.set_expect_100_continue_handler([](const Request &req, Response &res) { + return 417; +}); +``` + +```cpp +// Send a final status without reading the message body. +svr.set_expect_100_continue_handler([](const Request &req, Response &res) { + return res.status = 401; +}); +``` + +### Keep-Alive connection + +```cpp +svr.set_keep_alive_max_count(2); // Default is 5 +``` + +### Timeout + +```c++ +svr.set_read_timeout(5, 0); // 5 seconds +svr.set_write_timeout(5, 0); // 5 seconds +svr.set_idle_interval(0, 100000); // 100 milliseconds +``` + +### Set maximum payload length for reading request body + +```c++ +svr.set_payload_max_length(1024 * 1024 * 512); // 512MB +``` + ### Server-Sent Events Please check [here](https://github.com/yhirose/cpp-httplib/blob/master/example/sse.cc). @@ -240,24 +278,6 @@ svr.new_task_queue = [] { }; ``` -### 'Expect: 100-continue' handler - -As default, the server sends `100 Continue` response for `Expect: 100-continue` header. - -```cpp -// Send a '417 Expectation Failed' response. -svr.set_expect_100_continue_handler([](const Request &req, Response &res) { - return 417; -}); -``` - -```cpp -// Send a final status without reading the message body. -svr.set_expect_100_continue_handler([](const Request &req, Response &res) { - return res.status = 401; -}); -``` - Client Example -------------- @@ -360,11 +380,14 @@ res = cli.Options("*"); res = cli.Options("/resource/foo"); ``` -### Connection Timeout +### Timeout ```c++ -cli.set_timeout_sec(5); // timeouts in 5 seconds +cli.set_connection_timeout(0, 300000); // 300 milliseconds +cli.set_read_timeout(5, 0); // 5 seconds +cli.set_write_timeout(5, 0); // 5 seconds ``` + ### Receive content with Content receiver ```cpp