diff options
-rw-r--r-- | src/gun.erl | 3 | ||||
-rw-r--r-- | src/gun_http.erl | 8 | ||||
-rw-r--r-- | src/gun_spdy.erl | 2 | ||||
-rw-r--r-- | src/gun_ws.erl | 5 |
4 files changed, 12 insertions, 6 deletions
diff --git a/src/gun.erl b/src/gun.erl index 074b121..5d564a5 100644 --- a/src/gun.erl +++ b/src/gun.erl @@ -90,7 +90,8 @@ -type spdy_opts() :: map(). -export_type([spdy_opts/0]). --type ws_opts() :: [{compress, boolean()}]. +-type ws_opts() :: map(). +-export_type([ws_opts/0]). -record(state, { parent :: pid(), diff --git a/src/gun_http.erl b/src/gun_http.erl index d6a69d1..6e65341 100644 --- a/src/gun_http.erl +++ b/src/gun_http.erl @@ -29,7 +29,7 @@ -type io() :: head | {body, non_neg_integer()} | body_close | body_chunked. --type websocket_info() :: {websocket, reference(), binary(), [], []}. %% key, extensions, protocols +-type websocket_info() :: {websocket, reference(), binary(), [binary()], [], gun:ws_opts()}. %% key, extensions, protocols, options -record(http_state, { owner :: pid(), @@ -47,6 +47,8 @@ check_options(Opts) -> do_check_options(maps:to_list(Opts)). +do_check_options([]) -> + ok; do_check_options([{keepalive, K}|Opts]) when is_integer(K), K > 0 -> do_check_options(Opts); do_check_options([{version, V}|Opts]) when V =:= 'HTTP/1.1'; V =:= 'HTTP/1.0' -> @@ -152,7 +154,7 @@ handle_head(Data, State=#http_state{owner=Owner, version=ClientVersion, ok; true -> StreamRef2 = case StreamRef of - {websocket, SR, _, _, _} -> SR; + {websocket, SR, _, _, _, _} -> SR; _ -> StreamRef end, Owner ! {gun_response, self(), StreamRef2, @@ -293,7 +295,7 @@ cancel(State, StreamRef) -> %% HTTP does not provide any way to figure out what streams are unprocessed. down(#http_state{streams=Streams}) -> KilledStreams = [case Ref of - {websocket, Ref2, _, _, _} -> Ref2; + {websocket, Ref2, _, _, _, _} -> Ref2; _ -> Ref end || {Ref, _} <- Streams], {KilledStreams, []}. diff --git a/src/gun_spdy.erl b/src/gun_spdy.erl index c417e78..9a7d493 100644 --- a/src/gun_spdy.erl +++ b/src/gun_spdy.erl @@ -49,6 +49,8 @@ check_options(Opts) -> do_check_options(maps:to_list(Opts)). +do_check_options([]) -> + ok; do_check_options([{keepalive, K}|Opts]) when is_integer(K), K > 0 -> do_check_options(Opts); do_check_options([Opt|_]) -> diff --git a/src/gun_ws.erl b/src/gun_ws.erl index 246cc57..9e35fa6 100644 --- a/src/gun_ws.erl +++ b/src/gun_ws.erl @@ -112,8 +112,9 @@ dispatch(Rest, State=#ws_state{owner=Owner, frag_state=FragState, frag_buffer=So close(Reason, State) -> case Reason of - Normal when Normal =:= stop; Normal =:= timeout -> - send({close, 1000, <<>>}, State); +%% @todo We need to send a close frame from gun:ws_loop on close. +% Normal when Normal =:= stop; Normal =:= timeout -> +% send({close, 1000, <<>>}, State); {error, badframe} -> send({close, 1002, <<>>}, State); {error, badencoding} -> |