0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00
Commit graph

23 commits

Author SHA1 Message Date
Loïc Hoguin
0f257d06b6
Add hibernate option to cowboy_http and cowboy_http2
When enabled the connection process will automatically hibernate.
Because hibernation triggers GC, this can be used as a way to
keep memory usage lower, at the cost of performance.
2025-02-07 17:59:44 +01:00
Björn Svensson
662f6af982
Correcting TransOpts in send_timeout_close tests 2025-01-23 13:29:47 +01:00
Loïc Hoguin
b36f064a91
Refresh copyright lines 2024-01-25 11:22:54 +01:00
Robert J. Macomber
f74b69c3ed
Optionally reset the idle timeout when sending data
A new option reset_idle_timeout_on_send has been added.
When set to 'true', the idle timeout is reset not only
when data is received, but also when data is sent.

This allows sending large responses without having to
worry about timeouts triggering.

The default is currently unchanged but might change in
a future release.

LH: Greatly reworked the implementation so that the
    timeout gets reset on almost all socket writes.
	This essentially completely supersets the original
	work. Tests are mostly the same although I
	refactored a bit to avoid test code duplication.

This commit also changes HTTP/2 behavior a little when
data is received: Cowboy will not attempt to update the
window before running stream handler commands to avoid
sending WINDOW_UPDATE frames twice. Now it has some
small heuristic to ensure they can only be sent once
at most.
2023-12-21 14:03:07 +01:00
Loïc Hoguin
627a4508b5
Explicitly close the socket in some tests for speed ups
The socket staying open meant that the graceful shut down
of the Cowboy listeners were waiting for the connections
to be closed gracefully (or a timeout). Closing explicitly
where it makes sense ensures we don't unnecessarily wait.

This commit removes a full minute in the run time of all
Cowboy test suites (minus examples).
2023-12-18 18:17:09 +01:00
Loïc Hoguin
67bd791dcc
Change send_timeout_close test to accomodate macOS 2023-12-14 15:25:25 +01:00
Sergei Shuvatov
3f5f326b73
Add test for send_timeout_close
LH: I reworked the test a little and added the same test
for HTTP/2 so that both HTTP/1.1 and HTTP/2 get the issue
fixed.
2023-12-12 15:05:01 +01:00
Viktor Söderqvist
059d58d39f
Graceful shutdown
Note: This commit makes cowboy depend on cowlib master.

Graceful shutdown for HTTP/2:

1. A GOAWAY frame with the last stream id set to 2^31-1 is sent and a
   timer is started (goaway_initial_timeout, default 1000ms), to wait
   for any in-flight requests sent by the client, and the status is set
   to 'closing_initiated'. If the client responds with GOAWAY and closes
   the connection, we're done.
2. A second GOAWAY frame is sent with the actual last stream id and the
   status is set to 'closing'. If no streams exist, the connection
   terminates. Otherwise a second timer (goaway_complete_timeout,
   default 3000ms) is started, to wait for the streams to complete. New
   streams are not accepted when status is 'closing'.
3. If all streams haven't completed after the second timeout, the
   connection is forcefully terminated.

Graceful shutdown for HTTP/1.x:

1. If a request is currently being handled, it is waited for and the
   response is sent back to the client with the header "Connection:
   close". Then, the connection is closed.
2. If the current request handler is not finished within the time
   configured in transport option 'shutdown' (default 5000ms), the
   connection process is killed by its supervisor (ranch).

Implemented for HTTP/1.x and HTTP/2 in the following scenarios:

* When receiving exit signal 'shutdown' from the supervisor (e.g. when
  cowboy:stop_listener/3 is called).
* When a connection process is requested to terminate using
  sys:terminate/2,3.

LH: Edited tests a bit and added todos for useful tests to add.
2020-11-27 15:38:21 +01:00
Loïc Hoguin
cf84f59d9b
Add persistent_term support to the router 2019-09-28 15:40:41 +02:00
Loïc Hoguin
dc240adc1e
Move some tests out of the old HTTP test suite
And additional minor tweaks.
2018-11-21 10:25:01 +01:00
Loïc Hoguin
d2f367fba3
Use try..after in tests that start their own listeners 2018-11-19 09:29:21 +01:00
Loïc Hoguin
bed328b6c9
Use ?FUNCTION_NAME instead of ct_helper:name()
Cowboy is 19+ so it's OK to use it.
2018-11-19 09:05:34 +01:00
Loïc Hoguin
8185d356c5
Add the idle_timeout option to HTTP/2 2018-11-16 16:30:57 +01:00
Loïc Hoguin
ef426e0ff4
Fix the infinity timeout tests
Make sure the test fails when the code is incorrect.
2018-08-13 11:10:49 +02:00
Bing Han
e9fd2925ae
Fix cancelling undefined settings timer
when settings_timeout is infinity
2018-08-13 11:10:49 +02:00
Loïc Hoguin
6e00600d7d
Fix intermittent failure of max_frame_size_sent test 2018-05-20 18:17:49 +02:00
Loïc Hoguin
9a29aea148
Add options controlling maximum h2 frame sizes 2018-04-27 17:58:37 +02:00
Loïc Hoguin
d38d86c4a9
Add options controlling initial control flow windows 2018-04-26 22:08:05 +02:00
Bartek Walkowicz
2131709328
Add case for handling infinity for idle/request_timeout
Currently cowboy assumes that idle_timeout or request_timeout is
a number and always starts timers. Similar situation takes place
in case of preface_timeout for http2. This commit adds case for
handling infinity as a timeout, allowing to not start mentioned
timers.
2018-03-14 17:15:06 +01:00
Loïc Hoguin
482de55a96
Fix a miscount of output flow control window for HTTP/2
The miscount occurred because of a faulty iolist split function.
The bug should now be corrected, a PropEr test has been added
and a regression test has also been added.
2018-01-23 16:14:18 +01:00
Loïc Hoguin
cf3ab5832a
Add nowarn_export_all to all test suites 2017-11-29 16:57:10 +01:00
Loïc Hoguin
6f7b59886e
Remove NumAcceptors argument from start_clear/tls
They are now cowboy:start_clear/3 and cowboy:start_tls/3.
The NumAcceptors argument can be specified via the
num_acceptor transport option. Ranch has been updated
to 1.4.0 to that effect.
2017-06-07 15:15:54 +02:00
Gary Rennie
4d92487f84
Add test for inactivity_timeout option in cowboy_http2
The inactivity timeout is used to close the connection in the absence of
any data from the client.

Since this is not part or the rfc7540 spec, a new http2_SUITE module has
been created with a test for the inactivity_timeout.
2017-05-05 18:46:12 +02:00