test/handlers/read_body_h.erl
raw| 1 | %% This module reads the request body fully and send a 204 response. |
| 2 | |
| 3 | -module(read_body_h). |
| 4 | |
| 5 | -export([init/2]). |
| 6 | |
| 7 | init(Req0, Opts) -> |
| 8 | {ok, Req} = read_body(Req0), |
| 9 | {ok, cowboy_req:reply(200, #{}, Req), Opts}. |
| 10 | |
| 11 | read_body(Req0) -> |
| 12 | case cowboy_req:read_body(Req0) of |
| 13 | {ok, _, Req} -> {ok, Req}; |
| 14 | {more, _, Req} -> read_body(Req) |
| 15 | end. |