This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 94576ef3f perf: optimized gzip code logic (#8897)
94576ef3f is described below
commit 94576ef3f3a69aa5a181e8a972f44ab4d8959915
Author: jackfu <[email protected]>
AuthorDate: Fri Feb 24 09:37:53 2023 +0800
perf: optimized gzip code logic (#8897)
---
apisix/plugins/gzip.lua | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/apisix/plugins/gzip.lua b/apisix/plugins/gzip.lua
index d9f319d01..8720cfe9f 100644
--- a/apisix/plugins/gzip.lua
+++ b/apisix/plugins/gzip.lua
@@ -112,24 +112,24 @@ function _M.header_filter(conf, ctx)
-- Like Nginx, don't gzip if Content-Type is missing
return
end
- local from = core.string.find(content_type, ";")
- if from then
- content_type = str_sub(content_type, 1, from - 1)
- end
- local matched = false
if type(types) == "table" then
+ local matched = false
+ local from = core.string.find(content_type, ";")
+ if from then
+ content_type = str_sub(content_type, 1, from - 1)
+ end
+
for _, ty in ipairs(types) do
if content_type == ty then
matched = true
break
end
end
- else
- matched = true
- end
- if not matched then
- return
+
+ if not matched then
+ return
+ end
end
local content_length = tonumber(ngx_header["Content-Length"])