From 145b9af4bdbb85e2f83959ee8abaa4d9207a4529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 27 Jul 2019 16:53:26 +0200 Subject: Fix ssl and other types --- doc/src/manual/gun.asciidoc | 4 ++-- src/gun.erl | 7 ++++--- src/gun_event.erl | 2 +- src/gun_tcp.erl | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/src/manual/gun.asciidoc b/doc/src/manual/gun.asciidoc index f8d5406..da5548b 100644 --- a/doc/src/manual/gun.asciidoc +++ b/doc/src/manual/gun.asciidoc @@ -98,7 +98,7 @@ connect_destination() :: #{ protocols => [http | http2], transport => tcp | tls, - tls_opts => [ssl:connect_option()], + tls_opts => [ssl:tls_client_option()], tls_handshake_timeout => timeout() } ---- @@ -213,7 +213,7 @@ opts() :: #{ supervise => boolean(), tcp_opts => [gen_tcp:connect_option()], tls_handshake_timeout => timeout(), - tls_opts => [ssl:connect_option()], + tls_opts => [ssl:tls_client_option()], trace => boolean(), transport => tcp | tls, ws_opts => ws_opts() diff --git a/src/gun.erl b/src/gun.erl index 74866ec..d758ffc 100644 --- a/src/gun.erl +++ b/src/gun.erl @@ -104,9 +104,11 @@ -export_type([req_headers/0]). -type ws_close_code() :: 1000..4999. + -type ws_frame() :: close | ping | pong | {text | binary | close | ping | pong, iodata()} | {close, ws_close_code(), iodata()}. +-export_type([ws_frame/0]). -type opts() :: #{ connect_timeout => timeout(), @@ -122,7 +124,7 @@ supervise => boolean(), tcp_opts => [gen_tcp:connect_option()], tls_handshake_timeout => timeout(), - tls_opts => [ssl:connect_option()], + tls_opts => [ssl:tls_client_option()], trace => boolean(), transport => tcp | tls | ssl, ws_opts => ws_opts() @@ -138,7 +140,7 @@ protocol => http | http2, %% @todo Remove in Gun 2.0. protocols => [http | http2], transport => tcp | tls, - tls_opts => [ssl:connect_option()], + tls_opts => [ssl:tls_client_option()], tls_handshake_timeout => timeout() }. -export_type([connect_destination/0]). @@ -771,7 +773,6 @@ init({Owner, Host, Port, Opts}) -> default_transport(443) -> tls; default_transport(_) -> tcp. -%% @todo This is where we would implement the backoff mechanism presumably. not_connected(_, {retries, 0, Reason}, State) -> {stop, {shutdown, Reason}, State}; not_connected(_, {retries, Retries0, _}, State=#state{opts=Opts}) -> diff --git a/src/gun_event.erl b/src/gun_event.erl index 3520c79..1e158c4 100644 --- a/src/gun_event.erl +++ b/src/gun_event.erl @@ -65,7 +65,7 @@ stream_ref => reference(), reply_to => pid(), socket := inet:socket() | ssl:sslsocket() | pid(), %% The socket before/after will be different. - tls_opts := [ssl:connect_option()], + tls_opts := [ssl:tls_client_option()], timeout := timeout(), protocol => http | http2, error => any() diff --git a/src/gun_tcp.erl b/src/gun_tcp.erl index 615e925..a4f9e96 100644 --- a/src/gun_tcp.erl +++ b/src/gun_tcp.erl @@ -41,7 +41,7 @@ messages() -> {tcp, tcp_closed, tcp_error}. %% and the actual connect step. -spec domain_lookup(inet:ip_address() | inet:hostname(), - inet:port_number(), [gen_tcp:connect_option()] | [ssl:connect_option()], timeout()) + inet:port_number(), [gen_tcp:connect_option()], timeout()) -> {ok, lookup_info()} | {error, atom()}. domain_lookup(Address, Port0, Opts0, Timeout) -> {Mod, Opts} = inet:tcp_module(Opts0, Address), -- cgit v1.2.3