(52) Empty reply from server

Pankaj Chaudhary pankajitbhu at gmail.com
Wed Apr 27 07:56:47 UTC 2016


Hi Bart,

thank you for response.

I have referred the /root/Downloads/nginx-1.9.14/src/http/v2 module code.

Below is  that sample code.
static ngx_int_t
ngx_http_v2_parse_authority(ngx_http_request_t *r, ngx_http_v2_header_t
*header)
{
    ngx_table_elt_t            *h;
    ngx_http_header_t          *hh;
    ngx_http_core_main_conf_t  *cmcf;

    static ngx_str_t host = ngx_string("host");

    h = ngx_list_push(&r->headers_in.headers);
    if (h == NULL) {
        return NGX_ERROR;
    }

    h->hash = ngx_hash_key(host.data, host.len);

    h->key.len = host.len;
    h->key.data = host.data;

    h->value.len = header->value.len;
    h->value.data = header->value.data;

    h->lowcase_key = host.data;

    cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);

    hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash,
                       h->lowcase_key, h->key.len);


Best Regards,
Pankaj

On Tue, Apr 26, 2016 at 6:23 PM, Valentin V. Bartenev <vbart at nginx.com>
wrote:

> On Tuesday 26 April 2016 16:52:22 Pankaj Chaudhary wrote:
> > 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.
> >
>
> You shouldn't do that (I believe even in Apache) because it's an expensive
> operation in comparison to just storing the value in local variable.
>
>
> > Please check my code and let me know why i am not able to read the value
> > from header.
>
> Because you write your value in one structure, but try to find it in
> another.
>
> >
> > Below code snippet to set header value in request header:-
> >
> > ngx_table_elt_t *cookie;
> > cookie = ngx_list_push(&r->headers_in.headers);
>
> Here you have inserted your value into header list (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);
> >
>
> Here you are trying to find your value in the static input headers hash
> (clcf->headers_in_hash), that is created in ngx_http_init_headers_in_hash()
> on configuration stage.
>
>   wbr, Valentin V. Bartenev
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20160427/e736c139/attachment.html>


More information about the nginx mailing list