cvs: php4 /sapi/apache2 mod_php4.c

From: Date: Sun, 22 Oct 2000 16:03:53 +0000
Subject: cvs: php4 /sapi/apache2 mod_php4.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-2219@lists.php.net to get a copy of this message
rasmus Sun Oct 22 09:03:53 2000 EDT Modified files: /php4/sapi/apache2 mod_php4.c Log: Code to flatten Apache 2.0 bucket brigades Index: php4/sapi/apache2/mod_php4.c diff -u php4/sapi/apache2/mod_php4.c:1.1 php4/sapi/apache2/mod_php4.c:1.2 --- php4/sapi/apache2/mod_php4.c:1.1 Sun Oct 22 07:01:18 2000 +++ php4/sapi/apache2/mod_php4.c Sun Oct 22 09:03:53 2000 @@ -15,7 +15,7 @@ | Authors: | +----------------------------------------------------------------------+ */ -/* $Id: mod_php4.c,v 1.1 2000/10/22 14:01:18 rasmus Exp $ */ +/* $Id: mod_php4.c,v 1.2 2000/10/22 16:03:53 rasmus Exp $ */ #define NO_REGEX_EXTRA_H #ifdef WIN32 @@ -433,11 +433,6 @@ zend_hash_apply((HashTable *) per_dir_conf, (int (*)(void *)) php_apache_alter_ini_entries); } - /* We don't accept OPTIONS requests, but take everything else */ - if (r->method_number == M_OPTIONS) { - r->allowed |= (1 << METHODS) - 1; - return DECLINED; - } /* Make sure file exists */ if (filename == NULL && r->finfo.st_mode == 0) { @@ -689,40 +684,59 @@ } } } - - -#if HAVE_MOD_DAV - -extern int phpdav_mkcol_test_handler(request_rec *r); -extern int phpdav_mkcol_create_handler(request_rec *r); - -/* conf is being read twice (both here and in send_php()) */ -int send_parsed_php_dav_script(request_rec *r) -{ - php_apache_info_struct *conf; - - conf = (php_apache_info_struct *) get_module_config(r->per_dir_config, - &php4_module); - return send_php(r, 0, 0, conf->dav_script); -} -static int php_type_checker(request_rec *r) -{ - php_apache_info_struct *conf; +typedef struct PHP_OUTPUT_FILTER_CTX { + ap_bucket_brigade *b; +} php_output_filter_ctx_t; + +static int php_filter(ap_filter_t *f, ap_bucket_brigade *b) { + request_rec *r = f->r; + conn_rec *c = f->c; + php_output_filter_ctx_t *ctx = f->ctx; + apr_status_t rv; + const char *str; + apr_ssize_t n; + long size = 0L; + char *content, *p; - conf = (php_apache_info_struct *)get_module_config(r->per_dir_config, - &php4_module); + /* We don't accept OPTIONS requests, but take everything else */ + if (r->method_number == M_OPTIONS) { + r->allowed |= (1 << METHODS) - 1; + return ap_pass_brigade(f->next, b); + } + + if (ctx == NULL) { + f->ctx = ctx = apr_pcalloc(c->pool, sizeof(php_output_filter_ctx_t)); + ctx->b = ap_brigade_create(c->pool); /* create an initial empty brigade */ + } - /* If DAV support is enabled, use mod_dav's type checker. */ - if (conf->dav_script) { - dav_api_set_request_handler(r, send_parsed_php_dav_script); - dav_api_set_mkcol_handlers(r, phpdav_mkcol_test_handler, - phpdav_mkcol_create_handler); - /* leave the rest of the request to mod_dav */ - return dav_api_type_checker(r); + AP_BRIGADE_CONCAT(ctx->b,b); + if(AP_BUCKET_IS_EOS(AP_BRIGADE_LAST(b))) { + /* Ok, we have all of our brigades, time to munch on the buckets */ + AP_BRIGADE_FOREACH(e, b) { + rv = ap_bucket_read(e, &str, &n, 1); + } + /* Because some of our buckets may be pipes, we can't actually get the + * total size of our brigade on our first pass, so run through them all + * again to get the total size of the brigade */ + AP_BRIGADE_FOREACH(e, b) { + size += e->length; + } + /* Now that we have the size we can allocate a big chunk of memory + * where we will memcpy all of the buckets into. */ + content = p = apr_pcalloc(c->pool, size+1); + /* And now we can copy the buckets into our buffer */ + AP_BRIGADE_FOREACH(e, b) { + memcpy(p, e->data, e->length); + p += e->length; + } + /* We should now have a flat buffer in 'content' that we somehow have + * to get PHP to parse... */ } +} - return DECLINED; +static void register_php_hooks (void) { + ap_register_output_filter("PHP", php_filter, AP_FTYPE_CONTENT); } static const handler_rec php_handlers[] = @@ -733,7 +747,6 @@ {NULL} }; - command_rec php_commands[] = { {"php_value", php_apache_value_handler, NULL, OR_OPTIONS, TAKE2, "PHP Value Modifier"}, @@ -752,7 +765,7 @@ NULL, /* merge server config */ php_commands, /* command apr_table_t */ php_handlers, /* handlers */ - NULL /* register hooks */ + register_php_hooks /* register hooks */ }; /*

« previous php.cvs (#2219) next »