summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/http
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-07-12 15:19:11 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-07-12 15:19:11 +0000
commit20a36196a7aad4f863dbc4969ff648bcbc187a02 (patch)
tree2de4b641ea30bd3793c0d82d381f8f1ec6eacdfc /sca-cpp/trunk/modules/http
parent95a926c827a1f4316c0f9c822e0b6003da78bb12 (diff)
Add a host component property reporting the current virtual host name.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@963318 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/http')
-rw-r--r--sca-cpp/trunk/modules/http/httpd.hpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/sca-cpp/trunk/modules/http/httpd.hpp b/sca-cpp/trunk/modules/http/httpd.hpp
index 05403a5897..486bc7fa82 100644
--- a/sca-cpp/trunk/modules/http/httpd.hpp
+++ b/sca-cpp/trunk/modules/http/httpd.hpp
@@ -77,10 +77,10 @@ template<typename C> C& serverConf(const cmd_parms *cmd, const module* mod) {
/**
* Return the name of a server.
*/
-const string serverName(const server_rec* s) {
+const string serverName(const server_rec* s, const string& def = "localhost") {
ostringstream n;
n << (s->server_scheme != NULL? s->server_scheme : "http") << "://"
- << (s->server_hostname != NULL? s->server_hostname : "localhost") << ":"
+ << (s->server_hostname != NULL? s->server_hostname : def) << ":"
<< (s->port != 0? s->port : 80)
<< (s->path != NULL? string(s->path, s->pathlen) : "");
return str(n);
@@ -89,11 +89,11 @@ const string serverName(const server_rec* s) {
/**
* Determine the name of a server from an HTTP request.
*/
-const string serverName(request_rec* r) {
+const string serverName(request_rec* r, const string& def = "localhost") {
ostringstream n;
const char* hn = ap_get_server_name(r);
n << (r->server->server_scheme != NULL? r->server->server_scheme : "http") << "://"
- << (hn != NULL? hn : (r->server->server_hostname != NULL? r->server->server_hostname : "localhost")) << ":"
+ << (hn != NULL? hn : (r->server->server_hostname != NULL? r->server->server_hostname : def)) << ":"
<< (r->server->port != 0? r->server->port : 80)
<< (r->server->path != NULL? string(r->server->path, r->server->pathlen) : "");
return str(n);
@@ -102,16 +102,16 @@ const string serverName(request_rec* r) {
/**
* Return the host name for a server.
*/
-const string hostName(const server_rec* s) {
- return s->server_hostname != NULL? s->server_hostname : "localhost";
+const string hostName(const server_rec* s, const string& def = "localhost") {
+ return s->server_hostname != NULL? s->server_hostname : def;
}
/**
* Return the host name from an HTTP request.
*/
-const string hostName(request_rec* r) {
+const string hostName(request_rec* r, const string& def = "localhost") {
const char* hn = ap_get_server_name(r);
- return hn != NULL? hn : (r->server->server_hostname != NULL? r->server->server_hostname : "localhost");
+ return hn != NULL? hn : (r->server->server_hostname != NULL? r->server->server_hostname : def);
}
/**