0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

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.
This commit is contained in:
Loïc Hoguin 2024-01-08 15:13:18 +01:00
parent c1490d7d55
commit e4a78aaeb1
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
8 changed files with 137 additions and 21 deletions

View file

@ -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