aboutsummaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)Author
2025-04-10Cleanup HTTP/2 timeouts on close to avoid stray messagesLoïc Hoguin
2025-04-09Catch post-handshake TLS 1.3 alertsLoïc Hoguin
When TLS 1.3 is used and `fail_if_no_peer_cert` (or equivalent) is configured on the server, such as in mTLS scenarios, and the client certificate is missing or invalid, the TLS 1.3 alert will be sent after the handshake has completed. The same is true for post-handshake authentication in TLS 1.3 which Erlang/OTP doesn't yet support, but will at some point in the future. Due to the asynchronous nature of some `ssl` socket operations, such as sending, the alert may not always be returned from a socket call. When the ssl socket is active we would receive it as a message instead, so when Gun gets `{error,closed}` it must look for the active message and see if an alert occurred. When the ssl socket is passive we don't, so we must query the socket for it (trying to set the socket active at that point gets us the alert in the return value). There is a span between handshake and the initial active mode set where the socket is passive and may send data (the HTTP/2 preface) so we must account for both cases. Because we sometimes have to wait for the alert as a message, and we don't want to wait for a very long time (200ms), we sometimes may lose the alert. Perhaps in the future this wait time can be made configurable for users that really require getting the alert. The tests are only enabled on Linux because other OSes have intermittent failures (likely due to timing).
2025-03-28Reject Websocket frames sent over HTTPLoïc Hoguin
2025-03-27Handle error when sending Websocket pong framesLoïc Hoguin
Also fix an EvHandlerState value that mistakenly got dropped.
2025-03-26Default the origin authority to "localhost" for unix socketsLoïc Hoguin
Otherwise garbage gets sent.
2025-03-26Configure customize_hostname_check by defaultLoïc Hoguin
HTTP requires us to do wildcard certificate matching so we now do it by default. That plus the previously added `cacerts` configuration by default (using `public_key:cacerts_get/0`) means that as far as certificates are concerned, the default should now be fully compliant. Users may want to keep configuring some options such as `depth` though.
2025-03-26Remove copyright years from all files except LICENSELoïc Hoguin
2025-03-26Better identify ping errors and test the HTTP/1.1 oneLoïc Hoguin
2025-03-26User ping payload is 10000 or aboveLoïc Hoguin
2025-03-26Implement user pings for tunnelsLoïc Hoguin
2025-03-21Add gun:ping/2,3 for user-initiated ping for HTTP/2Viktor Söderqvist
Signed-off-by: Viktor Söderqvist <[email protected]>
2025-03-21Respect remote concurrency limit for headers/connect/ws_upgraderespect-remote-concurrency-limitLoïc Hoguin
In order to simplify the implementation the CookieStore is given to the connect function now, even though it's not currently used.
2025-03-18HTTP/2: Respect remote MAX_CONCURRENT_STREAMSViktor Söderqvist
If the limit has been reached, new requests are failed immediately, so that the application can retry them on a different connection. Co-authored-by: Björn Svensson <[email protected]>
2025-02-27Do not ignore data received immediately after switching to rawDenys Knertser
LH: Minor tweaks.
2025-02-27Include event handler state in gun:info/1 resultViktor Söderqvist
Adds event_handler and event_handler_state in the map returned by gun:info/1. Signed-off-by: Viktor Söderqvist <[email protected]>
2025-02-26Allow specifying functions for reply_toViktor Söderqvist
LH: I have fixed types, extended tests and tweaked a bit.
2025-02-25Send NO_ERROR in client-initiated graceful shutdownViktor Söderqvist
2025-02-25Add state_name field to gun:info/1Viktor Söderqvist
2025-01-02HTTP/2: Fix tunneled streams bugsLoïc Hoguin
* Tunneled streams can now close the stream. * Data received on tunneled streams now result in WINDOW_UPDATE frames being sent if necessary, and flow control is handled. This was detected as part of writing a new Cowboy test suite for benchmarking Websocket, but should help other uses too.
2024-11-06Fix a Dialyzer warningLoïc Hoguin
2024-03-26Initial HTTP/3 implementationhttp3Loïc Hoguin
Since quicer, which provides the QUIC implementation, is a NIF, Gun cannot depend directly on it. In order to enable QUIC and HTTP/3, users have to set the GUN_QUICER environment variable: export GUN_QUICER=1 Gun is now tested using GitHub Actions. As a result OTP-24+ is now required. In addition, the number of OTP releases tested has been reduced; only the latest of each major version is now tested. This also updates Erlang.mk.
2024-03-14Use public_key:cacerts_get/0 when possibleLoïc Hoguin
Also "fix" many TLS test failures due to yet more changes in the default options for TLS. Also small changes to make Dialyzer happy.
2024-03-14Remove client_preferred_next_protocolsViktor Söderqvist
2024-03-14Update Cowlib to 2.13.0Loïc Hoguin
2023-06-05Fix crash when TLS connection closes very earlyLoïc Hoguin
And ensure that we don't infinite loop when retries are enabled, by decrementing the retry count instead of using a new one. Also check for ssl:negotiated_protocol {error,closed} which was possible but was not documented in OTP before this change. Thanks @voluntas for the help.
2023-01-23Update public domain suffix listLoïc Hoguin
2023-01-23Update copyright lines in preparation for releaseLoïc Hoguin
2022-12-12macOS: Error out on eaddrnotavail instead of retryingLoïc Hoguin
This is to avoid reconnecting forever in a loop on bad configuration (such as IP in a different subnet).
2022-12-06Add keepalive_tolerance http2 optionViktor Söderqvist
The number of unacknowledged pings that can be tolerated before the connection is forcefully closed. When a keepalive ping is sent to the peer, a counter is incremented and if this counter exceeds the tolerance limit, the connection is forcefully closed. The counter is decremented whenever a ping ack is received from the peer. By default, the mechanism for closing the connection based on ping and ping ack is disabled. Loïc Hoguin: I have edited a lot of the code and renamed a few things as well as simplified the docs and increased test timeouts to avoid race conditions.
2022-12-05Document Websocket subprotocol negotiationLoïc Hoguin
2022-11-21Don't infinite loop gun_pool on bad configurationLoïc Hoguin
We leave the pool in a degraded state if the configuration given is invalid and a lookup/connect can't be made.
2022-11-21Support positive HTTP/1.0 responses to CONNECT requestsLoïc Hoguin
2022-11-21Enable send timeouts by defaultLoïc Hoguin
When no TCP options are provided, Gun will enable send timeouts at 15s. The value was chosen large enough to be safe while still allowing Gun to detect send errors eventually. Different applications may need to tweak and lower this value.
2022-11-14Implement gun_raw:down/1, gun_raw:update_flow/4Denys Knertser
Loïc: I have reworded a couple things and reordered the tests. It would be great to also test these things over proxies.
2022-11-08Include Websocket StreamRef in gun_down messagesWei Huang
2022-10-24Cookies: default SameSite is now "Default", not "None"Loïc Hoguin
2022-10-24Also flush gun_tunnel_upLed
2022-10-24Handle send errorsViktor Söderqvist
2022-10-11Make many gun_http2 functions return state or error tupleViktor Söderqvist
The following functions used to return a state, but now return {state, State} or {error, Reason}: * frame/5 * update_window/1,2 * maybe_ack_or_notify/2 * reset_stream/3 * push_promise_frame/7 * goaway/2 * maybe_send_data/6 * send_data/4 * send_data/6 * send_data_frame/4 Dialyzer will temporarily fail until functions start to return error tuples.
2022-09-19Handle of HTTP/2 tunnel errorsLoïc Hoguin
2022-09-12Add close/1 to gun_tls_proxy_cb to avoid undef crashesLoïc Hoguin
2022-09-12Update cookie tests against latest WPTLoïc Hoguin
The http-state tests were removed and replaced with tests in HTML pages. I have devised a way to semi- automatically import them and test them. Additional fixes were made following changes in the rfc6265bis draft.
2022-08-30Ignore parameters for text/event-streamBenedikt Reinartz
2022-08-30Make Protocol:init/4 return an ok-tupleViktor Söderqvist
This is a preparation for allowing init/4 to return an ok or an error tuple.
2022-03-08Handle any zero-sized Data in http:data with finMartin Björklund
Amended to make the test case hit the problem.
2022-03-08Don't add default SNI if already setJohan Bevemyr
2022-03-08gun_pool Dialyzer fixesSergei Shuvatov
2022-03-08Fix flushing by stream referenceSergei Shuvatov
2022-03-08Make the stream_error_* functions return 'ok'Viktor Söderqvist
This will make it more obvious what callbacks return.
2022-03-08Return commands instead of state in remaining callbacksViktor Söderqvist