diff options
author | Loïc Hoguin <[email protected]> | 2019-09-20 12:19:33 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2019-09-22 16:46:35 +0200 |
commit | f75a5416c4979ca26b1fbb8a737def8d01a20c8b (patch) | |
tree | 78443cfad2e8eac2c26f7a153dde9216e4770481 /src/gun_ws.erl | |
parent | 02dd576a837b8b47b1c656c6f4b8769c1aeb4ed0 (diff) | |
download | gun-f75a5416c4979ca26b1fbb8a737def8d01a20c8b.tar.gz gun-f75a5416c4979ca26b1fbb8a737def8d01a20c8b.tar.bz2 gun-f75a5416c4979ca26b1fbb8a737def8d01a20c8b.zip |
Supports going through multiple Socks proxies
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.
Diffstat (limited to 'src/gun_ws.erl')
-rw-r--r-- | src/gun_ws.erl | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/gun_ws.erl b/src/gun_ws.erl index 49911dc..7d65be0 100644 --- a/src/gun_ws.erl +++ b/src/gun_ws.erl @@ -16,7 +16,9 @@ -export([check_options/1]). -export([name/0]). --export([init/9]). +-export([opts_name/0]). +-export([has_keepalive/0]). +-export([init/4]). -export([handle/4]). -export([update_flow/4]). -export([closing/4]). @@ -77,13 +79,15 @@ do_check_options([Opt|_]) -> {error, {options, {ws, Opt}}}. name() -> ws. +opts_name() -> ws_opts. +has_keepalive() -> false. -init(Owner, Socket, Transport, StreamRef, Headers, Extensions, InitialFlow, Handler, Opts) -> - Owner ! {gun_upgrade, self(), StreamRef, [<<"websocket">>], Headers}, +init(Owner, Socket, Transport, #{stream_ref := StreamRef, headers := Headers, + extensions := Extensions, flow := InitialFlow, handler := Handler, opts := Opts}) -> {ok, HandlerState} = Handler:init(Owner, StreamRef, Headers, Opts), - {switch_protocol, ?MODULE, #ws_state{owner=Owner, stream_ref=StreamRef, + #ws_state{owner=Owner, stream_ref=StreamRef, socket=Socket, transport=Transport, opts=Opts, extensions=Extensions, - flow=InitialFlow, handler=Handler, handler_state=HandlerState}}. + flow=InitialFlow, handler=Handler, handler_state=HandlerState}. %% Do not handle anything if we received a close frame. %% Initiate or terminate the closing state depending on whether we sent a close yet. |