Skip to content

fix: do not invoke add_header if value resolved as nil#10619

Merged
juststillthinking merged 1 commit into
apache:masterfrom
fengxsong:patch-1
Dec 11, 2023
Merged

fix: do not invoke add_header if value resolved as nil#10619
juststillthinking merged 1 commit into
apache:masterfrom
fengxsong:patch-1

Conversation

@fengxsong

Copy link
Copy Markdown
Contributor

Description

If header_value is resolved to nil or empty table, add_header will throw an error https://github.com/openresty/lua-resty-core/blob/master/lib/resty/core/request.lua#L364

It's better to do nothing.

ref: https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/req.md#add_header

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)

@Revolyssup

Copy link
Copy Markdown
Contributor

@fengxsong Can you add some test here?

@fengxsong

Copy link
Copy Markdown
Contributor Author

@fengxsong Can you add some test here?

do we really need test case for this PR?

@Revolyssup

Copy link
Copy Markdown
Contributor

@fengxsong Can you add some test here?

do we really need test case for this PR?

A test case proving that logs have no error log in this condition might be helpful. @Sn0rt Do you have suggestions here?

@juststillthinking

Copy link
Copy Markdown
Contributor

@Revolyssup I think the code is very simple, no test cases is ok

@juststillthinking
juststillthinking merged commit e6afb6f into apache:master Dec 11, 2023
@fengxsong
fengxsong deleted the patch-1 branch December 12, 2023 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants