Debian Codegraph @

test/handlers/loop_handler_timeout_h.erl

raw
1 %% This module implements a loop handler that sends
2 %% itself a timeout that will intentionally arrive
3 %% after the HTTP/1.1 request_timeout. The protocol
4 %% is not supposed to close the connection when a
5 %% request is ongoing, and therefore this handler
6 %% will eventually send a 200 reply.
7
8 -module(loop_handler_timeout_h).
9
10 -export([init/2]).
11 -export([info/3]).
12 -export([terminate/3]).
13
14 init(Req, _) ->
15 erlang:send_after(6000, self(), timeout),
16 {cowboy_loop, Req, #{hibernate => true}}.
17
18 info(timeout, Req, State) ->
19 {stop, cowboy_req:reply(200, #{}, <<"Good!">>, Req), State}.
20
21 terminate(stop, _, _) ->
22 ok.