diff options
author | Loïc Hoguin <[email protected]> | 2017-05-03 17:44:00 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2017-05-03 17:44:00 +0200 |
commit | 95d2855f62aa31cfc65f270811c71edc43476aff (patch) | |
tree | 215a85cbfb5e2148a81f8ae9061157eb29820d88 /test/handlers/loop_handler_timeout_h.erl | |
parent | 73b4eb94ff8c5bf98b3e2faae22ee207c234bb38 (diff) | |
download | cowboy-95d2855f62aa31cfc65f270811c71edc43476aff.tar.gz cowboy-95d2855f62aa31cfc65f270811c71edc43476aff.tar.bz2 cowboy-95d2855f62aa31cfc65f270811c71edc43476aff.zip |
Add the idle_timeout HTTP/1.1 protocol option
This fixes the connection being dropped because of request_timeout
despite there being some active streams.
Diffstat (limited to 'test/handlers/loop_handler_timeout_h.erl')
-rw-r--r-- | test/handlers/loop_handler_timeout_h.erl | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/test/handlers/loop_handler_timeout_h.erl b/test/handlers/loop_handler_timeout_h.erl index 1628074..7061dbe 100644 --- a/test/handlers/loop_handler_timeout_h.erl +++ b/test/handlers/loop_handler_timeout_h.erl @@ -1,8 +1,9 @@ %% This module implements a loop handler that sends %% itself a timeout that will intentionally arrive -%% too late, as it configures itself to only wait -%% 200ms before closing the connection in init/2. -%% This results in a 204 reply being sent back by Cowboy. +%% after the HTTP/1.1 request_timeout. The protocol +%% is not supposed to close the connection when a +%% request is ongoing, and therefore this handler +%% will eventually send a 200 reply. -module(loop_handler_timeout_h). @@ -11,11 +12,11 @@ -export([terminate/3]). init(Req, _) -> - erlang:send_after(1000, self(), timeout), - {cowboy_loop, Req, undefined, hibernate}. + erlang:send_after(6000, self(), timeout), + {cowboy_loop, Req, #{hibernate => true}}. info(timeout, Req, State) -> - {stop, cowboy_req:reply(500, Req), State}. + {stop, cowboy_req:reply(200, #{}, <<"Good!">>, Req), State}. -terminate(timeout, _, _) -> +terminate(stop, _, _) -> ok. |