Return-Path: Delivered-To: apmail-httpd-apreq-cvs-archive@www.apache.org Received: (qmail 86838 invoked from network); 28 Feb 2005 06:51:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 28 Feb 2005 06:51:10 -0000 Received: (qmail 59042 invoked by uid 500); 28 Feb 2005 06:51:10 -0000 Delivered-To: apmail-httpd-apreq-cvs-archive@httpd.apache.org Received: (qmail 59024 invoked by uid 500); 28 Feb 2005 06:51:10 -0000 Mailing-List: contact apreq-cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: apreq-dev@httpd.apache.org List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list apreq-cvs@httpd.apache.org Received: (qmail 59009 invoked by uid 99); 28 Feb 2005 06:51:10 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sun, 27 Feb 2005 22:51:09 -0800 Received: (qmail 86822 invoked by uid 65534); 28 Feb 2005 06:51:08 -0000 Message-ID: <20050228065108.86820.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Mon, 28 Feb 2005 06:51:08 -0000 Subject: svn commit: r155672 - in httpd/apreq/branches/multi-env-unstable: acinclude.m4 configure.ac module/Makefile.am module/apache/ module/apache/Makefile.am module/apache/apreq_module_apache.h module/apache/apreq_private_apache.h module/apache/command.c module/apache/handle.c module/apache2/Makefile.am To: apreq-cvs@httpd.apache.org From: joes@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: joes Date: Sun Feb 27 22:51:05 2005 New Revision: 155672 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D155672 Log: Add basic layout for experimental apache 1.3.x module. Added: httpd/apreq/branches/multi-env-unstable/module/apache/ (with props) httpd/apreq/branches/multi-env-unstable/module/apache/Makefile.am httpd/apreq/branches/multi-env-unstable/module/apache/apreq_module_apac= he.h httpd/apreq/branches/multi-env-unstable/module/apache/apreq_private_apa= che.h httpd/apreq/branches/multi-env-unstable/module/apache/command.c httpd/apreq/branches/multi-env-unstable/module/apache/handle.c Modified: httpd/apreq/branches/multi-env-unstable/acinclude.m4 httpd/apreq/branches/multi-env-unstable/configure.ac httpd/apreq/branches/multi-env-unstable/module/Makefile.am httpd/apreq/branches/multi-env-unstable/module/apache2/Makefile.am Modified: httpd/apreq/branches/multi-env-unstable/acinclude.m4 URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/= acinclude.m4?view=3Ddiff&r1=3D155671&r2=3D155672 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- httpd/apreq/branches/multi-env-unstable/acinclude.m4 (original) +++ httpd/apreq/branches/multi-env-unstable/acinclude.m4 Sun Feb 27 22:51:0= 5 2005 @@ -24,6 +24,9 @@ AC_ARG_WITH(apu-config, AC_HELP_STRING([ --with-apu-config],[path to apu-*-config= script]), [APU_CONFIG=3D$withval],[APU_CONFIG=3D""]) + AC_ARG_WITH(apache1-apxs, + AC_HELP_STRING([--with-apache1-apxs],[path to apxs]), + [APACHE1_APXS=3D$withval],[APACHE1_APXS=3D""]) =20 prereq_check=3D"$PERL build/version_check.pl" =20 @@ -131,6 +134,7 @@ AM_CONDITIONAL(BUILD_HTTPD, test -n "$APACHE2_SRC") AM_CONDITIONAL(BUILD_APR, test "x$APR_CONFIG" =3D x`$APR_CONFIG --= srcdir`/apr-config) AM_CONDITIONAL(BUILD_APU, test "x$APU_CONFIG" =3D x`$APU_CONFIG --= srcdir`/apu-config) + AM_CONDITIONAL(HAVE_APACHE1, test -n "$APACHE1_APXS") =20 dnl Reset the default installation prefix to be the same as apu's ac_default_prefix=3D`$APU_CONFIG --prefix` @@ -157,32 +161,19 @@ fi =20 if test "x$USE_MAINTAINER_MODE" !=3D "xno"; then - CPPFLAGS=3D"$CPPFLAGS -Wall -Wmissing-prototypes -Wstrict-prot= otypes -Wmissing-declarations -Werror" - if test "$GCC" =3D "yes"; then - CPPFLAGS=3D"$CPPFLAGS -Wwrite-strings -Wcast-qual -Wfloat-= equal -Wshadow -Wpointer-arith -Wbad-function-cast -Wsign-compare -Waggrega= te-return -Wmissing-noreturn -Wmissing-format-attribute -Wpacked -Wredundan= t-decls -Wnested-externs -Wdisabled-optimization -Wno-long-long -Wendif-lab= els -Wcast-align -Wpacked" + APR_ADDTO([CFLAGS],[ + -Werror -Wall -Wmissing-prototypes -Wstrict-prototyp= es + -Wmissing-declarations -Wwrite-strings -Wcast-qual + -Wfloat-equal -Wshadow -Wpointer-arith + -Wbad-function-cast -Wsign-compare -Waggregate-return + -Wmissing-noreturn -Wmissing-format-attribute -Wpack= ed + -Wredundant-decls -Wnested-externs -Wdisabled-optimi= zation + -Wno-long-long -Wendif-labels -Wcast-align -Wpacked + ]) # -Wdeclaration-after-statement is only supported on gcc 3= .4+ - fi fi =20 - if test "x$CPPFLAGS" =3D "x"; then - echo " setting CPPFLAGS to \"`$APR_CONFIG --cppflags`\"" - CPPFLAGS=3D"`$APR_CONFIG --cppflags`" - else - apr_addto_bugger=3D"`$APR_CONFIG --cppflags`" - for i in $apr_addto_bugger; do - apr_addto_duplicate=3D"0" - for j in $CPPFLAGS; do - if test "x$i" =3D "x$j"; then - apr_addto_duplicate=3D"1" - break - fi - done - if test $apr_addto_duplicate =3D "0"; then - echo " adding \"$i\" to CPPFLAGS" - CPPFLAGS=3D"$CPPFLAGS $i" - fi - done - fi + APR_ADDTO([CPPFLAGS], "`$APR_CONFIG --cppflags`") =20 get_version=3D"$abs_srcdir/build/get-version.sh" version_hdr=3D"$abs_srcdir/include/apreq_version.h" @@ -221,6 +212,8 @@ AC_SUBST(APACHE2_INCLUDES) AC_SUBST(APACHE2_HTTPD) =20 + AC_SUBST(APACHE1_APXS) + AC_SUBST(APU_CONFIG) AC_SUBST(APR_CONFIG) AC_SUBST(APR_INCLUDES) @@ -284,4 +277,31 @@ =20 echo [$]0 [$]ac_configure_args '"[$]@"' >> $1 chmod +x $1 +])dnl + +dnl +dnl APR_ADDTO(variable, value) +dnl +dnl Add value to variable +dnl +AC_DEFUN([APR_ADDTO],[ + if test "x$$1" =3D "x"; then + echo " setting $1 to \"$2\"" + $1=3D"$2" + else + apr_addto_bugger=3D"$2" + for i in $apr_addto_bugger; do + apr_addto_duplicate=3D"0" + for j in $$1; do + if test "x$i" =3D "x$j"; then + apr_addto_duplicate=3D"1" + break + fi + done + if test $apr_addto_duplicate =3D "0"; then + echo " adding \"$i\" to $1" + $1=3D"$$1 $i" + fi + done + fi ])dnl Modified: httpd/apreq/branches/multi-env-unstable/configure.ac URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/= configure.ac?view=3Ddiff&r1=3D155671&r2=3D155672 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- httpd/apreq/branches/multi-env-unstable/configure.ac (original) +++ httpd/apreq/branches/multi-env-unstable/configure.ac Sun Feb 27 22:51:0= 5 2005 @@ -32,7 +32,7 @@ dnl Checks for library functions. =20 AC_APREQ -AC_CONFIG_FILES([Makefile library/Makefile library/t/Makefile module/Makef= ile module/apache2/Makefile glue/Makefile]) +AC_CONFIG_FILES([Makefile library/Makefile library/t/Makefile module/Makef= ile module/apache2/Makefile module/apache/Makefile glue/Makefile]) AC_CONFIG_FILES([build/doxygen.conf include/groups.dox]) AC_CONFIG_FILES([apreq2-config], [chmod +x apreq2-config]) AC_OUTPUT Modified: httpd/apreq/branches/multi-env-unstable/module/Makefile.am URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/= module/Makefile.am?view=3Ddiff&r1=3D155671&r2=3D155672 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- httpd/apreq/branches/multi-env-unstable/module/Makefile.am (original) +++ httpd/apreq/branches/multi-env-unstable/module/Makefile.am Sun Feb 27 2= 2:51:05 2005 @@ -1,5 +1,5 @@ INCLUDES =3D -I../src @APACHE2_INCLUDES@ @APR_INCLUDES@ @APU_INCLUDES@ -SUBDIRS =3D apache2 +SUBDIRS =3D apache2 apache LIBS =3D ../library/lib@APREQ_LIBNAME@.la @APR_LTLIBS@ @APU_LTLIBS@ LDFLAGS =3D @APR_LDFLAGS@ @APU_LDFLAGS@ TEST_CONFIG_SCRIPT =3D package Apache::TestMM; filter_args(); generate_scr= ipt("t/TEST") Propchange: httpd/apreq/branches/multi-env-unstable/module/apache/ ---------------------------------------------------------------------------= --- --- svn:ignore (added) +++ svn:ignore Sun Feb 27 22:51:05 2005 @@ -0,0 +1,4 @@ +=2Edeps +=2Elibs +Makefile.in +Makefile Added: httpd/apreq/branches/multi-env-unstable/module/apache/Makefile.am URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/= module/apache/Makefile.am?view=3Dauto&rev=3D155672 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- httpd/apreq/branches/multi-env-unstable/module/apache/Makefile.am (adde= d) +++ httpd/apreq/branches/multi-env-unstable/module/apache/Makefile.am Sun F= eb 27 22:51:05 2005 @@ -0,0 +1,23 @@ +if MAINTAINER_MODE +APACHE1_INCLUDES =3D -isystem `@APACHE1_APXS@ -q INCLUDEDIR` +else +APACHE1_INCLUDES =3D -I `@APACHE1_APXS@ -q INCLUDEDIR` +endif + +INCLUDES =3D $(APACHE1_INCLUDES) @APR_INCLUDES@ @APU_INCLUDES@ +LIBS =3D ../../library/lib@APREQ_LIBNAME@.la @APR_LTLIBS@ @APU_LTLIBS@ +LDFLAGS =3D @APR_LDFLAGS@ @APU_LDFLAGS@ +TEST_CONFIG_SCRIPT =3D package Apache::TestMM; filter_args(); generate_scr= ipt("t/TEST") +pkgincludedir =3D $(includedir)/@APREQ_LIBNAME@ +pkginclude_HEADERS =3D apreq_module_apache.h +mod_apreq2_la_LDFLAGS =3D -export-dynamic -module -avoid-version -rpath `@= APACHE1_APXS@ -q LIBEXECDIR` + +if HAVE_APACHE1 + +noinst_LTLIBRARIES =3D mod_apreq2.la +mod_apreq2_la_SOURCES =3D apreq_private_apache.h handle.c command.c + +install-exec-local: mod_apreq2.la + $(LIBTOOL) --mode=3Dinstall cp mod_apreq2.la `@APACHE1_APXS@ -q LIBEXECDI= R` + +endif \ No newline at end of file Added: httpd/apreq/branches/multi-env-unstable/module/apache/apreq_module_a= pache.h URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/= module/apache/apreq_module_apache.h?view=3Dauto&rev=3D155672 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- httpd/apreq/branches/multi-env-unstable/module/apache/apreq_module_apac= he.h (added) +++ httpd/apreq/branches/multi-env-unstable/module/apache/apreq_module_apac= he.h Sun Feb 27 22:51:05 2005 @@ -0,0 +1,43 @@ +/* +** Copyright 2003-2004 The Apache Software Foundation +** +** Licensed 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 implie= d=2E +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#ifndef APREQ_APACHE_H +#define APREQ_APACHE_H + +#include "apreq_module.h" +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + * Create an apreq handle which communicates with an Apache 1.3.x + * request_rec. + */ +APREQ_DECLARE(apreq_handle_t*) apreq_handle_apache(request_rec *r); + + +APREQ_DECLARE(apr_pool_t *) apreq_handle_apache_pool(apreq_handle_t *req); + +APREQ_DECLARE(apr_bucket_alloc_t *) + apreq_handle_apache_bucket_alloc(apreq_handle_t *req); + +#ifdef __cplusplus + } +#endif + +#endif Added: httpd/apreq/branches/multi-env-unstable/module/apache/apreq_private_= apache.h URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/= module/apache/apreq_private_apache.h?view=3Dauto&rev=3D155672 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- httpd/apreq/branches/multi-env-unstable/module/apache/apreq_private_apa= che.h (added) +++ httpd/apreq/branches/multi-env-unstable/module/apache/apreq_private_apa= che.h Sun Feb 27 22:51:05 2005 @@ -0,0 +1,11 @@ +#define CORE_PRIVATE +#include "http_config.h" +#undef CORE_PRIVATE + +extern module MODULE_VAR_EXPORT apreq_module; + +struct dir_config { + const char *temp_dir; + apr_uint64_t read_limit; + apr_size_t brigade_limit; +}; Added: httpd/apreq/branches/multi-env-unstable/module/apache/command.c URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/= module/apache/command.c?view=3Dauto&rev=3D155672 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- httpd/apreq/branches/multi-env-unstable/module/apache/command.c (added) +++ httpd/apreq/branches/multi-env-unstable/module/apache/command.c Sun Feb= 27 22:51:05 2005 @@ -0,0 +1,185 @@ +/* +** Copyright 2003-2004 The Apache Software Foundation +** +** Licensed 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 implie= d=2E +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#include "apr_strings.h" + +#include "apreq_util.h" +#include "apreq_module_apache.h" + +#include "httpd.h" +#include "http_log.h" +#include "http_request.h" + +#include "apreq_private_apache.h" + +/** + *

