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

Update the multipart reading interface

Now named read_part/read_part_body, with a verb indicating action.
This commit is contained in:
Loïc Hoguin 2016-08-10 15:09:04 +02:00
parent ae95e87eb1
commit aa6f2ab5a4
5 changed files with 38 additions and 36 deletions

View file

@ -9,9 +9,9 @@ init(Req, Opts) ->
{ok, cowboy_req:reply(200, #{}, term_to_binary(Result), Req2), Opts}.
acc_multipart(Req, Acc) ->
case cowboy_req:part(Req) of
case cowboy_req:read_part(Req) of
{ok, Headers, Req2} ->
{ok, Body, Req3} = cowboy_req:part_body(Req2),
{ok, Body, Req3} = cowboy_req:read_part_body(Req2),
acc_multipart(Req3, [{Headers, Body}|Acc]);
{done, Req2} ->
{lists:reverse(Acc), Req2}

View file

@ -9,7 +9,7 @@ init(Req, Opts) ->
{ok, cowboy_req:reply(200, Req2), Opts}.
multipart(Req) ->
case cowboy_req:part(Req) of
case cowboy_req:read_part(Req) of
{ok, [{<<"content-length">>, BinLength}], Req2} ->
Length = list_to_integer(binary_to_list(BinLength)),
{Length, Req3} = stream_body(Req2, 0),
@ -19,7 +19,7 @@ multipart(Req) ->
end.
stream_body(Req, N) ->
case cowboy_req:part_body(Req) of
case cowboy_req:read_part_body(Req) of
{ok, Data, Req2} ->
{N + byte_size(Data), Req2};
{more, Data, Req2} ->