(52) Empty reply from server
pankajitbhu at gmail.com
Tue Apr 26 11:22:22 UTC 2016
thank you for your input!
I have requirement to create own cookie based on input and wirte the that
cookie in header.
whenever i need that i can read from header and use it.
I have created my own cookie "thissomevalue" worte in header and later the
same read from header.
Please check my code and let me know why i am not able to read the value
Below code snippet to set header value in request header:-
cookie = ngx_list_push(&r->headers_in.headers);
cookie->lowcase_key = (u_char*) "cookie";
cookie->hash = ngx_crc32_long(cookie->lowcase_key, cookie->key.len);
Below code snippet to read set value from header:-
ngx_str_t val = ngx_string("cookie");
clcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
key= ngx_hash_key_lc(val.data, val.len);
type = ngx_hash_find(&clcf->headers_in_hash, key, val.data, val.len);
if (type != NULL)
test_val->lowcase_key = (u_char*) "test_val";
test_val->hash = ngx_crc32_long(test_val->lowcase_key, test_val->key.len);
curl response:-Test_val was accepting "somevalue"
HTTP/1.1 200 OK
Date: Tue, 26 Apr 2016 19:13:40 GMT
Hello, This is Nginx test Module!
On Sat, Apr 23, 2016 at 12:21 AM, Francis Daly <francis at daoine.org> wrote:
> On Thu, Apr 21, 2016 at 01:04:40PM +0530, Pankaj Chaudhary wrote:
> Hi there,
> > yes i am able to write successfully but while reading i am not getting
> > my written value in header.
> > for Example from my source code:-I am writing "thisitestvalue" value
> > against key "Set-Cookie" but if trying to read value against key
> > not getting .
> The curl output you showed included
> cookie: thisitestvalue
> And did not include "Set-Cookie:". Perhaps you were testing different
> code then.
> And if you write in to the headers_out structure, you would need to
> read from the headers_out structure for what you just wrote (except you
> already know what you just wrote, so I'm not sure why you would want to
> read it again).
> If you have copied the example code, and do not get the desired output,
> then presumably either you copied it wrong, or the example code is wrong.
> Francis Daly francis at daoine.org
> nginx mailing list
> nginx at nginx.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the nginx