Skip to content
This repository was archived by the owner on Nov 16, 2020. It is now read-only.

Commit 318ba1d

Browse files
committed
allow websocket compression extension
1 parent 64adcef commit 318ba1d

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

priv/schema/rabbitmq_web_stomp.schema

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,5 @@
7777
[{datatype, integer}]}.
7878
{mapping, "web_stomp.cowboy_opts.timeout", "rabbitmq_web_stomp.cowboy_opts.timeout",
7979
[{datatype, integer}]}.
80+
{mapping, "web_stomp.cowboy_opts.compress", "rabbitmq_web_stomp.cowboy_ws_opts.compress",
81+
[{datatype, {enum, [true, false]}}]}.

src/rabbit_ws_handler.erl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ init(Req0, Opts) ->
5252
undefined -> [];
5353
AuthHd -> [{authorization, binary_to_list(AuthHd)}]
5454
end,
55-
{cowboy_websocket, Req, {Socket, Peername, Sockname, Headers, FrameType}}.
55+
{_, WsOpts} = lists:keyfind(ws_opts, 1, Opts),
56+
{cowboy_websocket, Req, {Socket, Peername, Sockname, Headers, FrameType}, WsOpts}.
5657

5758
websocket_init({Socket, Peername, Sockname, Headers, FrameType}) ->
5859
Info = [{socket, Socket},

src/rabbit_ws_listener.erl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ init() ->
3434

3535
WsFrame = get_env(ws_frame, text),
3636
CowboyOpts = maps:from_list(get_env(cowboy_opts, [])),
37+
CowboyWsOpts = maps:from_list(get_env(cowboy_ws_opts, [])),
3738

3839
VhostRoutes = [
39-
{get_env(ws_path, "/ws"), rabbit_ws_handler, [{type, WsFrame}]}
40+
{get_env(ws_path, "/ws"), rabbit_ws_handler, [{type, WsFrame}, {ws_opts, CowboyWsOpts}]}
4041
],
4142
Routes = cowboy_router:compile([{'_', VhostRoutes}]), % any vhost
4243
NumTcpAcceptors = case application:get_env(rabbitmq_web_stomp, num_tcp_acceptors) of

0 commit comments

Comments
 (0)