From 8459bebceb9533948193774371cbd9fd571b78ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 16 Oct 2019 09:48:31 +0200 Subject: Cowboy 2.7.0 --- docs/en/cowboy/2.6/guide/req_body/index.html | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'docs/en/cowboy/2.6/guide/req_body') diff --git a/docs/en/cowboy/2.6/guide/req_body/index.html b/docs/en/cowboy/2.6/guide/req_body/index.html index 83e7ba92..641c6a26 100644 --- a/docs/en/cowboy/2.6/guide/req_body/index.html +++ b/docs/en/cowboy/2.6/guide/req_body/index.html @@ -69,7 +69,7 @@

Cowboy provides functions for reading the body raw, and read and parse form urlencoded or multipart bodies. The latter is covered in its own chapter.

Request body presence

Not all requests come with a body. You can check for the presence of a request body with this function:

-
@@ -79,7 +79,7 @@ http://www.gnu.org/software/src-highlite -->

In practice, this function is rarely used. When the method is POST, PUT or PATCH, the request body is often required by the application, which should just attempt to read it directly.

Request body length

You can obtain the length of the body:

-
@@ -89,7 +89,7 @@ http://www.gnu.org/software/src-highlite -->

Cowboy will update the body length in the Req object once the body has been read completely. A length will always be returned when attempting to call this function after reading the body completely.

Reading the body

You can read the entire body with one function call:

-
@@ -98,7 +98,7 @@ http://www.gnu.org/software/src-highlite -->

Cowboy returns an ok tuple when the body has been read fully.

By default, Cowboy will attempt to read up to 8MB of data, for up to 15 seconds. The call will return once Cowboy has read at least 8MB of data, or at the end of the 15 seconds period.

These values can be customized. For example, to read only up to 1MB for up to 5 seconds:

-
@@ -106,7 +106,7 @@ http://www.gnu.org/software/src-highlite --> #{length => 1000000, period => 5000}).

You may also disable the length limit:

-
@@ -116,7 +116,7 @@ http://www.gnu.org/software/src-highlite -->

These two options can effectively be used to control the rate of transmission of the request body.

Streaming the body

When the body is too large, the first call will return a more tuple instead of ok. You can call the function again to read more of the body, reading it one chunk at a time.

-
@@ -133,7 +133,7 @@ http://www.gnu.org/software/src-highlite -->

The length and period options can also be used. They need to be passed for every call.

Reading a form urlencoded body

Cowboy provides a convenient function for reading and parsing bodies sent as application/x-www-form-urlencoded.

-
@@ -141,7 +141,7 @@ http://www.gnu.org/software/src-highlite -->

This function returns a list of key/values, exactly like the function cowboy_req:parse_qs/1.

The defaults for this function are different. Cowboy will read for up to 64KB and up to 5 seconds. They can be modified:

-
@@ -205,6 +205,8 @@ http://www.gnu.org/software/src-highlite --> +
  • 2.7
  • +
  • 2.6
  • 2.5
  • -- cgit v1.2.3