test-nginx icon indicating copy to clipboard operation
test-nginx copied to clipboard

Case insensitive `response_headers`

Open jloh opened this issue 4 years ago • 0 comments

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 avatar Oct 08 '21 01:10 jloh

@bixuelantian It is usually the machine code frames emitted by LuaJIT's JIT compiler (assuming your LuaJIT build has debug symbols).

agentzh avatar Feb 04 '19 06:02 agentzh