diff options
Diffstat (limited to '')
-rwxr-xr-x | sca-cpp/trunk/modules/http/http-test | 4 | ||||
-rwxr-xr-x | sca-cpp/trunk/modules/http/httpd-conf | 2 | ||||
-rwxr-xr-x | sca-cpp/trunk/modules/http/httpd-test | 4 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/http/httpd.hpp | 26 |
4 files changed, 26 insertions, 10 deletions
diff --git a/sca-cpp/trunk/modules/http/http-test b/sca-cpp/trunk/modules/http/http-test index 0aaaec48df..bf6230aec8 100755 --- a/sca-cpp/trunk/modules/http/http-test +++ b/sca-cpp/trunk/modules/http/http-test @@ -20,7 +20,7 @@ # Setup ./httpd-conf tmp 8090 htdocs apachectl -k start -d `pwd`/tmp -sleep 1 +sleep 2 # Test ./curl-test @@ -28,5 +28,5 @@ rc=$? # Cleanup apachectl -k stop -d `pwd`/tmp -sleep 1 +sleep 2 return $rc diff --git a/sca-cpp/trunk/modules/http/httpd-conf b/sca-cpp/trunk/modules/http/httpd-conf index b00ee06ed3..686bfbcec7 100755 --- a/sca-cpp/trunk/modules/http/httpd-conf +++ b/sca-cpp/trunk/modules/http/httpd-conf @@ -27,7 +27,7 @@ mkdir -p $root mkdir -p $root/logs mkdir -p $root/conf cat >$root/conf/httpd.conf <<EOF -ServerName 127.0.0.1 +ServerName http://127.0.0.1:$port Listen $port DocumentRoot $htdocs TypesConfig $here/conf/mime.types diff --git a/sca-cpp/trunk/modules/http/httpd-test b/sca-cpp/trunk/modules/http/httpd-test index 8e1d681d84..762c4c7f6b 100755 --- a/sca-cpp/trunk/modules/http/httpd-test +++ b/sca-cpp/trunk/modules/http/httpd-test @@ -22,7 +22,7 @@ echo "Testing..." # Setup ./httpd-conf tmp 8090 htdocs apachectl -k start -d `pwd`/tmp -sleep 1 +sleep 2 # Test HTTP GET curl http://localhost:8090/index.html 2>/dev/null >tmp/index.html @@ -31,7 +31,7 @@ rc=$? # Cleanup apachectl -k stop -d `pwd`/tmp -sleep 1 +sleep 2 if [ "$rc" = "0" ]; then echo "OK" fi diff --git a/sca-cpp/trunk/modules/http/httpd.hpp b/sca-cpp/trunk/modules/http/httpd.hpp index 05b959f1d2..890fee8f01 100644 --- a/sca-cpp/trunk/modules/http/httpd.hpp +++ b/sca-cpp/trunk/modules/http/httpd.hpp @@ -69,6 +69,11 @@ template<typename C> const C& serverConf(const request_rec* r, const module* mod return *(C*)ap_get_module_config(r->server->module_config, mod); } +template<typename C> C& serverConf(const cmd_parms *cmd, const module* mod) { + return *(C*)ap_get_module_config(cmd->server->module_config, mod); +} + + /** * Returns a directory-scoped module configuration. */ @@ -88,7 +93,9 @@ template<typename C> C& dirConf(const request_rec* r, const module* mod) { const list<std::string> pathTokens(const char* p) { if (p == NULL || p[0] == '\0') return list<std::string>(); - return tokenize("/", p + 1); + if (p[0] == '/') + return tokenize("/", p + 1); + return tokenize("/", p); } const list<value> pathValues(const list<std::string>& l) { @@ -107,7 +114,7 @@ const list<value> path(const char* p) { const std::string path(const list<value>& p) { if (isNil(p)) return ""; - return "/" + car(p) + path(cdr(p)); + return std::string("/") + std::string(car(p)) + path(cdr(p)); } /** @@ -141,11 +148,11 @@ const bool debugRequest(request_rec* r, const std::string& msg) { std::cerr << " content type: " << contentType(r) << std::endl; std::cerr << " content encoding: " << optional(r->content_encoding) << std::endl; apr_table_do(debugHeader, r, r->headers_in, NULL); - std::cerr << " uri: " << optional(r->unparsed_uri) << std::endl; - std::cerr << " path: " << optional(r->uri) << std::endl; + std::cerr << " unparsed uri: " << optional(r->unparsed_uri) << std::endl; + std::cerr << " uri: " << optional(r->uri) << std::endl; std::cerr << " path info: " << optional(r->path_info) << std::endl; std::cerr << " filename: " << optional(r->filename) << std::endl; - std::cerr << " path tokens: " << pathTokens(r->uri) << std::endl; + std::cerr << " uri tokens: " << pathTokens(r->uri) << std::endl; std::cerr << " args: " << optional(r->args) << std::endl; return true; } @@ -159,6 +166,15 @@ const bool debugRequest(request_rec* r, const std::string& msg) { #endif /** + * Return the remaining part of a uri after the given path (aka the path info.) + */ +const list<value> pathInfo(const list<value>& uri, const list<value>& path) { + if (isNil(path)) + return uri; + return pathInfo(cdr(uri), cdr(path)); +} + +/** * Returns a list of key value pairs from the args in a query string. */ const list<value> queryArg(const std::string& s) { |