mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Ignore malformed accept-encoding headers in cowboy_compress_h
This commit is contained in:
parent
aa1a7d09f3
commit
3b85b808ae
2 changed files with 24 additions and 2 deletions
|
@ -71,9 +71,10 @@ early_error(StreamID, Reason, PartialReq, Resp, Opts) ->
|
|||
%% Internal.
|
||||
|
||||
%% Check if the client supports decoding of gzip responses.
|
||||
%%
|
||||
%% A malformed accept-encoding header is ignored (no compression).
|
||||
check_req(Req) ->
|
||||
%% @todo Probably shouldn't unconditionally crash on failure.
|
||||
case cowboy_req:parse_header(<<"accept-encoding">>, Req) of
|
||||
try cowboy_req:parse_header(<<"accept-encoding">>, Req) of
|
||||
%% Client doesn't support any compression algorithm.
|
||||
undefined ->
|
||||
#state{compress=undefined};
|
||||
|
@ -87,6 +88,9 @@ check_req(Req) ->
|
|||
_ ->
|
||||
#state{compress=gzip}
|
||||
end
|
||||
catch
|
||||
_:_ ->
|
||||
#state{compress=undefined}
|
||||
end.
|
||||
|
||||
%% Do not compress responses that contain the content-encoding header.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue