openresty / lua-resty-core

New FFI-based API for lua-nginx-module
792 stars 270 forks source link

bugfix: request headers contains "_" should be case-insensitive matched. #419

Closed vm-001 closed 1 year ago

vm-001 commented 1 year ago

I hereby granted the copyright of the changes in this pull request to the authors of this lua-resty-core project.

Fix a bug that request header contains "_" unable to be case-insensitive matched. e.g.

-- Request with headers:
-- X_Foo_Header: foo

local value = ngx.req.get_headers()["X_Foo_Header"]  -- nil
zhuizhuhaomeng commented 1 year ago

@vm-001 you have removed spaces that should not be removed

vm-001 commented 1 year ago

@zhuizhuhaomeng Ops, Looks like the IntelliJ IDEA is not intelligent at this moment. Fixed.

vm-001 commented 1 year ago

@zhuizhuhaomeng I think the CI failure is not caused by the PR because I also found a similar failure in another empty PR(https://app.travis-ci.com/github/openresty/lua-resty-core/builds/260795767)

vm-001 commented 1 year ago

Hi @zhuizhuhaomeng , May I know can this PR be merged?

zhuizhuhaomeng commented 1 year ago

@vm-001 The CI ran failed. Please rebase to the latest master branch code.

zhuizhuhaomeng commented 1 year ago

https://app.travis-ci.com/github/openresty/lua-resty-core/builds/261234448#L575 The CI failed. Please have a look at this one.

vm-001 commented 1 year ago

https://app.travis-ci.com/github/openresty/lua-resty-core/builds/261234448#L575 The CI failed. Please have a look at this one.

Thanks for the reminder. I've fixed the test fails. But I saw the CI still fails, have no idea what's wrong.

zhuizhuhaomeng commented 1 year ago

This is still needed.

value = rawget(tb, (str_replace_char(key, '_', '-')))
vm-001 commented 1 year ago

@zhuizhuhaomeng Yeah. I found the suggestion applied on the wrong line. I've made another suggestion to correct that.

zhuizhuhaomeng commented 1 year ago

add the following code to the top of the file

local str_find = string.find