Preserve HTTP request path when routing a request through a component reference.
git-svn-id: https://svn.apache.org/repos/asf/tuscany/sca-cpp/trunk@1052431 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/modules/server/mod-wiring.cpp b/modules/server/mod-wiring.cpp
index 67b179e..e873733 100644
--- a/modules/server/mod-wiring.cpp
+++ b/modules/server/mod-wiring.cpp
@@ -102,10 +102,13 @@
debug(target, "modwiring::translateReference::target");
// Route to an absolute target URI using mod_proxy or an HTTP client redirect
+ const list<value> pathInfo = cdddr(rpath);
if (httpd::isAbsolute(target)) {
if (useModProxy) {
- // Build proxy URI using current request's protocol scheme
- r->filename = apr_pstrdup(r->pool, c_str(string("proxy:") + httpd::scheme(r) + substr(target, find(target, "://"))));
+ // Build proxy URI
+ // current request's protocol scheme, reference target uri and request path info
+ string turi = httpd::scheme(r) + substr(target, find(target, "://")) + path(pathInfo);
+ r->filename = apr_pstrdup(r->pool, c_str(string("proxy:") + turi));
debug(r->filename, "modwiring::translateReference::filename");
r->proxyreq = PROXYREQ_REVERSE;
r->handler = "proxy-server";
@@ -118,7 +121,10 @@
}
// Route to a relative target URI using a local internal redirect
- r->filename = apr_pstrdup(r->pool, c_str(string("/redirect:/components/") + substr(target, 0, find(target, '/'))));
+ // /components/, target component name and request path info
+ const value tname = substr(target, 0, find(target, '/'));
+ const string tpath = path(cons(tname, pathInfo));
+ r->filename = apr_pstrdup(r->pool, c_str(string("/redirect:/components") + tpath));
debug(r->filename, "modwiring::translateReference::filename");
r->handler = "mod_tuscany_wiring";
return OK;