Extend init resp to include server ID, bug #3231
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 26 Jan 2010 12:09:57 +0000 (13:09 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 26 Jan 2010 12:09:57 +0000 (13:09 +0100)
src/http_command.c
src/pazpar2_config.c
src/pazpar2_config.h

index e3981b2..e3a290f 100644 (file)
@@ -297,8 +297,16 @@ static void cmd_init(struct http_channel *c)
     s->session_id = sesid;
     if (process_settings(s->psession, c->request, c->response) < 0)
         return;
-    sprintf(buf, HTTP_COMMAND_RESPONSE_PREFIX "<init><status>OK</status><session>%u</session>"
-            "<protocol>" PAZPAR2_PROTOCOL_VERSION "</protocol></init>", sesid);
+    
+    sprintf(buf, HTTP_COMMAND_RESPONSE_PREFIX 
+            "<init><status>OK</status><session>%u", sesid);
+    if (c->server->server_id)
+    {
+        strcat(buf, ".");
+        strcat(buf, c->server->server_id);
+    }
+    strcat(buf, "</session>"
+           "<protocol>" PAZPAR2_PROTOCOL_VERSION "</protocol></init>");
     rs->payload = nmem_strdup(c->nmem, buf);
     http_send_response(c);
 }
index 62e57f8..0771c2c 100644 (file)
@@ -722,6 +722,12 @@ static struct conf_server *server_create(struct conf_config *config,
     server->mergekey_pct = 0;
     server->server_settings = 0;
 
+    xmlChar *server_id = xmlGetProp(node, (xmlChar *) "id");
+    if (server_id)
+        server->server_id = nmem_strdup(nmem, (const char *)server_id);
+    else
+        server->server_id = 0;
+
     for (n = node->children; n; n = n->next)
     {
         if (n->type != XML_ELEMENT_NODE)
index 65ea5cc..9b57167 100644 (file)
@@ -135,6 +135,7 @@ struct conf_server
     struct sockaddr_in *proxy_addr;
     int listener_socket;
     char *server_settings;
+    char *server_id;
 
     pp2_charset_t relevance_pct;
     pp2_charset_t sort_pct;