Age | Commit message (Collapse) | Author |
|
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.
|
|
Also fix the multiple TLS proxies tests from the previous commit.
|
|
We now properly support TCP across two TLS proxies, and
TLS across two TCP/TLS proxies.
|
|
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.
|
|
|
|
|
|
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.
|
|
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.
|
|
|
|
|
|
|
|
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.
|
|
|
|
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.
|
|
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.
|
|
|
|
|
|
|
|
|
|
Also test protocol_changed over CONNECT.
|
|
|
|
|
|
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.
|
|
|
|
And ensure that Websocket triggers all the request/response
events.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
No need to have the error repeated in the logs by the Gun process.
|
|
This fixes a bug in `gun` when trying to open 2 connections with tracing enabled.
You can recreate it like so:
> application:ensure_all_started(gun).
> gun:open("localhost", 80, #{trace => true}).
> gun:open("localhost", 80, #{trace => true}).
The second call fails with a cause clause exception.
You'll observe the same exception by:
> dbg:start().
> dbg:start().
Ultimately this may be a bug in OTP, but since `dbg:start/0` is undocumented
I'm inclined to give it the benefit of the doubt. Regardless, since the docs[1]
clearly state that calling `dbg:tracer/0` is the proper way to start the default
tracer message receiver, I argue that calling `dbg:start/0` is a bug in `gun`.
[1]: http://erlang.org/doc/man/dbg.html
|
|
|
|
|
|
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.
|
|
|
|
Header names can now be provided as binary, string or atom
and Gun no longer requires them to be in lowercase. The list
of headers can also be provided as a map as well.
|
|
This was a bug in the case of HTTP/1.1 and an inconvenience
in the case of HTTP/2.
|
|
|
|
|
|
Also fixes an issue with switch_transport introduced when
converting the Gun process to gen_statem.
|
|
This is safer as servers may reject too many extra empty lines.
|
|
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.
|
|
|
|
A common state machine for Gun and Cowboy will be easier to
maintain. This fixes numerous issues including some test
failures that were hidden because the h2specd_SUITE was
flawed.
We temporarily depend on Cowlib master until a new version
is released.
|
|
|