in modules/server/mod-eval.hpp [1117:1173]
int translate(request_rec *r) {
if(r->method_number != M_GET && r->method_number != M_POST && r->method_number != M_PUT && r->method_number != M_PATCH && r->method_number != M_DELETE)
return DECLINED;
const gc_scoped_pool sp(r->pool);
debug_httpdRequest(r, "modeval::translate::input");
// Get the server configuration
const ServerConf& sc = httpd::serverConf<ServerConf>(r, &mod_tuscany_eval);
// Parse the request path
const list<value> rpath = pathValues(r->uri);
// Let default handler handle a resource request
const string prefix = isNull(rpath)? emptyStringValue : car(rpath);
if (prefix == string("vhosts") || prefix == string("v"))
return DECLINED;
// Get the request configuration
RequestConf& reqc = httpd::requestConf<RequestConf>(r, &mod_tuscany_eval);
// If the request is targeting a virtual host, configure the components
// in that virtual host
if (length(sc.vhostc.domain) != 0 && (length(sc.vhostc.contribPath) != 0 || !isNull(sc.vhostc.contributor)) && httpd::isVhostRequest(sc.server, sc.vhostc.domain, r)) {
const string vname = http::subDomain(httpd::hostName(r));
const failable<Composite> fvcompos = confComponents(sc.vhostc.contribPath, sc.vhostc.composName, sc.vhostc.contributor, vname, reqc.impls, (value)sc.lifecycle, sc.sslc, sc.timeout);
if (!hasContent(fvcompos))
return DECLINED;
const Composite vcompos = content(fvcompos);
// Flag the request as virtual host based
reqc.vhost = true;
// Translate the request
reqc.impls = vcompos.impls;
return translateRequest(r, rpath, mklist<value>(vname), vcompos.refs, vcompos.svcs, reqc.impls);
}
// Translate a request targeting the main host
const int rc = translateRequest(r, rpath, nilListValue, sc.compos.refs, sc.compos.svcs, sc.compos.impls);
if (rc != HTTP_NOT_FOUND)
return rc;
// Attempt to map the first segment of the request path to a virtual host
if (length(prefix) != 0 && (length(sc.vhostc.contribPath) != 0 || !isNull(sc.vhostc.contributor))) {
const string vname = prefix;
const failable<Composite> fvcompos = confComponents(sc.vhostc.contribPath, sc.vhostc.composName, sc.vhostc.contributor, vname, reqc.impls, (value)sc.lifecycle, sc.sslc, sc.timeout);
if (!hasContent(fvcompos))
return DECLINED;
const Composite vcompos = content(fvcompos);
// Translate the request
reqc.impls = vcompos.impls;
return translateRequest(r, cdr(rpath), mklist<value>(vname), vcompos.refs, vcompos.svcs, reqc.impls);
}
return DECLINED;
}