Baoyuantop commented on code in PR #12853: URL: https://github.com/apache/apisix/pull/12853#discussion_r2659312607
########## apisix/plugins/brotli.lua: ########## @@ -152,6 +152,30 @@ local function check_accept_encoding(ctx) end +local function weak_etag_header() + local etag = ngx.header.etag + if not etag then + return + end + + local regex = [[^(W/)?"(.*)"$]] + local matched, err = ngx.re.match(etag, regex, "jo") + if not matched then + -- not standard etag, no quote + ngx.header.etag = nil + return + end + + if not matched[1] then + -- strong etag, downgrade it + ngx.header.etag = [[W/"]] .. matched[2] .. [["]] Review Comment: It is recommended to use core.response.set_header to maintain consistent code style. ########## apisix/plugins/brotli.lua: ########## @@ -152,6 +152,30 @@ local function check_accept_encoding(ctx) end +local function weak_etag_header() + local etag = ngx.header.etag + if not etag then + return + end + + local regex = [[^(W/)?"(.*)"$]] + local matched, err = ngx.re.match(etag, regex, "jo") Review Comment: The err variable is declared but never used; if a regular expression match fails, an error should be logged. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
