Welcome! Log In Create A New Profile

Advanced

Re: (52) Empty reply from server

All files from this thread

File Name File Size   Posted by Date  
image.png 122.1 KB open | download pankajitbhu 05/02/2016 Read message
April 26, 2016 07:24AM
Hi Francis,

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.


for example:-

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
from header.

Below code snippet to set header value in request header:-

ngx_table_elt_t *cookie;
cookie = ngx_list_push(&r->headers_in.headers);
cookie->lowcase_key = (u_char*) "cookie";
ngx_str_set(&cookie->key, "Cookie");
ngx_str_set(&cookie->value, "somevalue");
cookie->hash = ngx_crc32_long(cookie->lowcase_key, cookie->key.len);


Below code snippet to read set value from header:-

ngx_http_core_main_conf_t *clcf;
ngx_str_t *type;
ngx_uint_t key;
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)
{
ngx_table_elt_t *test_val;
test_val= ngx_list_push(&r->headers_out.headers);
test_val->lowcase_key = (u_char*) "test_val";
ngx_str_set(&test_val->key, "Test_Val");
ngx_str_set(&test_val->value, type->data);
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
Server: nginx/1.9.12
Date: Tue, 26 Apr 2016 19:13:40 GMT
Content-Type: text/plain
Content-Length: 34
Connection: keep-alive
Test_Val: Cookie

Hello, This is Nginx test Module!



On Sat, Apr 23, 2016 at 12:21 AM, Francis Daly <francis@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
> the
> > 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
> "Set-Cookie"
> > 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.
>
> f
> --
> Francis Daly francis@daoine.org
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

(52) Empty reply from server

Pankaj Chaudhary April 14, 2016 06:06AM

Re: (52) Empty reply from server

Francis Daly April 14, 2016 12:56PM

Re: (52) Empty reply from server

pankajitbhu April 14, 2016 02:08PM

Re: (52) Empty reply from server

Francis Daly April 14, 2016 05:14PM

Re: (52) Empty reply from server

pankajitbhu April 15, 2016 03:50AM

Re: (52) Empty reply from server

pankajitbhu April 18, 2016 06:56AM

Re: (52) Empty reply from server

Francis Daly April 18, 2016 07:36PM

Re: (52) Empty reply from server

pankajitbhu April 19, 2016 06:22AM

Re: (52) Empty reply from server

Francis Daly April 19, 2016 01:44PM

Re: (52) Empty reply from server

pankajitbhu April 20, 2016 03:26AM

Re: (52) Empty reply from server

Francis Daly April 20, 2016 03:40PM

Re: (52) Empty reply from server

pankajitbhu April 21, 2016 03:36AM

Re: (52) Empty reply from server

Francis Daly April 22, 2016 02:54PM

Re: (52) Empty reply from server

pankajitbhu April 26, 2016 07:24AM

Re: (52) Empty reply from server

Valentin V. Bartenev April 26, 2016 08:54AM

Re: (52) Empty reply from server

pankajitbhu April 27, 2016 03:58AM

Re: (52) Empty reply from server

Valentin V. Bartenev April 27, 2016 11:40AM

Re: (52) Empty reply from server

pankajitbhu April 27, 2016 12:22PM

Re: (52) Empty reply from server

Valentin V. Bartenev May 04, 2016 09:48AM

Re: (52) Empty reply from server

pankajitbhu May 05, 2016 01:00AM

Re: (52) Empty reply from server

Valentin V. Bartenev May 05, 2016 10:04AM

Re: (52) Empty reply from server

pankajitbhu May 09, 2016 05:06AM

Re: (52) Empty reply from server

Francis Daly May 10, 2016 04:48PM

Re: (52) Empty reply from server

pankajitbhu May 11, 2016 02:50AM

Re: (52) Empty reply from server

Francis Daly April 28, 2016 03:12AM

Re: (52) Empty reply from server Attachments

pankajitbhu May 02, 2016 03:14AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 195
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready