Skip to content

Commit

Permalink
Fixed type specs to satisfy dialyzer.
Browse files Browse the repository at this point in the history
  • Loading branch information
maximvl committed Nov 29, 2013
1 parent 3177a4e commit b08985c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/websocket_client.app.src
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{application, websocket_client,
[
{description, "Erlang websocket client"},
{vsn, "0.5.3"},
{vsn, "0.5.4"},
{registered, []},
{applications, [
ssl,
Expand Down
6 changes: 2 additions & 4 deletions src/websocket_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ ws_client_init(Handler, Protocol, Host, Port, Path, Args) ->
websocket_loop(websocket_req:set([{keepalive,KeepAlive},{keepalive_timer,KATimer}], WSReq), HandlerState, <<>>).

%% @doc Send http upgrade request and validate handshake response challenge
-spec websocket_handshake(WSReq :: websocket_req:req()) ->
ok.
-spec websocket_handshake(WSReq :: websocket_req:req()) -> {ok, binary()}.
websocket_handshake(WSReq) ->
[Protocol, Path, Host, Key, Transport, Socket] =
websocket_req:get([protocol, path, host, key, transport, socket], WSReq),
Expand Down Expand Up @@ -220,8 +219,7 @@ generate_ws_key() ->
base64:encode(crypto:rand_bytes(16)).

%% @doc Validate handshake response challenge
-spec validate_handshake(HandshakeResponse :: binary(), Key :: binary()) ->
ok.
-spec validate_handshake(HandshakeResponse :: binary(), Key :: binary()) -> {ok, binary()}.
validate_handshake(HandshakeResponse, Key) ->
Challenge = base64:encode(
crypto:sha(<< Key/binary, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" >>)),
Expand Down
30 changes: 15 additions & 15 deletions src/websocket_req.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
-module(websocket_req).

-record(websocket_req, {
protocol :: protocol(),
host :: string(),
port :: inet:port_number(),
path :: string(),
keepalive = infinity :: integer(),
keepalive_timer = undefined :: reference(),
socket :: inet:socket() | ssl:sslsocket(),
transport :: module(),
handler :: module(),
key :: binary(),
remaining = undefined :: integer(),
fin = undefined :: fin(),
opcode = undefined :: opcode(),
continuation = undefined :: binary(),
continuation_opcode = undefined :: opcode()
protocol :: protocol(),
host :: string(),
port :: inet:port_number(),
path :: string(),
keepalive = infinity :: infinity | integer(),
keepalive_timer = undefined :: undefined | reference(),
socket :: inet:socket() | ssl:sslsocket(),
transport :: module(),
handler :: module(),
key :: binary(),
remaining = undefined :: undefined | integer(),
fin = undefined :: undefined | fin(),
opcode = undefined :: undefined | opcode(),
continuation = undefined :: undefined | binary(),
continuation_opcode = undefined :: undefined | opcode()
}).

-opaque req() :: #websocket_req{}.
Expand Down

0 comments on commit b08985c

Please sign in to comment.