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
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,
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... */
*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!
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;
(*balancer)->s = bshared;
- return NULL;
+ return ap_proxy_update_balancer(p, *balancer, alias);
}
/*