Browse Source

Add dummy functions for Sec-WebSocket-(Accept|Key) headers

From RFC6455.

These base64 values are expected to be matched directly in the
first case, or hashed to generate a new base64 value, therefore
no parsing or validation is required.
Loïc Hoguin 10 years ago
parent
commit
2d88bfa010
1 changed files with 23 additions and 0 deletions
  1. 23 0
      src/cow_http_hd.erl

+ 23 - 0
src/cow_http_hd.erl

@@ -34,7 +34,9 @@
 -export([parse_if_unmodified_since/1]).
 -export([parse_if_unmodified_since/1]).
 -export([parse_last_modified/1]).
 -export([parse_last_modified/1]).
 -export([parse_max_forwards/1]).
 -export([parse_max_forwards/1]).
+-export([parse_sec_websocket_accept/1]).
 -export([parse_sec_websocket_extensions/1]).
 -export([parse_sec_websocket_extensions/1]).
+-export([parse_sec_websocket_key/1]).
 -export([parse_sec_websocket_protocol_client/1]).
 -export([parse_sec_websocket_protocol_client/1]).
 -export([parse_sec_websocket_version_client/1]).
 -export([parse_sec_websocket_version_client/1]).
 -export([parse_te/1]).
 -export([parse_te/1]).
@@ -1792,6 +1794,16 @@ parse_max_forwards_error_test_() ->
 	[{V, fun() -> {'EXIT', _} = (catch parse_content_length(V)) end} || V <- Tests].
 	[{V, fun() -> {'EXIT', _} = (catch parse_content_length(V)) end} || V <- Tests].
 -endif.
 -endif.
 
 
+%% @doc Dummy parsing function for the Sec-WebSocket-Accept header.
+%%
+%% The argument is returned without any processing. This value is
+%% expected to be matched directly by the client so no parsing is
+%% needed.
+
+-spec parse_sec_websocket_accept(binary()) -> binary().
+parse_sec_websocket_accept(SecWebSocketAccept) ->
+	SecWebSocketAccept.
+
 %% @doc Parse the Sec-WebSocket-Extensions request header.
 %% @doc Parse the Sec-WebSocket-Extensions request header.
 
 
 -spec parse_sec_websocket_extensions(binary()) -> [{binary(), [binary() | {binary(), binary()}]}].
 -spec parse_sec_websocket_extensions(binary()) -> [{binary(), [binary() | {binary(), binary()}]}].
@@ -1903,6 +1915,17 @@ horse_parse_sec_websocket_extensions() ->
 	).
 	).
 -endif.
 -endif.
 
 
+%% @doc Dummy parsing function for the Sec-WebSocket-Key header.
+%%
+%% The argument is returned without any processing. This value is
+%% expected to be prepended to a static value, the result of which
+%% hashed to form a new base64 value returned in Sec-WebSocket-Accept,
+%% therefore no parsing is needed.
+
+-spec parse_sec_websocket_key(binary()) -> binary().
+parse_sec_websocket_key(SecWebSocketKey) ->
+	SecWebSocketKey.
+
 %% @doc Parse the Sec-WebSocket-Protocol request header.
 %% @doc Parse the Sec-WebSocket-Protocol request header.
 
 
 -spec parse_sec_websocket_protocol_client(binary()) -> [binary()].
 -spec parse_sec_websocket_protocol_client(binary()) -> [binary()].