Server Configuration Directives

+ * + * + * + * + * = + *
Per-directory commands for mod_apreq + *
DirectiveContextDefaultDescription
APREQ_ReadLimitdirectory-1 (Unl= imited) + * Maximum number of bytes mod_apreq will send off to libapreq for parsing= . =20 + * mod_apreq will log this event and remove itself from the filter chain. + * The APR_EGENERAL error will be reported to libapreq2 users via the retu= rn=20 + * value of apreq_env_read(). + *
APREQ_BrigadeLimitdirectory #APREQ_MAX_BRIGAD= E_LEN + * Maximum number of bytes apreq will allow to accumulate + * within a brigade. Excess data will be spooled to a + * file bucket appended to the brigade. + *
APREQ_TempDirdirectoryNULL + * Sets the location of the temporary directory apreq will use to spool + * overflow brigade data (based on the APREQ_BrigadeLimit setting). + * If left unset, libapreq2 will select a platform-specific location via a= pr_temp_dir_get(). + *
+ * + *

Implementation Details

+ *
+ * XXX apreq as a normal input filter
+ * XXX apreq as a "virtual" content handler.
+ * XXX apreq as a transparent "tee".
+ * XXX apreq parser registration in post_config
+ * 
+ * @{ + */ + + +static void *apreq_create_dir_config(pool *p, char *d) +{ + /* d =3D=3D OR_ALL */ + struct dir_config *dc =3D ap_palloc(p, sizeof *dc); + dc->temp_dir =3D NULL; + dc->read_limit =3D (apr_uint64_t)-1; + dc->brigade_limit =3D APREQ_DEFAULT_BRIGADE_LIMIT; + return dc; +} + +static void *apreq_merge_dir_config(pool *p, void *a_, void *b_) +{ + struct dir_config *a =3D a_, *b =3D b_, *c =3D ap_palloc(p, sizeof *c); + + c->temp_dir =3D (b->temp_dir !=3D NULL) /* overrides o= k */ + ? b->temp_dir : a->temp_dir; + + c->brigade_limit =3D (b->brigade_limit =3D=3D (apr_size_t)-1) /* overr= ides ok */ + ? a->brigade_limit : b->brigade_limit; + + c->read_limit =3D (b->read_limit < a->read_limit) /* why min? */ + ? b->read_limit : a->read_limit; + + return c; +} + +static const char *apreq_set_temp_dir(cmd_parms *cmd, void *data, + const char *arg) +{ + struct dir_config *conf =3D data; + const char *err =3D ap_check_cmd_context(cmd, NOT_IN_LIMIT); + + if (err !=3D NULL) + return err; + + conf->temp_dir =3D arg; + return NULL; +} + +static const char *apreq_set_read_limit(cmd_parms *cmd, void *data, + const char *arg) +{ + struct dir_config *conf =3D data; + const char *err =3D ap_check_cmd_context(cmd, NOT_IN_LIMIT); + + if (err !=3D NULL) + return err; + + conf->read_limit =3D apreq_atoi64f(arg); + return NULL; +} + +static const char *apreq_set_brigade_limit(cmd_parms *cmd, void *data, + const char *arg) +{ + struct dir_config *conf =3D data; + const char *err =3D ap_check_cmd_context(cmd, NOT_IN_LIMIT); + + if (err !=3D NULL) + return err; + + conf->brigade_limit =3D apreq_atoi64f(arg); + return NULL; +} + + +static const command_rec apreq_cmds[] =3D +{ + { "APREQ_TempDir", apreq_set_temp_dir, NULL, OR_ALL, TAKE1, + "Default location of temporary directory" }, + { "APREQ_ReadLimit", apreq_set_read_limit, NULL, OR_ALL, TAKE1, + "Maximum amount of data that will be fed into a parser." }, + { "APREQ_BrigadeLimit", apreq_set_brigade_limit, NULL, OR_ALL, TAKE1, + "Maximum in-memory bytes a brigade may use." }, + { NULL } +}; + +static void apreq_cleanup(void *data) +{ + apr_pool_t *p =3D data; + apr_pool_destroy(p); + apr_terminate(); +} + +static void apreq_init (server_rec *s, pool *sp) +{ + /* APR_HOOK_FIRST because we want other modules to be able to + register parsers in their post_config hook */ + + apr_pool_t *p; + apr_initialize(); + apr_pool_create(&p, NULL); + apreq_initialize(p); + ap_register_cleanup(sp, p, apreq_cleanup, apreq_cleanup); +} + + + +/** @} */ + + +module MODULE_VAR_EXPORT apreq_module =3D +{ + STANDARD_MODULE_STUFF, + apreq_init, /* module initializer */ + apreq_create_dir_config, /* per-directory config creator */ + apreq_merge_dir_config, /* dir config merger */ + NULL, /* server config creator */ + NULL, /* server config merger */ + apreq_cmds, /* command table */ + NULL, /* [9] content handlers */ + NULL, /* [2] URI-to-filename translation */ + NULL, /* [5] check/validate user_id */ + NULL, /* [6] check user_id is valid *here* */ + NULL, /* [4] check access by host address */ + NULL, /* [7] MIME type checker/setter */ + NULL, /* [8] fixups */ + NULL, /* [10] logger */ + NULL, /* [3] header parser */ + NULL, /* process initialization */ + NULL, /* process exit/cleanup */ + NULL /* [1] post read_request handling */ +}; + Added: httpd/apreq/branches/multi-env-unstable/module/apache/handle.c URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/= module/apache/handle.c?view=3Dauto&rev=3D155672 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- httpd/apreq/branches/multi-env-unstable/module/apache/handle.c (added) +++ httpd/apreq/branches/multi-env-unstable/module/apache/handle.c Sun Feb = 27 22:51:05 2005 @@ -0,0 +1,526 @@ +/* +** Copyright 2003-2004 The Apache Software Foundation +** +** Licensed 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 implie= d=2E +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +#include "apr_strings.h" +#include "apreq_module_apache.h" + +#include "http_main.h" +#include "http_log.h" +#include "http_protocol.h" +#include "http_request.h" + +#include "apreq_private_apache.h" + +/* This is basically the cgi_handle struct with a request_rec */ + +struct apache_handle { + struct apreq_handle_t handle; + request_rec *r; + apr_pool_t *pool; + apr_bucket_alloc_t *bucket_alloc; + + apr_table_t *jar, *args, *body; + apr_status_t jar_status, + args_status, + body_status; + + apreq_parser_t *parser; + apreq_hook_t *hook_queue; + + const char *temp_dir; + apr_size_t brigade_limit; + apr_uint64_t read_limit; + apr_uint64_t bytes_read; + apr_bucket_brigade *in; + +}; + +static const char *apache_header_in(apreq_handle_t *env, const char *name) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + return ap_table_get(req->r->headers_in, name); +} + +static apr_status_t apache_header_out(apreq_handle_t *env, + const char *name, char *value) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + ap_table_add(req->r->err_headers_out, name, value); + return APR_SUCCESS; +} + + +static apr_status_t ba_cleanup(void *data) +{ + apr_bucket_alloc_t *ba =3D data; + apr_bucket_alloc_destroy(ba); + return APR_SUCCESS; +} + + +static void init_body(apreq_handle_t *env) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + const char *cl_header =3D apache_header_in(env, "Content-Length"); + apr_bucket_alloc_t *ba =3D req->bucket_alloc; + request_rec *r =3D req->r; + + req->body =3D apr_table_make(req->pool, APREQ_DEFAULT_NELTS); + apr_pool_cleanup_register(req->pool, ba, ba_cleanup, ba_cleanup); + + if (cl_header !=3D NULL) { + char *dummy; + apr_int64_t content_length =3D apr_strtoi64(cl_header, &dummy, 0); + + if (dummy =3D=3D NULL || *dummy !=3D 0) { + req->body_status =3D APREQ_ERROR_BADHEADER; + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, + "Invalid Content-Length header (%s)", cl_header); + return; + } + else if ((apr_uint64_t)content_length > req->read_limit) { + req->body_status =3D APREQ_ERROR_OVERLIMIT; + ap_log_rerror(APLOG_MARK, APLOG_ERR, r, + "Content-Length header (%s) exceeds configured " + "max_body limit (%" APR_UINT64_T_FMT ")",=20 + cl_header, req->read_limit); + return; + } + } + + if (req->parser =3D=3D NULL) { + const char *ct_header =3D apache_header_in(env, "Content-Type"); + + if (ct_header !=3D NULL) { + apreq_parser_function_t pf =3D apreq_parser(ct_header); + + if (pf !=3D NULL) { + req->parser =3D apreq_parser_make(req->pool, + ba, + ct_header,=20 + pf, + req->brigade_limit, + req->temp_dir, + req->hook_queue, + NULL); + } + else { + req->body_status =3D APREQ_ERROR_NOPARSER; + return; + } + } + else { + req->body_status =3D APREQ_ERROR_NOHEADER; + return; + } + } + else { + if (req->parser->brigade_limit > req->brigade_limit) + req->parser->brigade_limit =3D req->brigade_limit; + if (req->temp_dir !=3D NULL) + req->parser->temp_dir =3D req->temp_dir; + if (req->hook_queue !=3D NULL) + apreq_parser_add_hook(req->parser, req->hook_queue); + } + + req->hook_queue =3D NULL; + req->in =3D apr_brigade_create(req->pool, ba); + req->body_status =3D APR_INCOMPLETE; + +} + +static apr_status_t apache_read(apreq_handle_t *env, + apr_off_t bytes) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + request_rec *r =3D req->r; + apr_bucket *e; + long got =3D 0; + char buf[HUGE_STRING_LEN]; + char tc[] =3D "[apreq] apache_read"; + int want =3D sizeof buf; + + if (req->body_status =3D=3D APR_EINIT) + init_body(env); + + if (req->body_status !=3D APR_INCOMPLETE) + return req->body_status; + + /* XXX want a loop here, instead of reducing bytes */ + + if (bytes > HUGE_STRING_LEN) + want =3D HUGE_STRING_LEN; + else + want =3D bytes; + + + ap_hard_timeout(tc, r); + got =3D ap_get_client_block(r, buf, want); + ap_kill_timeout(r); + + if (got > 0) { + e =3D apr_bucket_transient_create(buf, got, req->bucket_alloc); + req->bytes_read +=3D got; + } + else + e =3D apr_bucket_eos_create(req->bucket_alloc); + + APR_BRIGADE_INSERT_TAIL(req->in, e); + + + if (req->bytes_read <=3D req->read_limit) { + req->body_status =3D apreq_parser_run(req->parser, req->body, req-= >in); + apr_brigade_cleanup(req->in); + } + else { + req->body_status =3D APREQ_ERROR_OVERLIMIT; + ap_log_rerror(APLOG_MARK, APLOG_ERR, req->r, + "Bytes read (%" APR_UINT64_T_FMT + ") exceeds configured limit (%" APR_UINT64_T_FMT ")", + req->bytes_read, req->read_limit); + } + + return req->body_status; +} + + + + + + +static apr_status_t apache_jar(apreq_handle_t *env, const apr_table_t **t) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + request_rec *r =3D req->r; + + if (req->jar_status =3D=3D APR_EINIT) { + const char *cookies =3D ap_table_get(r->headers_in, "Cookie"); + if (cookies !=3D NULL) { + req->jar =3D apr_table_make(req->pool, APREQ_DEFAULT_NELTS); + req->jar_status =3D=20 + apreq_parse_cookie_header(req->pool, req->jar, cookies); + } + else + req->jar_status =3D APREQ_ERROR_NODATA; + } + + *t =3D req->jar; + return req->jar_status; +} + +static apr_status_t apache_args(apreq_handle_t *env, const apr_table_t **t) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + request_rec *r =3D req->r; + + if (req->args_status =3D=3D APR_EINIT) { + if (r->args !=3D NULL) { + req->args =3D apr_table_make(req->pool, APREQ_DEFAULT_NELTS); + req->args_status =3D=20 + apreq_parse_query_string(req->pool, req->args, r->args); + } + else + req->args_status =3D APREQ_ERROR_NODATA; + } + + *t =3D req->args; + return req->args_status; +} + + + + +static apreq_cookie_t *apache_jar_get(apreq_handle_t *env, const char *nam= e) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + const apr_table_t *t; + const char *val; + + if (req->jar_status =3D=3D APR_EINIT) + apache_jar(env, &t); + else + t =3D req->jar; + + if (t =3D=3D NULL) + return NULL; + + val =3D apr_table_get(t, name); + if (val =3D=3D NULL) + return NULL; + + return apreq_value_to_cookie(val); +} + +static apreq_param_t *apache_args_get(apreq_handle_t *env, const char *nam= e) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + const apr_table_t *t; + const char *val; + + if (req->args_status =3D=3D APR_EINIT) + apache_args(env, &t); + else + t =3D req->args; + + if (t =3D=3D NULL) + return NULL; + + val =3D apr_table_get(t, name); + if (val =3D=3D NULL) + return NULL; + + return apreq_value_to_param(val); +} + + +static apr_status_t apache_body(apreq_handle_t *env, const apr_table_t **t) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + + switch (req->body_status) { + + case APR_EINIT: + init_body(env); + if (req->body_status !=3D APR_INCOMPLETE) + break; + + case APR_INCOMPLETE: + while (apache_read(env, APREQ_DEFAULT_READ_BLOCK_SIZE) =3D=3D APR_= INCOMPLETE) + ; /*loop*/ + } + + *t =3D req->body; + return req->body_status; +} + +static apreq_param_t *apache_body_get(apreq_handle_t *env, const char *nam= e) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + const char *val; + + switch (req->body_status) { + + case APR_EINIT: + + init_body(env); + if (req->body_status !=3D APR_INCOMPLETE) + return NULL; + apache_read(env, APREQ_DEFAULT_READ_BLOCK_SIZE); + + case APR_INCOMPLETE: + + val =3D apr_table_get(req->body, name); + if (val !=3D NULL) + return apreq_value_to_param(val); + + do { + /* riff on Duff's device */ + apache_read(env, APREQ_DEFAULT_READ_BLOCK_SIZE); + + default: + + val =3D apr_table_get(req->body, name); + if (val !=3D NULL) + return apreq_value_to_param(val); + + } while (req->body_status =3D=3D APR_INCOMPLETE); + + } + + return NULL; +} + +static +apr_status_t apache_parser_get(apreq_handle_t *env,=20 + const apreq_parser_t **parser) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + *parser =3D req->parser; + return APR_SUCCESS; +} + +static +apr_status_t apache_parser_set(apreq_handle_t *env,=20 + apreq_parser_t *parser) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + + if (req->parser =3D=3D NULL) { + + if (req->hook_queue !=3D NULL) { + apr_status_t s =3D apreq_parser_add_hook(parser, req->hook_que= ue); + if (s !=3D APR_SUCCESS) + return s; + } + if (req->temp_dir !=3D NULL) { + req->temp_dir =3D req->temp_dir; + } + if (req->brigade_limit < req->brigade_limit) { + req->brigade_limit =3D req->brigade_limit; + } + + req->hook_queue =3D NULL; + req->parser =3D parser; + return APR_SUCCESS; + } + else + return APREQ_ERROR_MISMATCH; +} + +static +apr_status_t apache_hook_add(apreq_handle_t *env, + apreq_hook_t *hook) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + + if (req->parser !=3D NULL) { + return apreq_parser_add_hook(req->parser, hook); + } + else if (req->hook_queue !=3D NULL) { + apreq_hook_t *h =3D req->hook_queue; + while (h->next !=3D NULL) + h =3D h->next; + h->next =3D hook; + } + else { + req->hook_queue =3D hook; + } + return APR_SUCCESS; + +} + +static +apr_status_t apache_brigade_limit_set(apreq_handle_t *env, + apr_size_t bytes) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + apr_size_t *limit =3D (req->parser =3D=3D NULL)=20 + ? &req->brigade_limit=20 + : &req->parser->brigade_limit; + + if (*limit > bytes) { + *limit =3D bytes; + return APR_SUCCESS; + } + + return APREQ_ERROR_MISMATCH; +} + +static +apr_status_t apache_brigade_limit_get(apreq_handle_t *env, + apr_size_t *bytes) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + *bytes =3D (req->parser =3D=3D NULL)=20 + ? req->brigade_limit=20 + : req->parser->brigade_limit; + + return APR_SUCCESS; +} + +static +apr_status_t apache_read_limit_set(apreq_handle_t *env, + apr_uint64_t bytes) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + if (req->read_limit > bytes && req->bytes_read < bytes) { + req->read_limit =3D bytes; + return APR_SUCCESS; + } + + return APREQ_ERROR_MISMATCH; +} + +static +apr_status_t apache_read_limit_get(apreq_handle_t *env, + apr_uint64_t *bytes) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + *bytes =3D req->read_limit; + return APR_SUCCESS; +} + +static +apr_status_t apache_temp_dir_set(apreq_handle_t *env, + const char *path) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + + const char **curpath =3D (req->parser =3D=3D NULL)=20 + ? &req->temp_dir + : &req->parser->temp_dir; + + if (*curpath =3D=3D NULL) { + *curpath =3D apr_pstrdup(req->pool, path); + return APR_SUCCESS; + } + + return APREQ_ERROR_NOTEMPTY; +} + +static +apr_status_t apache_temp_dir_get(apreq_handle_t *env, + const char **path) +{ + struct apache_handle *req =3D (struct apache_handle *)env; + + *path =3D req->parser ? req->parser->temp_dir : req->temp_dir; + return APR_SUCCESS; +} + +static APREQ_MODULE(apache, 20050227); + +static void apreq_cleanup(void *data) +{ + struct apache_handle *req =3D data; + apr_pool_destroy(req->pool); +} + + +APREQ_DECLARE(apreq_handle_t *) apreq_handle_apache(request_rec *r) +{ + struct apache_handle *req =3D + ap_get_module_config(r->request_config, &apreq_module); + struct dir_config *d =3D + ap_get_module_config(r->per_dir_config, &apreq_module); + + if (req !=3D NULL) + return &req->handle; + + apr_pool_create(&req->pool, NULL); + req =3D apr_pcalloc(req->pool, sizeof *req); + req->bucket_alloc =3D apr_bucket_alloc_create(req->pool); + + req->handle.module =3D &apache_module; + req->r =3D r; + + req->args_status =3D req->jar_status =3D req->body_status =3D APR_EINI= T; + ap_register_cleanup(r->pool, req, apreq_cleanup, apreq_cleanup); + + if (d =3D=3D NULL) { + req->read_limit =3D (apr_uint64_t)-1; + req->brigade_limit =3D APREQ_DEFAULT_BRIGADE_LIMIT; + } + else { + req->temp_dir =3D d->temp_dir; + req->read_limit =3D d->read_limit; + req->brigade_limit =3D d->brigade_limit; + } + + ap_set_module_config(r->request_config, &apreq_module, req); + + return &req->handle; +} Modified: httpd/apreq/branches/multi-env-unstable/module/apache2/Makefile.am URL: http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/= module/apache2/Makefile.am?view=3Ddiff&r1=3D155671&r2=3D155672 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- httpd/apreq/branches/multi-env-unstable/module/apache2/Makefile.am (ori= ginal) +++ httpd/apreq/branches/multi-env-unstable/module/apache2/Makefile.am Sun = Feb 27 22:51:05 2005 @@ -30,6 +30,6 @@ mod_apreq2_la_SOURCES =3D apreq_private_apache2.h handle.c filter.c =20 install-exec-local: mod_apreq.la - @APACHE2_APXS@ -i -a -n apreq2 mod_apreq2.la + @APACHE2_APXS@ -i -a -n apreq mod_apreq2.la =20 endif