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

i can't get ngx.var.http_cookie #10

Closed
luoqi opened this issue Jan 6, 2011 · 4 comments
Closed

i can't get ngx.var.http_cookie #10

luoqi opened this issue Jan 6, 2011 · 4 comments

Comments

@luoqi
Copy link

luoqi commented Jan 6, 2011

--conf/test.lua
ngx.print(ngx.var.content_type);--error
ngx.print(ngx.var.http_cookie);--error
ngx.print(ngx.var.remote_addr);--success

不知道什么原因,请指教!

@luoqi
Copy link
Author

luoqi commented Jan 6, 2011

请教,我这样,取不到信息:
location /test {
content_by_lua_file conf/test.lua;
}

--conf/test.lua
ngx.print(ngx.var.content_type);--error
ngx.print(ngx.var.http_cookie);--error
ngx.print(ngx.var.remote_addr);--success

不知道什么原因,请指教!

@luoqi
Copy link
Author

luoqi commented Jan 7, 2011

我发现了,原来,ngx.var.http_cookie=null;

@chaoslawful
Copy link
Contributor

贴一下实际的http请求头,有http-cookie或content-type这种header的内容么?你不用ngx_lua直接输出$http_cookie、$content_type、$remote_addr变量的值有内容么?

@luoqi
Copy link
Author

luoqi commented Jan 7, 2011

我用echo模块,可以输出$http_cookie、$content_type,但是空的,
用ngx.print就不行了,可能是,ngx.print不能输出null值。
当我设置ngx.header.cookie="hello!";后,再ngx.print(ngx.var.http_cookie);就正确了。
所以,后来,我在使用过程中,都这样写local cookie=ngx.var.http_cookie or '';或,先判断一下if cookie then ... end

@cs0604 cs0604 mentioned this issue Sep 6, 2013
bungle added a commit to bungle/lua-nginx-module that referenced this issue Jan 15, 2017
bungle added a commit to bungle/lua-nginx-module that referenced this issue Jan 15, 2017
zhuizhuhaomeng pushed a commit that referenced this issue Oct 19, 2021
==openresty==70603==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x621000001500,0x621000002181) and [0x62100000187f, 0x621000002500) overlap
    #0 0x7f3db1899ffe  (/lib64/libasan.so.5+0x99ffe)
    #1 0x9da926  (/usr/local/openresty-debug/nginx/sbin/nginx+0x9da926)
    #2 0x9dd1a1  (/usr/local/openresty-debug/nginx/sbin/nginx+0x9dd1a1)
    #3 0x4c89c6  (/usr/local/openresty-debug/nginx/sbin/nginx+0x4c89c6)
    #4 0x5d1e4e  (/usr/local/openresty-debug/nginx/sbin/nginx+0x5d1e4e)
    #5 0x4c89c6  (/usr/local/openresty-debug/nginx/sbin/nginx+0x4c89c6)
    #6 0x5b8583  (/usr/local/openresty-debug/nginx/sbin/nginx+0x5b8583)
    #7 0x4c89c6  (/usr/local/openresty-debug/nginx/sbin/nginx+0x4c89c6)
    #8 0x4b4419  (/usr/local/openresty-debug/nginx/sbin/nginx+0x4b4419)
    #9 0x427f16  (/usr/local/openresty-debug/nginx/sbin/nginx+0x427f16)
    #10 0x7f3daff27554  (/lib64/libc.so.6+0x22554)
    #11 0x42d537  (/usr/local/openresty-debug/nginx/sbin/nginx+0x42d537)
This issue was closed.
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

2 participants