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

more_headers with eval filter will throw warning of 'uninitialized value $key' #51

Open
zhongjin616 opened this issue Dec 19, 2016 · 0 comments

Comments

@zhongjin616
Copy link

zhongjin616 commented Dec 19, 2016

this is my t directory layout:

└── t
    └── Var
        ├── Conf.pm
    ├── test.t

the content of Conf.pm

package Var::Conf;

use Exporter qw(import);

our @EXPORT_OK = qw(Headers);


our $Headers = q{
Cookie: sessionId=0ca3eafb0a8ffc8146ac0609897d6a24; controlId=7cf98c6218e2f4154ff74b69a6fa3f5d
};

1;

the content of test.t

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

use File::Basename qw(dirname);
use lib dirname(abs_path $0);
use Var::Conf qw(Headers);

$ENV{TEST_NGINX_CODE_PWD} = cwd();

#repeat_each(2);

no_long_string();

run_tests();

__DATA__

=== TEST 1: basic resty test
--- http_config
    init_worker_by_lua_block {
        print("init")
    }

--- config
    location = /t {
        echo ok;
    }

--- more_headers eval: $Var::Conf::Headers

--- request
GET /t
--- response_body
ok

then , run the cmd: prove t/test.t
will give the warning of uninitialized value

Use of uninitialized value $key in lc at /usr/local/share/perl/5.18.2/Test/Nginx/Socket.pm line 301, <DATA> line 1.
Use of uninitialized value $key in concatenation (.) or string at /usr/local/share/perl/5.18.2/Test/Nginx/Socket.pm line 306, <DATA> line 1.
t/test.t .. ok   
All tests successful.
Files=1, Tests=2,  0 wallclock secs ( 0.02 usr  0.01 sys +  0.18 cusr  0.04 csys =  0.25 CPU)
Result: PASS

if i replace the --- more_headers eval: $Var::Conf::Headers in test.t, with

--- more_headers
    Cookie: sessionId=0ca3eafb0a8ffc8146ac0609897d6a24; controlId=7cf98c6218e2f4154ff74b69a6fa3f5d

the warning message gone.

============================================
OS: Ubuntu 14.04
Test:Nginx v0.25

perl -v give me this:

This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-linux-gnu-thread-multi

nginx -v output:

nginx version: openresty/1.9.7.4
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