Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case insensitive response_headers #126

Open
jloh opened this issue Oct 8, 2021 · 0 comments
Open

Case insensitive response_headers #126

jloh opened this issue Oct 8, 2021 · 0 comments

Comments

@jloh
Copy link

jloh commented Oct 8, 2021

Hi all, thanks for the fantastic framework!

I recently ran into an issue where I've been testing to make sure a specific set of headers are not sent on some responses but it turns out the negative header matching this test suite does is case sensitive. You can replicate it using this below test case:

use Test::Nginx::Socket 'no_plan';
use Cwd qw(cwd);

my $pwd = cwd();

our $HttpConfig = qq{
    lua_package_path "$pwd/lib/?.lua;;";
};

no_long_string();
no_diff();
run_tests();

__DATA__
=== TEST 1: header case matters
--- http_config eval
"$::HttpConfig"
--- config
    location /t {
        content_by_lua_block {
            ngx.header["X-Powered-By"] = "hello"
            ngx.header["via"] = "server-1"
            ngx.say("OK")
        }
    }
--- request
GET /t
--- no_error_log
[error]
--- response_headers
! x-powered-by

I would expect this test to fail since x-powered-by is sent on the response, its just under X-Powered-By. Is there a flag I can enable to make sure these matches are case insensitive? Note that replacing ! x-powered-by with ! X-Powered-By does cause the test to fail since it matches a header on the response.

I tried doing something like this:

--- response_headers_filter
lc

But it appears response_headers_filter isn't a thing, only response_body_filter which is understandable.

Any help would be fantastic, thanks in advance!

jloh added a commit to jloh/test-nginx that referenced this issue Oct 8, 2021
refs openresty#126

- This likely isn't a full proper fix in itself but it does fix my use case!
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

No branches or pull requests

1 participant