aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun.erl
AgeCommit message (Collapse)Author
2020-04-16Add tests for cookie_ignore_informational optionLoïc Hoguin
2020-03-28Fix a Dialyzer warning introduced in the previous commitLoïc Hoguin
2020-03-28Make intermediaries return tls not tls_proxyLoïc Hoguin
Also add a test for CONNECT to TLS via 2 TLS proxies.
2020-03-25Fix crash in gun:info/1 when socket is closedLoïc Hoguin
The call to Transport:sockname/1 can return an error if the socket was closed as we were gathering info. In that case we simply do not fill in the address and port information.
2020-03-15Document the cookie store option and related modulesLoïc Hoguin
Also contains a few small changes and Dialyzer fixes.
2020-03-12Make Gun use the cookie store when configured toLoïc Hoguin
2020-02-10Handle cow_http2_machine timeoutsLoïc Hoguin
2019-10-08Fix retrying on disconnect with retry=1Loïc Hoguin
2019-09-26Document the cow_http2_machine optionsLoïc Hoguin
The details are not given for now. The best would be to document them in Cowlib and refer to that documentation instead of duplicating the information in both the Gun and Cowboy manuals.
2019-09-26Remove UnprocessedStreams from the gun_down messageLoïc Hoguin
2019-09-26Add reply_to option to ws_upgrade; remove notowner entirelyLoïc Hoguin
The reply_to option is also propagated when we switch protocols.
2019-09-26Add a function to change the connection ownerLoïc Hoguin
While at it the gun:info/1 function has been fixed to work even when we are in the not_connected state, and the owner is now also returned.
2019-09-24Add auto-ping to Websocket and a silence_pings optionLoïc Hoguin
The auto-ping will at regular interval send a ping frame. The silence_pings option defaults to true. It can be set to false when the user needs to receive ping/pong frames.
2019-09-24Reject requests/data when using WebsocketLoïc Hoguin
2019-09-24Initial support for raw send/recv operationsLoïc Hoguin
Gun can now be used to send or receive arbitrary data in the following scenarios: * Directly after connecting to a server (this is not terribly useful but it works nevertheless due to the Gun architecture) * After connecting through one or more Socks and/or HTTP proxies. This allows using Gun's proxy capabilities to access servers located beyond firewalls. * After performing an HTTP/1.1 Upgrade. This allows using Gun to implement custom protocols that require upgrading from an HTTP/1.1 connection. As there is still no support for HTTP/2 CONNECT for the time being, there are no relevant streams attached to those use cases and therefore the raw protocol currently expects users to use 'undefined' as the StreamRef value. This is not a final decision and will most likely produce a Dialyzer warning at this time.
2019-09-23Set server_name_indication for TLS handshakesLoïc Hoguin
This essentially reverts to the old behavior for initial TLS handshakes, and improves TLS support for the Socks/HTTP proxy cases.
2019-09-23Accept all cow_http2_machine optionsLoïc Hoguin
2019-09-23Remove 'protocol' option from connect_destination()Loïc Hoguin
It was deprecated and replaced by 'protocols' in a previous version.
2019-09-22Cancel the existing keepalive when switching protocolsLoïc Hoguin
2019-09-22Document Socks supportLoïc Hoguin
Also correct various Socks related types. This commit also adds a new gun:protocols/0 type as a simpler way of describing preferred protocols. The protocol/opts tuple is also documented. This commit also fixes an issue with the default value for the preferred protocols when using CONNECT over TLS. It was mistakenly not enabling http2 by default.
2019-09-22Add CONNECT->Socks5->HTTP testsLoïc Hoguin
Also fix the multiple TLS proxies tests from the previous commit.
2019-09-22Add more tests with two Socks5 proxiesLoïc Hoguin
We now properly support TCP across two TLS proxies, and TLS across two TCP/TLS proxies.
2019-09-22Always switch_protocolLoïc Hoguin
When doing a CONNECT from http to http or from socks to socks we may want to use different configuration options. Switching the protocol explicitly helps us achieve that. It will also signal through events that a protocol switch occurred.
2019-09-22Rework state transitions resulting from from protocol changesLoïc Hoguin
2019-09-22Improve retrieval of keepalive optionLoïc Hoguin
2019-09-22Supports going through multiple Socks proxiesLoïc Hoguin
This commit also reworks the switch_protocol command. The `P | {P, Opts}` type is used here as well. This allows us to remove the code specific to Websocket. In addition a few new protocol functions allow us to declare what's the name of the options key for the protocol and what the capabilities are with regard to keepalive.
2019-09-22Add Socks5->HTTP/2 testsLoïc Hoguin
Also consolidate the ALPN code in the tls_handshake state rather than doing it in CONNECT/Socks separately. Also improves the origin tests by sending a message once the handshake is completed instead of having timeouts.
2019-09-22Support connecting to HTTPS server via TCP Socks5Loïc Hoguin
2019-09-22Further consolidation of TLS handshakesLoïc Hoguin
2019-09-22Simplify HandshakeEventLoïc Hoguin
2019-09-22Move and merge all TLS handshakes to the main Gun codeLoïc Hoguin
There's now an initial_tls_handshake state for the initial connection with handshake, and tls_handshake state for any subsequent TLS handshakes. The Socks5 code will be able to reuse this tls_handshake state to perform its own transport switches.
2019-09-22Initial support for Socks5Loïc Hoguin
2019-09-05Implement graceful shutdownLoïc Hoguin
The graceful shutdown is implemented through a new 'closing' state. This state is entered under different circumstances depending on the protocol. The gun:shutdown/1 function is now implemented and documented. It allows shutting down the connection gracefully regardless of the current state of the connection and for all protocols. The behavior is entirely dependent on the protocol. For HTTP/1.1 the connection stays up only until after the current stream is complete; other streams are immediately canceled. For HTTP/2 a GOAWAY frame is sent and existing streams continue to be processed. The connection is closed after all streams are processed and the server's GOAWAY frame is received. For Websocket a close frame is sent. The connection is closed when receiving the server's close frame. In all cases the closing_timeout option defines how long we wait, as a maximum, before closing the connection after the graceful shutdown was started. The graceful shutdown is also initiated when the owner process goes away; when sending an HTTP/1.1 request with the connection: close header; when receiving an HTTP/1.1 response with the connection: close header; when receiving an HTTP/1.0 response without a connection header; when the server sends a GOAWAY HTTP/2 frame; or when we send or receive a Websocket close frame. Along with these changes, the gun:ws_send/2 function now accepts a list of frames as argument. Those frames may include a close frame that initiates the graceful shutdown.
2019-08-05Add flow controlLoïc Hoguin
Flow control is disabled by default. The initial flow value must be set to enable it (either for the entire connection or on a per-request basis). Flow applies to all HTTP streams as well as Websocket. HTTP/2 pushed streams receive the same value as their originating stream.
2019-07-27Fix ssl and other typesLoïc Hoguin
2019-07-27Add the retry_fun option for different backoff strategiesLoïc Hoguin
2019-07-27Postpone operations until connectedTony Han
2019-07-26Add the origin_changed eventLoïc Hoguin
2019-07-26Add the transport_changed eventLoïc Hoguin
Also test protocol_changed over CONNECT.
2019-07-26Add tls_handshake events for CONNECT through TLS proxiesLoïc Hoguin
2019-07-24Add the cancel event for local/remote stream cancellationLoïc Hoguin
2019-07-22Split domain lookup/connect/TLS handshake and add eventsLoïc Hoguin
This changes the way we connect to servers entirely. We now have three states when connecting (domain_lookup, connect and tls_handshake when applicable) and as a result three corresponding timeout options. Each state has a start/end event associated and the event data was tweaked to best match each event. Since the TLS handshake is separate, the transport_opts option was also split into two: tcp_opts and tls_opts.
2019-07-15Add Websocket frames related eventsLoïc Hoguin
2019-07-13Add ws_upgrade/protocol_changed eventsLoïc Hoguin
And ensure that Websocket triggers all the request/response events.
2019-06-02Add request_start, request_headers and request_end eventsLoïc Hoguin
2019-05-13Add the terminate eventLoïc Hoguin
2019-05-13Add the disconnect event callbackLoïc Hoguin
2019-05-08Add event_handler with init/connect_start/connect_endLoïc Hoguin
2019-04-26Add upgrade/ws tuples to gun:await/2,3,4Loïc Hoguin
2019-04-26Add specs to await functions, document error type betterLoïc Hoguin