0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 04:30:25 +00:00

Handle expect: 100-continue request headers

The 100 continue response will only be sent if the client
has not sent the body yet (at all), if the connection is
HTTP/1.1 or above and if the user has not sent it yet.

The 100 continue response is sent when the user calls
read_body and it is cowboy_stream_h's responsibility
to send it. This means projects that don't use the
cowboy_stream_h stream handler will need to handle the
expect header themselves (but that's okay because they
might have different considerations than normal Cowboy).
This commit is contained in:
Loïc Hoguin 2017-10-30 16:21:25 +00:00
parent f3d6b05b86
commit 217fac7f44
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
3 changed files with 77 additions and 7 deletions

View file

@ -18,6 +18,9 @@ echo(<<"read_body">>, Req0, Opts) ->
_ -> ok
end,
{_, Body, Req} = case cowboy_req:path(Req0) of
<<"/100-continue", _/bits>> ->
cowboy_req:inform(100, Req0),
cowboy_req:read_body(Req0);
<<"/full", _/bits>> -> read_body(Req0, <<>>);
<<"/opts", _/bits>> -> cowboy_req:read_body(Req0, Opts);
_ -> cowboy_req:read_body(Req0)