From: helge Date: Mon, 21 Aug 2006 11:06:07 +0000 (+0000) Subject: added ability to forward requests to other hosts X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1bd5bdc1151224f7dba8a35c84a108c8ac2d15c7;p=sope added ability to forward requests to other hosts git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1345 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/mod_ngobjweb/ChangeLog b/sope-appserver/mod_ngobjweb/ChangeLog index e457e4ac..c1d3e64b 100644 --- a/sope-appserver/mod_ngobjweb/ChangeLog +++ b/sope-appserver/mod_ngobjweb/ChangeLog @@ -1,3 +1,8 @@ +2006-08-21 Helge Hess + + * handler.c: added ability to forward app requests to other hosts + (using IP:port syntax) + 2005-10-04 Helge Hess * GNUmakefile: add APR include dirs if apr-config can be found (this is diff --git a/sope-appserver/mod_ngobjweb/handler.c b/sope-appserver/mod_ngobjweb/handler.c index 1476b29a..ab9a4aed 100644 --- a/sope-appserver/mod_ngobjweb/handler.c +++ b/sope-appserver/mod_ngobjweb/handler.c @@ -336,14 +336,26 @@ int ngobjweb_handler(request_rec *r) { } else { struct sockaddr_in *snsi; - char *host; + char *host, *pos; int port; - host = "127.0.0.1"; - port = atoi(cfg->appPort); - - //ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, - // "appPort: '%s', cfg 0x%08X", cfg->appPort, cfg); + if ((pos = index(cfg->appPort, ':'))) { + host = apr_palloc(r->pool, (pos - cfg->appPort) + 3); + strncpy(host, cfg->appPort, (pos - cfg->appPort)); + host[pos - cfg->appPort] = '\0'; + + port = atoi(pos + 1); + } + else { + host = "127.0.0.1"; + port = atoi(cfg->appPort); + } + +#if HEAVY_LOG + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, + "appPort: '%s' host: %s port %d, cfg 0x%p", + cfg->appPort, host, port, cfg); +#endif addressLen = sizeof(struct sockaddr_in); address = apr_palloc(r->pool, sizeof(struct sockaddr_in)); @@ -357,7 +369,7 @@ int ngobjweb_handler(request_rec *r) { if (snsi->sin_addr.s_addr == -1) { ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, - "couldn't convert snsd IP address: %s", host); + "could not convert IP address: %s", host); } if (HEAVY_LOG && 0) { ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server,