aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun_http.erl
AgeCommit message (Collapse)Author
2020-03-25Fix host/:authority header when connecting to an IPv6 addressLoïc Hoguin
2020-03-12Make Gun use the cookie store when configured toLoïc Hoguin
2019-10-01Don't try upgrading 101 responses with no/bad Upgrade headerLoïc Hoguin
Also rework the different handle_head scenarios in separate functions.
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-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-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-23Properly error out on HTTP/1.0 Websocket upgrade attemptsLoïc Hoguin
2019-09-23Reduce the #http_state sizeLoïc Hoguin
The version is still kept in the state even if it's an option because it's useful to have there and it's just a tiny atom.
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 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-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-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-26Add tls_handshake events for CONNECT through TLS proxiesLoïc Hoguin
2019-07-25Add tls_handshake events for CONNECT through TCP proxiesLoïc Hoguin
2019-07-25Fix missing response_end event for HTTP/1.0 body_closeLoïc Hoguin
2019-07-24Add the cancel event for local/remote stream cancellationLoïc Hoguin
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-07-03Add the response_trailers eventLoïc Hoguin
2019-07-03Add the response_start eventLoïc Hoguin
Thought it needed cow_http2_machine changes but everything was available. For HTTP/1.1 it is triggered when receiving data while expecting headers. For HTTP/2 it is triggered after we have received a HEADERS frame for streams in idle state.
2019-07-02Add response_inform/response_headers/response_end eventsLoïc Hoguin
This covers many scenarios but more need to be added.
2019-06-02Add request_start, request_headers and request_end eventsLoïc Hoguin
2019-04-25Fix Websocket upgrade host header when it's an IP addressSergey Tupchiy
2019-04-22Make gun_tls_proxy work for HTTP/2 connectionsLoïc Hoguin
2019-04-19Integrate gun_tls_proxy into gun properLoïc Hoguin
Still need to add ALPN support and to wait before trying to send data on a proxied TLS connection that didn't complete its handshake.
2019-01-09Add function gun:stream_info/2Loïc Hoguin
2019-01-06Fix KilledStreams value for HTTP for connection: close responsesLoïc Hoguin
2019-01-05Fix atom hostnamesLoïc Hoguin
2019-01-05Fix transfer-encoding precedence over content-lengthLoïc Hoguin
2019-01-03Update copyright yearsLoïc Hoguin
2019-01-02Don't send the default port in the host header for HTTP/2Loïc Hoguin
2019-01-02Don't send the default port in the host header for HTTP/1.1Loïc Hoguin
2018-12-31Separate request/4,5,6 into headers/4,5 and request/5,6Loïc Hoguin
This cleaner separation gets rid of the implicit body check that was causing issues for many users. Now the body is either given explicitly or it is expected via future gun:data/3 calls.
2018-12-31Fix stripping stream reference in gun_httpPiotr Bober
An invalid stream reference (the websocket tuple wrapper) was sent in the gun_data message. Also moves autobahn to its own test suite.
2018-12-19Convert the gun process to gen_statemLoïc Hoguin
2018-09-26Don't send keep-alive while waiting for CONNECT responsesLoïc Hoguin
Otherwise this can mess up the underlying protocol we will switch to, like TLS or HTTP/2.
2018-09-26Keep track of the intermediaries the connection go throughLoïc Hoguin
Also augment the CONNECT tests to confirm that the intermediaries are accounted for.
2018-09-20Use ALPN when proxying TLS connections using CONNECTLoïc Hoguin
This fixes HTTP/2 over TLS connections. The protocol destination option has been deprecated in favor of a protocols option.
2018-09-17Add HTTP/1.1 CONNECT supportLoïc Hoguin
Gun can now be used to connect through TCP HTTP/1.1 proxies using all supported protocols. It is also possible to create a tunnel through multiple proxies. Also updates Cowlib to 2.6.0.
2018-06-04Support Unix domain sockets when building host headersSimon Thörnqvist
2018-06-04Update copyright yearsLoïc Hoguin
2018-06-04Remove the dependency on RanchLoïc Hoguin
We instead of two new modules, gun_tcp and gun_tls. They only have 6 functions so far, much less than what Ranch provided before. Also renames ssl to tls where applicable. It's still possible to use the ssl transport option but it's now undocumented.
2018-06-03Rename gun_data and gun_sse to gun_data_h and gun_sse_hLoïc Hoguin