diff options
Diffstat (limited to 'sca-cpp/trunk/modules/http')
-rw-r--r-- | sca-cpp/trunk/modules/http/Makefile.am | 6 | ||||
-rwxr-xr-x | sca-cpp/trunk/modules/http/http-test | 4 | ||||
-rwxr-xr-x | sca-cpp/trunk/modules/http/httpd-conf | 1 | ||||
-rwxr-xr-x | sca-cpp/trunk/modules/http/httpd-restart | 25 | ||||
-rwxr-xr-x | sca-cpp/trunk/modules/http/httpd-start | 25 | ||||
-rwxr-xr-x | sca-cpp/trunk/modules/http/httpd-stop | 25 | ||||
-rwxr-xr-x | sca-cpp/trunk/modules/http/httpd-test | 4 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/http/httpd.hpp | 34 |
8 files changed, 108 insertions, 16 deletions
diff --git a/sca-cpp/trunk/modules/http/Makefile.am b/sca-cpp/trunk/modules/http/Makefile.am index 0e1364747c..b522113423 100644 --- a/sca-cpp/trunk/modules/http/Makefile.am +++ b/sca-cpp/trunk/modules/http/Makefile.am @@ -19,7 +19,13 @@ noinst_PROGRAMS = curl-test INCLUDES = -I${HTTPD_INCLUDE} +httpdir=$(prefix)/modules/http +http_DATA = httpd.prefix + curl_test_SOURCES = curl-test.cpp curl_test_LDFLAGS = -lxml2 -lcurl -lmozjs +httpd.prefix: $(top_builddir)/config.status + echo ${HTTPD_PREFIX} >httpd.prefix + TESTS = httpd-test http-test diff --git a/sca-cpp/trunk/modules/http/http-test b/sca-cpp/trunk/modules/http/http-test index bf6230aec8..9f65b37eec 100755 --- a/sca-cpp/trunk/modules/http/http-test +++ b/sca-cpp/trunk/modules/http/http-test @@ -19,7 +19,7 @@ # Setup ./httpd-conf tmp 8090 htdocs -apachectl -k start -d `pwd`/tmp +./httpd-start tmp sleep 2 # Test @@ -27,6 +27,6 @@ sleep 2 rc=$? # Cleanup -apachectl -k stop -d `pwd`/tmp +./httpd-stop tmp sleep 2 return $rc diff --git a/sca-cpp/trunk/modules/http/httpd-conf b/sca-cpp/trunk/modules/http/httpd-conf index 686bfbcec7..434040803d 100755 --- a/sca-cpp/trunk/modules/http/httpd-conf +++ b/sca-cpp/trunk/modules/http/httpd-conf @@ -27,6 +27,7 @@ mkdir -p $root mkdir -p $root/logs mkdir -p $root/conf cat >$root/conf/httpd.conf <<EOF +ErrorLog $root/logs/error_log ServerName http://127.0.0.1:$port Listen $port DocumentRoot $htdocs diff --git a/sca-cpp/trunk/modules/http/httpd-restart b/sca-cpp/trunk/modules/http/httpd-restart new file mode 100755 index 0000000000..92f27eb0df --- /dev/null +++ b/sca-cpp/trunk/modules/http/httpd-restart @@ -0,0 +1,25 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Restart httpd server +here=`readlink -f $0`; here=`dirname $here` +root=`readlink -f $1` + +httpd_prefix=`cat $here/httpd.prefix` +$httpd_prefix/bin/apachectl -k graceful -d $root diff --git a/sca-cpp/trunk/modules/http/httpd-start b/sca-cpp/trunk/modules/http/httpd-start new file mode 100755 index 0000000000..91fc5284af --- /dev/null +++ b/sca-cpp/trunk/modules/http/httpd-start @@ -0,0 +1,25 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Start httpd server +here=`readlink -f $0`; here=`dirname $here` +root=`readlink -f $1` + +httpd_prefix=`cat $here/httpd.prefix` +$httpd_prefix/bin/apachectl -E $root/logs/error_log -k start -d $root diff --git a/sca-cpp/trunk/modules/http/httpd-stop b/sca-cpp/trunk/modules/http/httpd-stop new file mode 100755 index 0000000000..7f4fe94629 --- /dev/null +++ b/sca-cpp/trunk/modules/http/httpd-stop @@ -0,0 +1,25 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Stop httpd server +here=`readlink -f $0`; here=`dirname $here` +root=`readlink -f $1` + +httpd_prefix=`cat $here/httpd.prefix` +$httpd_prefix/bin/apachectl -k graceful-stop -d $root diff --git a/sca-cpp/trunk/modules/http/httpd-test b/sca-cpp/trunk/modules/http/httpd-test index 762c4c7f6b..952a58937a 100755 --- a/sca-cpp/trunk/modules/http/httpd-test +++ b/sca-cpp/trunk/modules/http/httpd-test @@ -21,7 +21,7 @@ echo "Testing..." # Setup ./httpd-conf tmp 8090 htdocs -apachectl -k start -d `pwd`/tmp +./httpd-start tmp sleep 2 # Test HTTP GET @@ -30,7 +30,7 @@ diff tmp/index.html htdocs/index.html rc=$? # Cleanup -apachectl -k stop -d `pwd`/tmp +./httpd-stop tmp sleep 2 if [ "$rc" = "0" ]; then echo "OK" diff --git a/sca-cpp/trunk/modules/http/httpd.hpp b/sca-cpp/trunk/modules/http/httpd.hpp index 43e75bf769..6b08c3b838 100644 --- a/sca-cpp/trunk/modules/http/httpd.hpp +++ b/sca-cpp/trunk/modules/http/httpd.hpp @@ -42,7 +42,7 @@ #include "util_script.h" #include "util_md5.h" #include "http_config.h" - +#include "ap_mpm.h" #include "mod_core.h" #include "string.hpp" @@ -65,21 +65,14 @@ 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); +template<typename C> C& serverConf(const server_rec* s, const module* mod) { + return *(C*)ap_get_module_config(s->module_config, mod); } - -/** - * Returns a directory-scoped module configuration. - */ -template<typename C> void *makeDirConf(apr_pool_t *p, char *dirspec) { - return new (gc_new<C>(p)) C(dirspec); +template<typename C> C& serverConf(const cmd_parms *cmd, const module* mod) { + return *(C*)ap_get_module_config(cmd->server->module_config, mod); } -template<typename C> C& dirConf(const request_rec* r, const module* mod) { - return *(C*)ap_get_module_config(r->per_dir_config, mod); -} /** * Convert a path string to a list of values. @@ -404,6 +397,23 @@ const int internalRedirect(const string& uri, request_rec* r) { return httpd::internalRedirect(content(nr)); } +/** + * Put a value in the process user data. + */ +const bool putUserData(const string& k, const int v, const server_rec* s) { + apr_pool_userdata_set((const void *)v, c_str(k), apr_pool_cleanup_null, s->process->pool); + return true; +} + +/** + * Return a user data value. + */ +const int userData(const string& k, const server_rec* s) { + void* v = (int)0; + apr_pool_userdata_get(&v, c_str(k), s->process->pool); + return (int)v; +} + } } |