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

Move body length count to cowboy_stream_h instead of protocols

The documentation was correct, the code was not.

This should make it easier to implement new protocols. Note that
for HTTP/2 we will need to add some form of counting later on to
check for malformed requests, but we can do simpler and just
reduce from the expected length and then check if that's 0 when
IsFin=fin.
This commit is contained in:
Loïc Hoguin 2017-09-25 12:34:44 +02:00
parent a6126306a2
commit c09b10190b
No known key found for this signature in database
GPG key ID: 71366FF21851DF03
4 changed files with 48 additions and 37 deletions

View file

@ -440,7 +440,7 @@ read_body(Req=#{pid := Pid, streamid := StreamID}, Opts) ->
receive
{request_body, Ref, nofin, Body} ->
{more, Body, Req};
{request_body, Ref, {fin, BodyLength}, Body} ->
{request_body, Ref, fin, BodyLength, Body} ->
{ok, Body, set_body_length(Req, BodyLength)}
after Timeout ->
exit(timeout)