aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_http2.erl
AgeCommit message (Collapse)Author
2024-03-26Initial HTTP/3 implementationHEADmasterhttp3Loï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-14Update Cowlib to 2.13.0Loïc Hoguin
2023-01-23Update copyright lines in preparation for releaseLoïc Hoguin
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-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-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-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
2021-02-07Initial commit for Gun poolsLoïc Hoguin
The approach taken here is very similar to what browsers are doing. A separate pool is created for each host/port/scope. The authority (host header) is used to determine which pool will execute requests. A connection process is semi-randomly chosen, from the connections that have capacity. Maximum capacity is determined by the protocol (the HTTP/2 setting set by the server is used, for example). Multiple processes can process requests/responses on the same connection concurrently. There is no need to "give back" the response to the pool, the number of ongoing streams is maintained via an event handler. The implementation is currently not strict, there may be more attempts to create requests than there is capacity. I'm not sure if it should be made strict or if Gun should just wait before sending requests (it only matters in the HTTP/2 case at the moment). When there is no connection with capacity available in the pool (because they have too many streams, or are reconnecting, or any other reason), checking out fails. There is no timeout to wait for a connection to be available. On the other hand the checkout_retry option allows setting multiple timeouts to retry checking out a connection. Each retry attempt's wait time can have a different value. The initial implementation of this work was sponsored by Kobil and made at the suggestion of Ilya Khaprov.
2020-11-12Return 'undefined' for raw|socks origin_scheme where applicableLoïc Hoguin
2020-11-12Update copyright yearsLoïc Hoguin
2020-11-12Review and remove many todosLoïc Hoguin
HTTP/1.1 Upgrade to HTTP/2 will not be implemented. There are discussions for this functionality to be removed from the HTTP/2 spec. HTTP/1.1 Upgrade to TLS will most likely not be implemented.
2020-11-06Make CONNECT responses produce a response_end eventLoïc Hoguin
While the stream has not ended, the response has.
2020-11-06Fix IsFin mismatch in HTTP/2 CONNECT responseLoïc Hoguin
The response ends when the tunnel is established, even if the stream itself does not. The data coming in on the stream after is not part of the response. This makes both HTTP/1.1 and HTTP/2 send 'fin' to successful CONNECT responses.
2020-11-02Initial implementation of Websocket over HTTP/2http2-websocketLoïc Hoguin
2020-10-21Fix cookie handling when tunnel and origin schemes mismatchLoïc Hoguin
The cookie_ignore_informational has been moved to http_opts and http2_opts. Also fix an issue when using 'protocols' in gun:open. When connecting via TLS the protocol's options were discarded.
2020-10-19Fix cookies for tunnelsLoïc Hoguin
There are still small issues left to fix. In particular the set_cookie command should be replaced with doing the same in the protocol itself so that the scheme is correct. So CookieStore must be propagated to all callbacks.
2020-10-16Remove commented codeLoïc Hoguin
2020-10-16Add or fix events inside or related to CONNECT tunnelsLoïc Hoguin
2020-10-07Propagate timeouts to the right layer in HTTP/2 tunnelsLoïc Hoguin
This temporarily depends on Cowlib master.
2020-10-07Default keepalive to infinity for all protocolsLoïc Hoguin
For HTTP/2 some servers are not fond of receiving pings, especially if there's no stream at the time. (particularly gRPC servers). This is an odd decision for sure. Rather than trying to accomodate for their logic the ping is no longer sent by default. For Websocket sending a ping is a new feature in Gun 2.0 so I'm just being conservative there.
2020-10-05Improve some 'todo' return values and argumentsLoïc Hoguin
While most of this functionality isn't implemented this is not a reason to let them return invalid values.
2020-10-03Fix Dialyzer warningsLoïc Hoguin
2020-10-03Add tunnel_SUITE testing all 3-layer combinationsLoïc Hoguin
The test suite is 216 tests with a tunnel created via two proxies leading to one origin server. The tests are for example socks5_h2_https where socks5 identifies the first SOCKS5 proxy, h2 the second HTTP/2 CONNECT proxy and https the secure HTTP/1.1 origin server. The test not only sets up the tunnel and does a request (or sends/receives data in the case of raw origin servers) but also confirms that the stream_info and info data is correct.
2020-09-21Ensure the right stream_ref is passed around HTTP/2 tunnelsLoïc Hoguin
2020-09-21Fix compilation and Dialyzer warningsLoïc Hoguin
2020-09-21Fix gun:stream_info/2 when gun_tunnel is involvedLoïc Hoguin
2020-09-21Initial success for h2 CONNECT -> https CONNECT -> httpsLoïc Hoguin
2020-09-21Add test HTTP/2 CONNECT -> HTTP/1.1 CONNECT -> originLoïc Hoguin
Implements gun:connect with a tunnel.
2020-09-21Add more HTTP/2 CONNECT testsLoïc Hoguin
2020-09-21Add a gun:stream_ref() type and fix DialyzerLoïc Hoguin
2020-09-21Refactor protocol handling via gun_protocolsLoïc Hoguin
2020-09-21Few more tests and fixesLoïc Hoguin
2020-09-21Replace gun_tunnel_up/3 message with /4 variantLoïc Hoguin
Also fixes all the tests. Lots of work remain around protocols (how best to pass the base stream_ref to them? maybe the current solution, maybe a new argument to Protocol:init) and strengthen the concept of stream_ref, at least with its own type.
2020-09-21Rename the 3-arity gun_socks_up to gun_tunnel_upLoïc Hoguin
2020-09-21Add gun_tunnel_up message to HTTP/2 CONNECTLoïc Hoguin
2020-09-21First working HTTPS over secure HTTP/2Loïc Hoguin
Has a timer:sleep/1 though because there is currently no way to wait for the TLS handshake to complete.
2020-09-21Make gun_socks_up stream-specific for HTTP/2 CONNECTLoïc Hoguin
2020-09-21Make HTTP/2 CONNECT to a SOCKS server workLoïc Hoguin
2020-09-21Add HTTP/2 CONNECT tests with Cowboy as originLoïc Hoguin
2020-09-21Add the base_stream_ref to gun_http/gun_http2Loïc Hoguin
2020-09-21HTTP/2 over HTTP/2 CONNECTLoïc Hoguin
2020-09-21Improve HTTP/2 CONNECT to non-HTTP originLoïc Hoguin
Now has a proper StreamRef given to it by the CONNECT stream.
2020-09-21Make gun:stream_info/2 return intermediaries for HTTP/2 CONNECTLoïc Hoguin
2020-09-21Initial HTTP/2 CONNECT implementationLoïc Hoguin
2020-04-16Empty the commands queue when returningLoïc Hoguin
2020-03-12Make Gun use the cookie store when configured toLoïc Hoguin