diff options
| author | Loïc Hoguin <[email protected]> | 2025-02-06 12:18:59 +0100 |
|---|---|---|
| committer | Loïc Hoguin <[email protected]> | 2025-02-06 12:18:59 +0100 |
| commit | 8e121d138c4f658cf0953eeeeea85d07c203a5b6 (patch) | |
| tree | 59ae986ddeaa6cb0a73408553d8f4c25a2779081 /test | |
| parent | 9d4912208e91c1cb3195bf86966a84e88e7c9ff9 (diff) | |
| download | cowboy-8e121d138c4f658cf0953eeeeea85d07c203a5b6.tar.gz cowboy-8e121d138c4f658cf0953eeeeea85d07c203a5b6.tar.bz2 cowboy-8e121d138c4f658cf0953eeeeea85d07c203a5b6.zip | |
Fix request_timeout triggering when a request was in the buffer
The problem was that when a request immediately following another
request with a large enough body, the data for the new request
(including headers) would be buffered waiting for more data,
instead of being processed immediately. If no more data came
in on the socket the request_timeout would eventually trigger.
Now the buffer is processed immediately.
Diffstat (limited to 'test')
| -rw-r--r-- | test/http_SUITE.erl | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl index a752250..4b8fc8c 100644 --- a/test/http_SUITE.erl +++ b/test/http_SUITE.erl @@ -43,6 +43,7 @@ end_per_group(Name, _) -> init_dispatch(_) -> cowboy_router:compile([{"localhost", [ {"/", hello_h, []}, + {"/delay_hello", delay_hello_h, #{delay => 1000, notify_received => self()}}, {"/echo/:key", echo_h, []}, {"/resp/:key[/:arg]", resp_h, []}, {"/set_options/:key", set_options_h, []}, @@ -454,6 +455,26 @@ request_timeout_pipeline(Config) -> cowboy:stop_listener(?FUNCTION_NAME) end. +request_timeout_pipeline_delay(Config) -> + doc("Ensure the request_timeout does not trigger on requests " + "coming in after a large request body."), + {ok, _} = cowboy:start_clear(?FUNCTION_NAME, [{port, 0}], #{ + env => #{dispatch => init_dispatch(Config)}, + request_timeout => 500 + }), + Port = ranch:get_port(?FUNCTION_NAME), + try + ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]), + {ok, http} = gun:await_up(ConnPid), + StreamRef1 = gun:post(ConnPid, "/", #{}, <<0:8000000>>), + StreamRef2 = gun:get(ConnPid, "/delay_hello"), + {response, nofin, 200, _} = gun:await(ConnPid, StreamRef1), + {response, nofin, 200, _} = gun:await(ConnPid, StreamRef2), + {error, {down, {shutdown, closed}}} = gun:await(ConnPid, undefined, 1000) + after + cowboy:stop_listener(?FUNCTION_NAME) + end. + request_timeout_skip_body(Config) -> doc("Ensure the request_timeout drops connections when requests " "fail to come in fast enough after skipping a request body."), |
