Skip to content

Conversation

@yuweizzz
Copy link
Contributor

Description

Downgrade etag when in needed.

Which issue(s) this PR fixes:

Fixes #12707

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working plugin labels Dec 31, 2025

if not matched[1] then
-- strong etag, downgrade it
ngx.header.etag = [[W/"]] .. matched[2] .. [["]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is recommended to use core.response.set_header to maintain consistent code style.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @yuweizzz, similar issues exist in other parts of the code; please correct them all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check it again.

end

local regex = [[^(W/)?"(.*)"$]]
local matched, err = ngx.re.match(etag, regex, "jo")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The err variable is declared but never used; if a regular expression match fails, an error should be logged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@Baoyuantop Baoyuantop added the wait for update wait for the author's response in this issue/PR label Jan 4, 2026
@Baoyuantop Baoyuantop added awaiting review and removed wait for update wait for the author's response in this issue/PR labels Jan 5, 2026
@yuweizzz yuweizzz requested a review from Baoyuantop January 5, 2026 10:24
@Baoyuantop Baoyuantop added wait for update wait for the author's response in this issue/PR and removed awaiting review labels Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working plugin size:L This PR changes 100-499 lines, ignoring generated files. wait for update wait for the author's response in this issue/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ETag and Last-Modified headers are not preserved when response is Brotli-compressed

3 participants