aboutsummaryrefslogtreecommitdiffstats
path: root/guide/req.md
diff options
context:
space:
mode:
authorrambocoder <[email protected]>2013-03-06 08:50:45 -0500
committerrambocoder <[email protected]>2013-03-06 08:50:45 -0500
commit84d7671e91bb2dee2081172dbf651860134ae75e (patch)
tree1fe31a5ec0edf33a2070d3ab253b5f0f02cb9913 /guide/req.md
parent233cf43ab9c6c16d22e14039a79606fc935693d6 (diff)
downloadcowboy-84d7671e91bb2dee2081172dbf651860134ae75e.tar.gz
cowboy-84d7671e91bb2dee2081172dbf651860134ae75e.tar.bz2
cowboy-84d7671e91bb2dee2081172dbf651860134ae75e.zip
Check the length before reading the body in body/1 and body_qs/1
Diffstat (limited to 'guide/req.md')
-rw-r--r--guide/req.md21
1 files changed, 16 insertions, 5 deletions
diff --git a/guide/req.md b/guide/req.md
index 8fd854a..f627737 100644
--- a/guide/req.md
+++ b/guide/req.md
@@ -91,11 +91,22 @@ was passed in the request, then Cowboy will return a size
of `undefined`, as it has no way of knowing it.
If you know the request contains a body, and that it is
-of appropriate size, then you can read it directly with
-either `body/1` or `body_qs/1`. Otherwise, you will want
-to stream it with `stream_body/1` and `skip_body/1`, with
-the streaming process optionally initialized using `init_stream/4`
-or `init_stream/5`.
+within 8MB (for `body/1`) or 16KB (for `body_qs/1`) bytes,
+then you can read it directly with either `body/1` or `body_qs/1`.
+If you want to override the default size limits of `body/1`
+or `body_qs/1`, you can pass the maximum body length byte
+size as first parameter to `body/2` and `body_qs/2` or pass
+atom `infinity` to ignore size limits.
+
+If the request contains bigger body than allowed default sizes
+or supplied maximum body length, `body/1`, `body/2`, `body_qs/1`
+and `body_qs/2` will return `{error, badlength}`. If the request
+contains chunked body, `body/1`, `body/2`, `body_qs/1`
+and `body_qs/2` will return `{error, chunked}`.
+If you get either of the above two errors, you will want to
+handle the body of the request using `stream_body/1` and
+`skip_body/1`, with the streaming process optionally
+initialized using `init_stream/4` or `init_stream/5`.
Multipart request body
----------------------