]> granicus.if.org Git - apache/commitdiff
Pull this out as a sep function to allow for full vhosting
authorJim Jagielski <jim@apache.org>
Mon, 28 Nov 2011 20:11:44 +0000 (20:11 +0000)
committerJim Jagielski <jim@apache.org>
Mon, 28 Nov 2011 20:11:44 +0000 (20:11 +0000)
adjustment between get and define balancers...

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1207562 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy.h
modules/proxy/proxy_util.c

index 234bfed0885360ff9bbb5a892832d28941382919..6ac8dc88fa715a3f5bfe3d02310a4a62f7e73f8c 100644 (file)
@@ -644,6 +644,17 @@ PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
                                                       proxy_server_conf *conf,
                                                       const char *url);
 
+/**
+ * Update the balancer's vhost related fields
+ * @param p     memory pool used for temporary storage while finding balancer
+ * @param balancer  balancer to be updated
+ * @param url   url to find vhost info
+ * @return      error string or NULL if OK
+ */
+PROXY_DECLARE(char *) ap_proxy_update_balancer(apr_pool_t *p,
+                                               proxy_balancer *balancer,
+                                               const char *url);
+
 /**
  * Define and Allocate space for the balancer to proxy configuration
  * @param p      memory pool to allocate balancer from
index a89a8db233627a486156fa3b9056632b7f31d92a..6ae1253937f665b86b0440934a91efcfb396c95a 100644 (file)
@@ -1316,6 +1316,26 @@ PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
     return NULL;
 }
 
+
+PROXY_DECLARE(char *) ap_proxy_update_balancer(apr_pool_t *p,
+                                                proxy_balancer *balancer,
+                                                const char *url)
+{
+    apr_uri_t puri;
+    if (apr_uri_parse(p, url, &puri) != APR_SUCCESS) {
+        return apr_psprintf(p, "unable to parse: %s", url);
+    }
+    if (puri.path && PROXY_STRNCPY(balancer->s->vpath, puri.path) != APR_SUCCESS) {
+        return apr_psprintf(p, "balancer %s front-end virtual-path (%s) too long",
+                            balancer->s->name, puri.path);
+    }
+    if (puri.hostname && PROXY_STRNCPY(balancer->s->vhost, puri.hostname) != APR_SUCCESS) {
+        return apr_psprintf(p, "balancer %s front-end vhost name (%s) too long",
+                            balancer->s->name, puri.hostname);
+    }
+    return NULL;
+}
+
 PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,
                                                proxy_balancer **balancer,
                                                proxy_server_conf *conf,
@@ -1329,7 +1349,6 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,
     proxy_balancer_shared *bshared;
     char *c, *q, *uri = apr_pstrdup(p, url);
     const char *sname;
-    apr_uri_t puri;
 
     /* We should never get here without a valid BALANCER_PREFIX... */
 
@@ -1344,8 +1363,6 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,
     *balancer = apr_array_push(conf->balancers);
     memset(*balancer, 0, sizeof(proxy_balancer));
 
-    apr_uri_parse(p, alias, &puri);
-
     /*
      * NOTE: The default method is byrequests, which we assume
      * exists!
@@ -1378,9 +1395,6 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,
     if (PROXY_STRNCPY(bshared->sname, sname) != APR_SUCCESS) {
         return apr_psprintf(p, "balancer safe-name (%s) too long", sname);
     }
-    if (PROXY_STRNCPY(bshared->vpath, puri.path) != APR_SUCCESS) {
-        return apr_psprintf(p, "balancer front-end virtual-path (%s) too long", puri.path);
-    }
     bshared->hash = ap_proxy_hashfunc(bshared->name, PROXY_HASHFUNC_DEFAULT);    
     (*balancer)->hash = bshared->hash;
 
@@ -1394,7 +1408,7 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,
 
     (*balancer)->s = bshared;
 
-    return NULL;
+    return ap_proxy_update_balancer(p, *balancer, alias);
 }
 
 /*