aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_req.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2024-01-08 15:13:18 +0100
committerLoïc Hoguin <[email protected]>2024-01-08 15:13:18 +0100
commite4a78aaeb110a3eda5269b618230b8bcb18fbcc2 (patch)
tree9c85e90adbe50b118ba0846473b17929bbda5e7d /src/cowboy_req.erl
parentc1490d7d5503636e7995583222cf8edf5f882db5 (diff)
downloadcowboy-e4a78aaeb110a3eda5269b618230b8bcb18fbcc2.tar.gz
cowboy-e4a78aaeb110a3eda5269b618230b8bcb18fbcc2.tar.bz2
cowboy-e4a78aaeb110a3eda5269b618230b8bcb18fbcc2.zip
Document body reading in auto mode
It is now tested both via cowboy_req:read_body and via cowboy_req:cast. Removes a bad example from the guide of body reading with period of infinity, which does not work.
Diffstat (limited to 'src/cowboy_req.erl')
-rw-r--r--src/cowboy_req.erl6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index 90c5a3a..312862d 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -521,7 +521,11 @@ read_body(Req=#{has_read_body := true}, _) ->
read_body(Req, Opts) ->
Length = maps:get(length, Opts, 8000000),
Period = maps:get(period, Opts, 15000),
- Timeout = maps:get(timeout, Opts, Period + 1000),
+ DefaultTimeout = case Period of
+ infinity -> infinity; %% infinity + 1000 = infinity.
+ _ -> Period + 1000
+ end,
+ Timeout = maps:get(timeout, Opts, DefaultTimeout),
Ref = make_ref(),
cast({read_body, self(), Ref, Length, Period}, Req),
receive