diff options
author | Loïc Hoguin <[email protected]> | 2019-10-02 20:30:32 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2019-10-02 20:30:32 +0200 |
commit | eaa052616f7c85d4daf4817ceecd5f87fecfc8f4 (patch) | |
tree | 1865efbc9551631607435119839e8af0dc779a8b /test/handlers/resp_h.erl | |
parent | 20660d7566b63977e80f694724fee890d875ec1b (diff) | |
download | cowboy-eaa052616f7c85d4daf4817ceecd5f87fecfc8f4.tar.gz cowboy-eaa052616f7c85d4daf4817ceecd5f87fecfc8f4.tar.bz2 cowboy-eaa052616f7c85d4daf4817ceecd5f87fecfc8f4.zip |
Ensure we can stream the response body from any process
Diffstat (limited to 'test/handlers/resp_h.erl')
-rw-r--r-- | test/handlers/resp_h.erl | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/handlers/resp_h.erl b/test/handlers/resp_h.erl index 19405db..bc76d56 100644 --- a/test/handlers/resp_h.erl +++ b/test/handlers/resp_h.erl @@ -247,6 +247,21 @@ do(<<"stream_body">>, Req0, Opts) -> cowboy_req:stream_body(<<"Hello! ">>, nofin, Req), cowboy_req:stream_body({sendfile, 0, AppSize, AppFile}, fin, Req), {ok, Req, Opts}; + <<"spawn">> -> + Req = cowboy_req:stream_reply(200, Req0), + Parent = self(), + Pid = spawn(fun() -> + cowboy_req:stream_body(<<"Hello ">>, nofin, Req), + cowboy_req:stream_body(<<"world">>, nofin, Req), + cowboy_req:stream_body(<<"!">>, fin, Req), + Parent ! {self(), ok} + end), + receive + {Pid, ok} -> ok + after 5000 -> + error(timeout) + end, + {ok, Req, Opts}; _ -> %% Call stream_body without initiating streaming. cowboy_req:stream_body(<<0:800000>>, fin, Req0), |