aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_websocket.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-11-01 15:41:52 +0000
committerLoïc Hoguin <[email protected]>2017-11-01 15:41:52 +0000
commit5e88a9b394a2ae966ba95efadbf1cc24d060b457 (patch)
tree5cd26214ac0b584ec34b058020b26ef398a7f01c /src/cowboy_websocket.erl
parent83bd8bc935cbbba39c8c706a1f7d5a6e9ac932ef (diff)
downloadcowboy-5e88a9b394a2ae966ba95efadbf1cc24d060b457.tar.gz
cowboy-5e88a9b394a2ae966ba95efadbf1cc24d060b457.tar.bz2
cowboy-5e88a9b394a2ae966ba95efadbf1cc24d060b457.zip
Update Cowlib to 2.0.1 and fix OTP 20.1+ Websocket compression
Unfortunately compression will be disabled for 20.1, 20.1.1 and 20.1.2. In additiona I do not recommend 20.1.3 due to issues inflating some specific sizes.
Diffstat (limited to 'src/cowboy_websocket.erl')
-rw-r--r--src/cowboy_websocket.erl8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cowboy_websocket.erl b/src/cowboy_websocket.erl
index 3ec9f9a..d38c673 100644
--- a/src/cowboy_websocket.erl
+++ b/src/cowboy_websocket.erl
@@ -144,23 +144,27 @@ websocket_extensions(State=#state{extensions=Extensions}, Req=#{pid := Pid},
[{<<"permessage-deflate">>, Params}|Tail], RespHeader) ->
%% @todo Make deflate options configurable.
Opts = #{level => best_compression, mem_level => 8, strategy => default},
- case cow_ws:negotiate_permessage_deflate(Params, Extensions, Opts#{owner => Pid}) of
+ try cow_ws:negotiate_permessage_deflate(Params, Extensions, Opts#{owner => Pid}) of
{ok, RespExt, Extensions2} ->
websocket_extensions(State#state{extensions=Extensions2},
Req, Tail, [<<", ">>, RespExt|RespHeader]);
ignore ->
websocket_extensions(State, Req, Tail, RespHeader)
+ catch exit:{error, incompatible_zlib_version, _} ->
+ websocket_extensions(State, Req, Tail, RespHeader)
end;
websocket_extensions(State=#state{extensions=Extensions}, Req=#{pid := Pid},
[{<<"x-webkit-deflate-frame">>, Params}|Tail], RespHeader) ->
%% @todo Make deflate options configurable.
Opts = #{level => best_compression, mem_level => 8, strategy => default},
- case cow_ws:negotiate_x_webkit_deflate_frame(Params, Extensions, Opts#{owner => Pid}) of
+ try cow_ws:negotiate_x_webkit_deflate_frame(Params, Extensions, Opts#{owner => Pid}) of
{ok, RespExt, Extensions2} ->
websocket_extensions(State#state{extensions=Extensions2},
Req, Tail, [<<", ">>, RespExt|RespHeader]);
ignore ->
websocket_extensions(State, Req, Tail, RespHeader)
+ catch exit:{error, incompatible_zlib_version, _} ->
+ websocket_extensions(State, Req, Tail, RespHeader)
end;
websocket_extensions(State, Req, [_|Tail], RespHeader) ->
websocket_extensions(State, Req, Tail, RespHeader).