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

fix(brotli-plugin): Skip brotli compression for upstream compressed response #10740

Merged
merged 12 commits into from
Jan 12, 2024
5 changes: 5 additions & 0 deletions apisix/plugins/brotli.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ function _M.header_filter(conf, ctx)
return
end

local content_encoded = ngx_header["Content-Encoding"]
if content_encoded then
-- Don't compress if Content-Encoding is present in upstream data
return
end
local types = conf.types
local content_type = ngx_header["Content-Type"]
if not content_type then
Expand Down
6 changes: 6 additions & 0 deletions docs/en/latest/plugins/brotli.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ sudo sh -c "echo /usr/local/brotli/lib >> /etc/ld.so.conf.d/brotli.conf"
sudo ldconfig
```

:::caution

If the upstream is returning compressed response, than brotli plugin won't be able to compress.

:::

## Attributes

| Name | Type | Required | Default | Valid values | Description |
Expand Down