]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
we should only send the Set-Cookie header to the browser on the first response after...
authorKevin P. Fleming <kpfleming@digium.com>
Thu, 17 Jan 2008 21:31:56 +0000 (21:31 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Thu, 17 Jan 2008 21:31:56 +0000 (21:31 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@99001 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/manager.c

index 8e3309667546f3ecf01d339e165371de928c62d2..1b1687408671a5e4bcde9885ab88ebe20591b47a 100644 (file)
@@ -2639,6 +2639,7 @@ static char *generic_http_callback(int format, struct sockaddr_in *requestor, co
        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 @@ static char *generic_http_callback(int format, struct sockaddr_in *requestor, co
                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 @@ static char *generic_http_callback(int format, struct sockaddr_in *requestor, co
                        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) {