diff options
author | Loïc Hoguin <[email protected]> | 2017-11-01 15:41:52 +0000 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2017-11-01 15:41:52 +0000 |
commit | 5e88a9b394a2ae966ba95efadbf1cc24d060b457 (patch) | |
tree | 5cd26214ac0b584ec34b058020b26ef398a7f01c | |
parent | 83bd8bc935cbbba39c8c706a1f7d5a6e9ac932ef (diff) | |
download | cowboy-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.
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | rebar.config | 2 | ||||
-rw-r--r-- | src/cowboy_websocket.erl | 8 |
3 files changed, 9 insertions, 5 deletions
@@ -11,7 +11,7 @@ COMPILE_FIRST = cowboy_middleware cowboy_stream cowboy_sub_protocol PLT_APPS = public_key ssl CT_OPTS += -ct_hooks cowboy_ct_hook [] # -boot start_sasl -CI_OTP ?= OTP-19.0.7 OTP-19.1.6 OTP-19.2.3 OTP-19.3.6.3 OTP-20.0.5 OTP-20.1.2 +CI_OTP ?= OTP-19.0.7 OTP-19.1.6 OTP-19.2.3 OTP-19.3.6.3 OTP-20.0.5 OTP-20.1.3 CI_HIPE ?= $(lastword $(CI_OTP)) # CI_ERLLVM ?= $(CI_HIPE) @@ -20,7 +20,7 @@ CI_HIPE ?= $(lastword $(CI_OTP)) LOCAL_DEPS = crypto DEPS = cowlib ranch -dep_cowlib = git https://github.com/ninenines/cowlib 2.0.0 +dep_cowlib = git https://github.com/ninenines/cowlib 2.0.1 dep_ranch = git https://github.com/ninenines/ranch 1.4.0 DOC_DEPS = asciideck diff --git a/rebar.config b/rebar.config index ed819b7..101f012 100644 --- a/rebar.config +++ b/rebar.config @@ -1,4 +1,4 @@ {deps, [ -{cowlib,".*",{git,"https://github.com/ninenines/cowlib","2.0.0"}},{ranch,".*",{git,"https://github.com/ninenines/ranch","1.4.0"}} +{cowlib,".*",{git,"https://github.com/ninenines/cowlib","2.0.1"}},{ranch,".*",{git,"https://github.com/ninenines/ranch","1.4.0"}} ]}. {erl_opts, [debug_info,warn_export_vars,warn_shadow_vars,warn_obsolete_guard,warn_export_all,warn_missing_spec,warn_untyped_record]}. 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). |