mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-16 05:00:24 +00:00
Fix chunked streaming of request body and improve speed
This commit is contained in:
parent
ab0699ab29
commit
85d05fff34
3 changed files with 41 additions and 20 deletions
|
@ -73,6 +73,7 @@
|
|||
-export([stream_body_set_resp/1]).
|
||||
-export([stream_body_set_resp_close/1]).
|
||||
-export([te_chunked/1]).
|
||||
-export([te_chunked_chopped/1]).
|
||||
-export([te_chunked_delayed/1]).
|
||||
-export([te_identity/1]).
|
||||
|
||||
|
@ -133,6 +134,7 @@ groups() ->
|
|||
stream_body_set_resp,
|
||||
stream_body_set_resp_close,
|
||||
te_chunked,
|
||||
te_chunked_chopped,
|
||||
te_chunked_delayed,
|
||||
te_identity
|
||||
],
|
||||
|
@ -1037,6 +1039,21 @@ te_chunked(Config) ->
|
|||
{ok, 200, _, Client3} = cowboy_client:response(Client2),
|
||||
{ok, Body, _} = cowboy_client:response_body(Client3).
|
||||
|
||||
te_chunked_chopped(Config) ->
|
||||
Client = ?config(client, Config),
|
||||
Body = list_to_binary(io_lib:format("~p", [lists:seq(1, 100)])),
|
||||
Body2 = iolist_to_binary(body_to_chunks(50, Body, [])),
|
||||
{ok, Client2} = cowboy_client:request(<<"GET">>,
|
||||
build_url("/echo/body", Config),
|
||||
[{<<"transfer-encoding">>, <<"chunked">>}], Client),
|
||||
{ok, Transport, Socket} = cowboy_client:transport(Client2),
|
||||
_ = [begin
|
||||
ok = Transport:send(Socket, << C >>),
|
||||
ok = timer:sleep(10)
|
||||
end || << C >> <= Body2],
|
||||
{ok, 200, _, Client3} = cowboy_client:response(Client2),
|
||||
{ok, Body, _} = cowboy_client:response_body(Client3).
|
||||
|
||||
te_chunked_delayed(Config) ->
|
||||
Client = ?config(client, Config),
|
||||
Body = list_to_binary(io_lib:format("~p", [lists:seq(1, 100)])),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue