aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-10-02 19:12:05 +0200
committerLoïc Hoguin <[email protected]>2019-10-02 19:12:05 +0200
commit20660d7566b63977e80f694724fee890d875ec1b (patch)
tree38cb0e24818b1c196f94636319400158c1295df2 /test/handlers
parent8f6ee9c1868ebc7bf31fb4846114919e164e0cf3 (diff)
downloadcowboy-20660d7566b63977e80f694724fee890d875ec1b.tar.gz
cowboy-20660d7566b63977e80f694724fee890d875ec1b.tar.bz2
cowboy-20660d7566b63977e80f694724fee890d875ec1b.zip
Ensure we can read the request body from any process
Diffstat (limited to 'test/handlers')
-rw-r--r--test/handlers/echo_h.erl10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/handlers/echo_h.erl b/test/handlers/echo_h.erl
index ec37a66..7d0e75b 100644
--- a/test/handlers/echo_h.erl
+++ b/test/handlers/echo_h.erl
@@ -30,6 +30,16 @@ echo(<<"read_body">>, Req0, Opts) ->
Length = cowboy_req:body_length(Req1),
{ok, integer_to_binary(Length), Req1};
<<"/opts", _/bits>> -> cowboy_req:read_body(Req0, Opts);
+ <<"/spawn", _/bits>> ->
+ Parent = self(),
+ Pid = spawn_link(fun() ->
+ Parent ! {self(), cowboy_req:read_body(Req0)}
+ end),
+ receive
+ {Pid, Msg} -> Msg
+ after 5000 ->
+ error(timeout)
+ end;
_ -> cowboy_req:read_body(Req0)
end,
{ok, cowboy_req:reply(200, #{}, Body, Req), Opts};