From 2d88bfa01064188549fa86f07a148f802d0f0d86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 24 Dec 2014 19:13:18 +0200 Subject: 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. --- src/cow_http_hd.erl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/cow_http_hd.erl') diff --git a/src/cow_http_hd.erl b/src/cow_http_hd.erl index 2daff5f..4ce59a2 100644 --- a/src/cow_http_hd.erl +++ b/src/cow_http_hd.erl @@ -34,7 +34,9 @@ -export([parse_if_unmodified_since/1]). -export([parse_last_modified/1]). -export([parse_max_forwards/1]). +-export([parse_sec_websocket_accept/1]). -export([parse_sec_websocket_extensions/1]). +-export([parse_sec_websocket_key/1]). -export([parse_sec_websocket_protocol_client/1]). -export([parse_sec_websocket_version_client/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]. -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. -spec parse_sec_websocket_extensions(binary()) -> [{binary(), [binary() | {binary(), binary()}]}]. @@ -1903,6 +1915,17 @@ horse_parse_sec_websocket_extensions() -> ). -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. -spec parse_sec_websocket_protocol_client(binary()) -> [binary()]. -- cgit v1.2.3