[MINOR] set the expiration date when removing a cookie

It was specified in the documentation that a cookie would be deleted if the
client was switched to a cookie-less server such as a backup server, in
order to avoid stickyness on errors. To achieve this, an empty cookie was
returned. It seems this no longer works (at least with Firefox 1.5 and
Mozilla 1.8a5), because the browser returns the empty cookie. The cookie
specification says that in order to remove a cookie, it must be accompanied
by an expiration date in the past, so this is what we do. Tested on Mozilla
1.8a5, works.
This commit is contained in:
willy tarreau 2006-05-09 23:32:26 +02:00
parent f2b8d30d93
commit 4f7a101265
1 changed files with 3 additions and 2 deletions

View File

@ -4908,11 +4908,12 @@ int process_srv(struct session *t) {
(!(t->proxy->options & PR_O_COOK_POST) || (t->flags & SN_POST))) { (!(t->proxy->options & PR_O_COOK_POST) || (t->flags & SN_POST))) {
/* the server is known, it's not the one the client requested, we have to /* the server is known, it's not the one the client requested, we have to
* insert a set-cookie here, except if we want to insert only on POST * insert a set-cookie here, except if we want to insert only on POST
* requests and this one isn't. * requests and this one isn't. Note that servers which don't have cookies
* (eg: some backup servers) will return a full cookie removal request.
*/ */
len = sprintf(trash, "Set-Cookie: %s=%s; path=/\r\n", len = sprintf(trash, "Set-Cookie: %s=%s; path=/\r\n",
t->proxy->cookie_name, t->proxy->cookie_name,
t->srv->cookie ? t->srv->cookie : ""); t->srv->cookie ? t->srv->cookie : "; Expires=Thu, 01-Jan-1970 00:00:01 GMT");
t->flags |= SN_SCK_INSERTED; t->flags |= SN_SCK_INSERTED;