using host header to select virtual server

Wed, 28 Dec 2016 12:23:51 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 28 Dec 2016 12:23:51 +0100
changeset 138
06619bbd14ef
parent 137
ca0cf1016a8b
child 139
29ac9aed4889

using host header to select virtual server

src/server/daemon/httprequest.c file | annotate | diff | comparison | revisions
--- a/src/server/daemon/httprequest.c	Tue Dec 27 19:50:20 2016 +0100
+++ b/src/server/daemon/httprequest.c	Wed Dec 28 12:23:51 2016 +0100
@@ -117,7 +117,7 @@
     } else {
         io = sysstream_new(pool, request->connection->fd);
     }
-     sn->sn.csd = httpstream_new(pool, io);
+    sn->sn.csd = httpstream_new(pool, io);
     
     
     sn->sn.client = pblock_create_pool(sn->sn.pool, 8);
@@ -299,6 +299,18 @@
     }
     rq->port = request->connection->listener->port;
     
+    if(rq->host) {
+        VirtualServer *vs = ucx_map_cstr_get(sn->config->host_vs, rq->host);
+        if(vs) {
+            rq->vs = vs;
+        } else {
+            log_ereport(
+                    LOG_VERBOSE,
+                    "Unkown host '%s': using default virtual server", 
+                    rq->host);
+        }
+    }
+    
     // parse connection header
     rq->rq.rq_attr.keep_alive = (rq->rq.protv_num >= PROTOCOL_VERSION_HTTP11);
     char *conn_str = pblock_findkeyval(pb_key_connection, rq->rq.headers);

mercurial