Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore client_max_window_bits with missing header #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/cow_ws.erl
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ negotiate_permessage_deflate1(Params, Extensions, Opts) ->
ignore;
{#{client_max_window_bits := CB}, _} when CB > ClientMaxWindowBits ->
ignore;
{Negotiated, _} when not is_map_key(client_max_window_bits_set, Negotiated), ClientMaxWindowBits < 15 ->
ignore;
{Negotiated, RespParams2} ->
%% We add the configured max window bits if necessary.
RespParams = case Negotiated of
Expand Down Expand Up @@ -165,12 +167,14 @@ negotiate_params([{<<"client_max_window_bits">>, Max}|Tail], Negotiated, RespPar
error ->
ignore;
CB when CB =< CB0 ->
negotiate_params(Tail, Negotiated#{client_max_window_bits => CB},
negotiate_params(Tail,
Negotiated#{client_max_window_bits => CB,
client_max_window_bits_set => true},
[<<"; client_max_window_bits=">>, Max|RespParams]);
%% When the client sends window bits larger than the server wants
%% to use, we use what the server defined.
_ ->
negotiate_params(Tail, Negotiated,
negotiate_params(Tail, Negotiated#{client_max_window_bits_set => true},
[<<"; client_max_window_bits=">>, integer_to_binary(CB0)|RespParams])
end;
negotiate_params([{<<"server_max_window_bits">>, Max}|Tail], Negotiated, RespParams) ->
Expand Down