php-src/sapi/apache2filter/php_apache.h
Aaron Bannert 27a5b380cf PHP filters and Apache 2 aren't quite a perfect match yet, so we have
to do some trickery with the server_context to make sure it is always
valid within the current thread.

This patch makes sure the server_context is created in apache's
post_read_request hook phase, and then registeres a cleanup that
will NULL out the server context when the request goes out of scope.
Then, inside the output filters, if the server_context is null we
throw an error. Finally, instead of saving the output filter in
the server_context, now we store the entire request_rec pointer
in there.

POST bodies appear to be working now, although they are very inefficient.
The input filter is still just realloc()ing for whatever data comes
down the input pipe, and then sending this to PHP. This means that
we are doing some really nasty memory management on big POST bodies.
For now this it allows for unlimited input bodies, which means that
a big POST could potentially DoS a box by making it run out of memory.
We might want to put a limit on here just in case, at least until
we figure out how to consume input data more efficiently into php.
2002-04-11 19:25:08 +00:00

53 lines
2.0 KiB
C

/*
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.php.net/license/2_02.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Sascha Schumann <sascha@schumann.cx> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_APACHE_H
#define PHP_APACHE_H
typedef struct php_struct {
int state;
request_rec *r;
/* Length of post_data buffer */
int post_len;
/* Index for reading from buffer */
int post_idx;
/* Buffer for request body filter */
char *post_data;
/* Whether or not we've processed PHP in the output filters yet. */
int request_processed;
} php_struct;
int php_apache_register_module(void);
void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf);
void *create_php_config(apr_pool_t *p, char *dummy);
void apply_config(void *);
extern const command_rec php_dir_cmds[];
#define APR_ARRAY_FOREACH_OPEN(arr, key, val) \
{ \
apr_table_entry_t *elts; \
int i; \
elts = (apr_table_entry_t *) arr->elts; \
for (i = 0; i < arr->nelts; i++) { \
key = elts[i].key; \
val = elts[i].val;
#define APR_ARRAY_FOREACH_CLOSE() }}
#endif /* PHP_APACHE_H */