[asterisk-commits] kpfleming: branch 1.4 r99001 - /branches/1.4/main/manager.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 17 15:31:56 CST 2008


Author: kpfleming
Date: Thu Jan 17 15:31:56 2008
New Revision: 99001

URL: http://svn.digium.com/view/asterisk?view=rev&rev=99001
Log:
we should only send the Set-Cookie header to the browser on the first response after creating a manager session, not on every response (doing so causes the browser to clear any local cookies it may have associated with the session)

Modified:
    branches/1.4/main/manager.c

Modified: branches/1.4/main/manager.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/manager.c?view=diff&rev=99001&r1=99000&r2=99001
==============================================================================
--- branches/1.4/main/manager.c (original)
+++ branches/1.4/main/manager.c Thu Jan 17 15:31:56 2008
@@ -2639,6 +2639,7 @@
 	char *c = workspace;
 	char *retval = NULL;
 	struct ast_variable *v;
+	unsigned int new_session = 0;
 
 	for (v = params; v; v = v->next) {
 		if (!strcasecmp(v->name, "mansession_id")) {
@@ -2670,6 +2671,7 @@
 		ast_atomic_fetchadd_int(&s->eventq->usecount, 1);
 		ast_atomic_fetchadd_int(&num_sessions, 1);
 		AST_LIST_UNLOCK(&sessions);
+		new_session = 1;
 	}
 
 	/* Reset HTTP timeout.  If we're not yet authenticated, keep it extremely short */
@@ -2710,8 +2712,10 @@
 			s->needdestroy = 1;
 		}
 		ast_build_string(&c, &len, "Content-type: text/%s\r\n", contenttype[format]);
-		sprintf(tmp, "%08lx", s->managerid);
-		ast_build_string(&c, &len, "%s\r\n", ast_http_setcookie("mansession_id", tmp, httptimeout, cookie, sizeof(cookie)));
+		if (new_session) {
+			sprintf(tmp, "%08lx", s->managerid);
+			ast_build_string(&c, &len, "%s\r\n", ast_http_setcookie("mansession_id", tmp, httptimeout, cookie, sizeof(cookie)));
+		}
 		if (format == FORMAT_HTML)
 			ast_build_string(&c, &len, "<title>Asterisk&trade; Manager Interface</title>");
 		if (format == FORMAT_XML) {




More information about the asterisk-commits mailing list