Michael Ellery
November 01, 2013 12:42PM
devs,

I'm looking for advice about how to properly clear a cookie value from the current request so that it will be omitted
from the request when it goes upstream (to proxy). Here's the code I currently have:

static ngx_str_t my_cookie_name = ngx_string("MyMagicCookieName");


ngx_uint_t i;
ngx_table_elt_t **h;
ngx_str_t null_header_value = ngx_null_string;
h = r->headers_in.cookies.elts;
for (i = 0; i < r->headers_in.cookies.nelts; i++) {
if (h[i]->value.len > my_cookie_name.len &&
0 == ngx_strncmp(h[i]->value.data, my_cookie_name.data, my_cookie_name.len))
{
h[i]->value = null_header_value;
break;
}
}


my main concern is leaking memory -- will the nulling of this value cause memory to be leaked? If so, how can I fix this?

A secondary concern is that I believe value can actually contain a list of comma separated of cookie name/vals, although
I've not actually encountered that problem so far. What would be the right way to wipe out only PART of the value data,
if that's indeed what I need to do?

Thanks,
Mike Ellery

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

how to clear a cookie value in request object

Michael Ellery 869 November 01, 2013 12:42PM

Re: how to clear a cookie value in request object

Maxim Dounin 352 November 01, 2013 07:42PM

Re: how to clear a cookie value in request object

Mike Ellery 776 November 02, 2013 02:06PM

Re: how to clear a cookie value in request object

Maxim Dounin 484 November 04, 2013 04:58PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 176
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