0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 04:10:24 +00:00

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.
This commit is contained in:
Loïc Hoguin 2017-11-01 15:41:52 +00:00
parent 83bd8bc935
commit 5e88a9b394
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
3 changed files with 9 additions and 5 deletions

View file

@ -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

View file

@ -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]}.

View file

@ -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).