Browse Source

Updated README

yhirose 5 years ago
parent
commit
509b8570b0
1 changed files with 43 additions and 20 deletions
  1. 43 20
      README.md

+ 43 - 20
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