Welcome! Log In Create A New Profile

Advanced

Re: Add new cookie into headers_in

Maxim Dounin
January 24, 2011 10:40AM
Hello!

On Mon, Jan 24, 2011 at 10:07:04AM -0500, michalkraus wrote:

> Hello,
> I have a filter module in rewrite phase. The module tests if a cookie is
> in the request. If not the module generates one (if cookie is found the
> module modifies it) and then send it back to the client via
> headers_out.
> But I need one more functionality. I want the generated/modified cookie
> to be sent to the proxy module. I have used the headers_more_module for
> this purpose so far and it worked perfectly. I generate an
> $ap_filter_cookie_sid variable in my module that contains the cookie. I
> would like my module to be able to modify headers_in on its own.
> I have managed to modify existing cookie in the headers_in.headers. But
> when no cookie is in headers_in.headers my module is not able to store
> newly generated cookie to headers_in.headers. It seems OK in my module
> but before running proxy module the Nginx stops processing the request.
> When the first request contains a cookie the Nginx server processes it
> correctly and each next request (also withnou cookie) as well. This
> behaviour is a bit confusing and I have no idea how to fix it.

>From architecture point of view, you should never modify
r->headers_in. Instead, you should provide module output as
variable and use proxy_set_header to pass it to backend.

More specifically, modification of r->headers_in will fail and
cause SIGSEGV at least for subrequests even if done perfectly
correctly. Don't do that.

Maxim Dounin

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

Add new cookie into headers_in

michalkraus January 24, 2011 10:07AM

Re: Add new cookie into headers_in

Maxim Dounin January 24, 2011 10:40AM

Re: Add new cookie into headers_in

michalkraus January 25, 2011 03:34AM

Re: Add new cookie into headers_in

Maxim Dounin January 25, 2011 07:58AM

Re: Add new cookie into headers_in

agentzh January 25, 2011 11:38PM

Re: Add new cookie into headers_in

agentzh January 25, 2011 11:50PM

Re: Add new cookie into headers_in

agentzh January 25, 2011 11:56PM

Re: Add new cookie into headers_in

michalkraus January 26, 2011 02:08AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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