summaryrefslogtreecommitdiff
path: root/sapi/apache2filter
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2010-02-07 22:19:53 +0100
committerSean Finney <seanius@debian.org>2010-02-07 22:27:07 +0100
commitc852c28a88fccf6e34a2cb091fdfa72bce2b59c7 (patch)
tree91f01b0d06916c78262404096bfd466b8e95e5b5 /sapi/apache2filter
parent176cbd0bc99e20bb21f92f0b72df728eafc1e2ce (diff)
parent0fab6db7cac8d2be99579dd049f812a8ff98e74f (diff)
downloadphp-c852c28a88fccf6e34a2cb091fdfa72bce2b59c7.tar.gz
Merge branch 'upstream-experimental' into upstream-sid
Diffstat (limited to 'sapi/apache2filter')
-rw-r--r--sapi/apache2filter/apache_config.c2
-rw-r--r--sapi/apache2filter/config.m46
-rwxr-xr-xsapi/apache2filter/config.w3210
-rw-r--r--sapi/apache2filter/php_apache.h12
-rw-r--r--sapi/apache2filter/php_functions.c161
-rw-r--r--sapi/apache2filter/sapi_apache2.c99
6 files changed, 171 insertions, 119 deletions
diff --git a/sapi/apache2filter/apache_config.c b/sapi/apache2filter/apache_config.c
index c3a9d6cb4..e06b16856 100644
--- a/sapi/apache2filter/apache_config.c
+++ b/sapi/apache2filter/apache_config.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: apache_config.c 272374 2008-12-31 11:17:49Z sebastian $ */
+/* $Id: apache_config.c 272370 2008-12-31 11:15:49Z sebastian $ */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
diff --git a/sapi/apache2filter/config.m4 b/sapi/apache2filter/config.m4
index 2c8ff5879..77823664f 100644
--- a/sapi/apache2filter/config.m4
+++ b/sapi/apache2filter/config.m4
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4 239540 2007-07-11 23:20:37Z jani $
+dnl $Id: config.m4 254692 2008-03-09 12:35:56Z lstrojny $
dnl
PHP_ARG_WITH(apxs2filter,,
@@ -110,7 +110,7 @@ if test "$PHP_APXS2FILTER" != "no"; then
`ln -s $APXS_BINDIR/httpd _APP_`
EXTRA_LIBS="$EXTRA_LIBS _APP_"
PHP_SELECT_SAPI(apache2filter, shared, sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
- INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"
+ INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"
;;
*)
PHP_SELECT_SAPI(apache2filter, shared, sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
@@ -118,7 +118,7 @@ if test "$PHP_APXS2FILTER" != "no"; then
;;
esac
- if test "$APXS_MPM" != "prefork"; then
+ if test "$APXS_MPM" != "prefork" && test "$APXS_MPM" != "peruser"; then
PHP_BUILD_THREAD_SAFE
fi
AC_MSG_RESULT(yes)
diff --git a/sapi/apache2filter/config.w32 b/sapi/apache2filter/config.w32
index 68579a8e3..6e7aab59c 100755
--- a/sapi/apache2filter/config.w32
+++ b/sapi/apache2filter/config.w32
@@ -1,10 +1,12 @@
// vim:ft=javascript
-// $Id: config.w32 234960 2007-05-04 18:17:55Z edink $
+// $Id: config.w32 259731 2008-05-14 03:13:17Z auroraeosrose $
ARG_ENABLE('apache2filter', 'Build Apache 2.x filter', 'no');
if (PHP_APACHE2FILTER != "no") {
- if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE2FILTER", PHP_PHP_BUILD + "\\include\\apache2") &&
+ if (PHP_ZTS == "no") {
+ WARNING("Apache2 module requires an --enable-zts build of PHP on windows");
+ } else if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE2FILTER", PHP_PHP_BUILD + "\\include\\apache2") &&
CHECK_LIB("libhttpd.lib", "apache2filter", PHP_PHP_BUILD + "\\lib\\apache2") &&
CHECK_LIB("libapr.lib", "apache2filter", PHP_PHP_BUILD + "\\lib\\apache2") &&
CHECK_LIB("libaprutil.lib", "apache2filter", PHP_PHP_BUILD + "\\lib\\apache2")
@@ -20,7 +22,9 @@ if (PHP_APACHE2FILTER != "no") {
ARG_ENABLE('apache2-2filter', 'Build Apache 2.2.x filter', 'no');
if (PHP_APACHE2_2FILTER != "no") {
- if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE2_2FILTER", PHP_PHP_BUILD + "\\include\\apache2_2") &&
+ if (PHP_ZTS == "no") {
+ WARNING("Apache2 module requires an --enable-zts build of PHP on windows");
+ } else if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE2_2FILTER", PHP_PHP_BUILD + "\\include\\apache2_2") &&
CHECK_LIB("libhttpd.lib", "apache2_2filter", PHP_PHP_BUILD + "\\lib\\apache2_2") &&
CHECK_LIB("libapr-1.lib", "apache2_2filter", PHP_PHP_BUILD + "\\lib\\apache2_2") &&
CHECK_LIB("libaprutil-1.lib", "apache2_2filter", PHP_PHP_BUILD + "\\lib\\apache2_2")
diff --git a/sapi/apache2filter/php_apache.h b/sapi/apache2filter/php_apache.h
index 243377b7f..3f54fa714 100644
--- a/sapi/apache2filter/php_apache.h
+++ b/sapi/apache2filter/php_apache.h
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_apache.h 272374 2008-12-31 11:17:49Z sebastian $ */
+/* $Id: php_apache.h 272370 2008-12-31 11:15:49Z sebastian $ */
#ifndef PHP_APACHE_H
#define PHP_APACHE_H
@@ -49,7 +49,6 @@ typedef struct php_struct {
} php_struct;
typedef struct _php_apr_bucket_brigade {
- unsigned int total_len;
apr_bucket_brigade *bb;
} php_apr_bucket_brigade;
@@ -60,8 +59,7 @@ void apply_config(void *);
extern const command_rec php_dir_cmds[];
static size_t php_apache_read_stream(void *, char *, size_t TSRMLS_DC);
-static void php_apache_close_stream(void * TSRMLS_DC);
-static long php_apache_fteller_stream(void * TSRMLS_DC);
+static size_t php_apache_fsizer_stream(void * TSRMLS_DC);
#define APR_ARRAY_FOREACH_OPEN(arr, key, val) \
{ \
@@ -74,4 +72,10 @@ static long php_apache_fteller_stream(void * TSRMLS_DC);
#define APR_ARRAY_FOREACH_CLOSE() }}
+/* fix for gcc4 visibility patch */
+#ifndef PHP_WIN32
+# undef AP_MODULE_DECLARE_DATA
+# define AP_MODULE_DECLARE_DATA PHPAPI
+#endif
+
#endif /* PHP_APACHE_H */
diff --git a/sapi/apache2filter/php_functions.c b/sapi/apache2filter/php_functions.c
index 822f2e1ba..d0b662f6c 100644
--- a/sapi/apache2filter/php_functions.c
+++ b/sapi/apache2filter/php_functions.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_functions.c 272374 2008-12-31 11:17:49Z sebastian $ */
+/* $Id: php_functions.c 272840 2009-01-05 16:24:26Z iliaa $ */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
@@ -59,23 +59,22 @@ static request_rec *php_apache_lookup_uri(char *filename TSRMLS_DC)
Perform an apache sub-request */
PHP_FUNCTION(virtual)
{
- zval **filename;
+ char *filename;
+ int filename_len;
request_rec *rr;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(filename);
-
- if (!(rr = php_apache_lookup_uri(Z_STRVAL_PP(filename) TSRMLS_CC))) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", Z_STRVAL_PP(filename));
+ if (!(rr = php_apache_lookup_uri(filename TSRMLS_CC))) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", filename);
RETURN_FALSE;
}
if (rr->status == HTTP_OK) {
if (ap_run_sub_req(rr)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - request execution failed", Z_STRVAL_PP(filename));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - request execution failed", filename);
ap_destroy_sub_req(rr);
RETURN_FALSE;
}
@@ -83,7 +82,7 @@ PHP_FUNCTION(virtual)
RETURN_TRUE;
}
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", Z_STRVAL_PP(filename));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", filename);
ap_destroy_sub_req(rr);
RETURN_FALSE;
}
@@ -99,16 +98,15 @@ PHP_FUNCTION(virtual)
PHP_FUNCTION(apache_lookup_uri)
{
request_rec *rr;
- zval **filename;
+ char *filename;
+ int filename_len;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(filename);
-
- if (!(rr = php_apache_lookup_uri(Z_STRVAL_PP(filename) TSRMLS_CC))) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", Z_STRVAL_PP(filename));
+ if (!(rr = php_apache_lookup_uri(filename TSRMLS_CC))) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", filename);
RETURN_FALSE;
}
@@ -145,7 +143,7 @@ PHP_FUNCTION(apache_lookup_uri)
return;
}
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", Z_STRVAL_PP(filename));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", filename);
ap_destroy_sub_req(rr);
RETURN_FALSE;
}
@@ -195,31 +193,27 @@ PHP_FUNCTION(apache_response_headers)
PHP_FUNCTION(apache_note)
{
php_struct *ctx;
- zval **note_name, **note_val;
+ char *note_name, *note_val = NULL;
+ int note_name_len, note_val_len;
char *old_note_val=NULL;
- int arg_count = ZEND_NUM_ARGS();
- if (arg_count<1 || arg_count>2 ||
- zend_get_parameters_ex(arg_count, &note_name, &note_val) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &note_name, &note_name_len, &note_val, &note_val_len) == FAILURE) {
+ return;
}
-
+
ctx = SG(server_context);
-
- convert_to_string_ex(note_name);
- old_note_val = (char *) apr_table_get(ctx->r->notes, Z_STRVAL_PP(note_name));
-
- if (arg_count == 2) {
- convert_to_string_ex(note_val);
- apr_table_set(ctx->r->notes, Z_STRVAL_PP(note_name), Z_STRVAL_PP(note_val));
+ old_note_val = (char *) apr_table_get(ctx->r->notes, note_name);
+
+ if (note_val) {
+ apr_table_set(ctx->r->notes, note_name, note_val);
}
if (old_note_val) {
RETURN_STRING(old_note_val, 1);
- } else {
- RETURN_FALSE;
}
+
+ RETURN_FALSE;
}
/* }}} */
@@ -229,26 +223,24 @@ PHP_FUNCTION(apache_note)
PHP_FUNCTION(apache_setenv)
{
php_struct *ctx;
- zval **variable=NULL, **string_val=NULL, **walk_to_top=NULL;
+ char *variable=NULL, *string_val=NULL;
+ int variable_len, string_val_len;
+ zend_bool walk_to_top = 0;
int arg_count = ZEND_NUM_ARGS();
- if (arg_count<1 || arg_count>3 ||
- zend_get_parameters_ex(arg_count, &variable, &string_val, &walk_to_top) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(arg_count TSRMLS_CC, "ss|b", &variable, &variable_len, &string_val, &string_val_len, &walk_to_top) == FAILURE) {
+ return;
}
ctx = SG(server_context);
- if (arg_count == 3 && Z_STRVAL_PP(walk_to_top)) {
+ if (arg_count == 3 && walk_to_top) {
while(ctx->f->r->prev) {
ctx->f->r = ctx->f->r->prev;
- }
+ }
}
- convert_to_string_ex(variable);
- convert_to_string_ex(string_val);
-
- apr_table_set(ctx->r->subprocess_env, Z_STRVAL_PP(variable), Z_STRVAL_PP(string_val));
+ apr_table_set(ctx->r->subprocess_env, variable, string_val);
RETURN_TRUE;
}
@@ -259,31 +251,30 @@ PHP_FUNCTION(apache_setenv)
PHP_FUNCTION(apache_getenv)
{
php_struct *ctx;
- zval **variable=NULL, **walk_to_top=NULL;
+ char *variable=NULL;
+ int variable_len;
+ zend_bool walk_to_top = 0;
int arg_count = ZEND_NUM_ARGS();
char *env_val=NULL;
- if (arg_count<1 || arg_count>2 ||
- zend_get_parameters_ex(arg_count, &variable, &walk_to_top) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(arg_count TSRMLS_CC, "s|b", &variable, &variable_len, &walk_to_top) == FAILURE) {
+ return;
}
ctx = SG(server_context);
- if (arg_count == 2 && Z_STRVAL_PP(walk_to_top)) {
+ if (arg_count == 2 && walk_to_top) {
while(ctx->f->r->prev) {
ctx->f->r = ctx->f->r->prev;
- }
+ }
}
- convert_to_string_ex(variable);
-
- env_val = (char*) apr_table_get(ctx->r->subprocess_env, Z_STRVAL_PP(variable));
+ env_val = (char*) apr_table_get(ctx->r->subprocess_env, variable);
if (env_val != NULL) {
RETURN_STRING(env_val, 1);
- } else {
- RETURN_FALSE;
- }
+ }
+
+ RETURN_FALSE;
}
/* }}} */
@@ -359,17 +350,55 @@ PHP_MINFO_FUNCTION(apache)
php_info_print_table_end();
}
-static zend_function_entry apache_functions[] = {
- PHP_FE(apache_lookup_uri, NULL)
- PHP_FE(virtual, NULL)
- PHP_FE(apache_request_headers, NULL)
- PHP_FE(apache_response_headers, NULL)
- PHP_FE(apache_setenv, NULL)
- PHP_FE(apache_getenv, NULL)
- PHP_FE(apache_note, NULL)
- PHP_FE(apache_get_version, NULL)
- PHP_FE(apache_get_modules, NULL)
- PHP_FALIAS(getallheaders, apache_request_headers, NULL)
+/* {{{ arginfo */
+ZEND_BEGIN_ARG_INFO_EX(arginfo_apache2filter_lookup_uri, 0, 0, 1)
+ ZEND_ARG_INFO(0, filename)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_apache2filter_virtual, 0, 0, 1)
+ ZEND_ARG_INFO(0, uri)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_apache2filter_getallheaders, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_apache2filter_response_headers, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_apache2filter_note, 0, 0, 1)
+ ZEND_ARG_INFO(0, note_name)
+ ZEND_ARG_INFO(0, note_value)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_apache2filter_setenv, 0, 0, 2)
+ ZEND_ARG_INFO(0, variable)
+ ZEND_ARG_INFO(0, value)
+ ZEND_ARG_INFO(0, walk_to_top)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_apache2filter_getenv, 0, 0, 1)
+ ZEND_ARG_INFO(0, variable)
+ ZEND_ARG_INFO(0, walk_to_top)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_apache2filter_get_version, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_apache2filter_get_modules, 0)
+ZEND_END_ARG_INFO()
+/* }}} */
+
+static const zend_function_entry apache_functions[] = {
+ PHP_FE(apache_lookup_uri, arginfo_apache2filter_lookup_uri)
+ PHP_FE(virtual, arginfo_apache2filter_virtual)
+ PHP_FE(apache_request_headers, arginfo_apache2filter_getallheaders)
+ PHP_FE(apache_response_headers, arginfo_apache2filter_response_headers)
+ PHP_FE(apache_setenv, arginfo_apache2filter_setenv)
+ PHP_FE(apache_getenv, arginfo_apache2filter_getenv)
+ PHP_FE(apache_note, arginfo_apache2filter_note)
+ PHP_FE(apache_get_version, arginfo_apache2filter_get_version)
+ PHP_FE(apache_get_modules, arginfo_apache2filter_get_modules)
+ PHP_FALIAS(getallheaders, apache_request_headers, arginfo_apache2filter_getallheaders)
{NULL, NULL, NULL}
};
diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c
index b2faf90d0..22f368edd 100644
--- a/sapi/apache2filter/sapi_apache2.c
+++ b/sapi/apache2filter/sapi_apache2.c
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: sapi_apache2.c 272374 2008-12-31 11:17:49Z sebastian $ */
+/* $Id: sapi_apache2.c 272370 2008-12-31 11:15:49Z sebastian $ */
#include <fcntl.h>
@@ -91,7 +91,7 @@ php_apache_sapi_ub_write(const char *str, uint str_length TSRMLS_DC)
}
static int
-php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC)
+php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers TSRMLS_DC)
{
php_struct *ctx;
ap_filter_t *f;
@@ -100,29 +100,44 @@ php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_str
ctx = SG(server_context);
f = ctx->r->output_filters;
- val = strchr(sapi_header->header, ':');
-
- if (!val) {
- sapi_free_header(sapi_header);
- return 0;
+ switch(op) {
+ case SAPI_HEADER_DELETE:
+ apr_table_unset(ctx->r->headers_out, sapi_header->header);
+ return 0;
+
+ case SAPI_HEADER_DELETE_ALL:
+ apr_table_clear(ctx->r->headers_out);
+ return 0;
+
+ case SAPI_HEADER_ADD:
+ case SAPI_HEADER_REPLACE:
+ val = strchr(sapi_header->header, ':');
+
+ if (!val) {
+ sapi_free_header(sapi_header);
+ return 0;
+ }
+ ptr = val;
+
+ *val = '\0';
+
+ do {
+ val++;
+ } while (*val == ' ');
+
+ if (!strcasecmp(sapi_header->header, "content-type"))
+ ctx->r->content_type = apr_pstrdup(ctx->r->pool, val);
+ else if (op == SAPI_HEADER_REPLACE)
+ apr_table_set(ctx->r->headers_out, sapi_header->header, val);
+ else
+ apr_table_add(ctx->r->headers_out, sapi_header->header, val);
+
+ *ptr = ':';
+ return SAPI_HEADER_ADD;
+
+ default:
+ return 0;
}
- ptr = val;
-
- *val = '\0';
-
- do {
- val++;
- } while (*val == ' ');
-
- if (!strcasecmp(sapi_header->header, "content-type"))
- ctx->r->content_type = apr_pstrdup(ctx->r->pool, val);
- else if (sapi_header->replace)
- apr_table_set(ctx->r->headers_out, sapi_header->header, val);
- else
- apr_table_add(ctx->r->headers_out, sapi_header->header, val);
-
- *ptr = ':';
- return SAPI_HEADER_ADD;
}
static int
@@ -210,7 +225,7 @@ php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC)
php_struct *ctx = SG(server_context);
const apr_array_header_t *arr = apr_table_elts(ctx->r->subprocess_env);
char *key, *val;
- int new_val_len;
+ unsigned int new_val_len;
APR_ARRAY_FOREACH_OPEN(arr, key, val)
if (!val) {
@@ -335,6 +350,7 @@ static sapi_module_struct apache2_sapi_module = {
php_apache_sapi_register_variables,
php_apache_sapi_log_message, /* Log message */
php_apache_sapi_get_request_time, /* Get Request Time */
+ NULL, /* Child terminate */
STANDARD_SAPI_MODULE_PROPERTIES
};
@@ -471,17 +487,16 @@ static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
} else {
pbb = f->ctx = apr_palloc(f->r->pool, sizeof(*pbb));
pbb->bb = apr_brigade_create(f->r->pool, f->c->bucket_alloc);
- pbb->total_len = 0;
}
if(ap_save_brigade(NULL, &pbb->bb, &bb, f->r->pool) != APR_SUCCESS) {
- // Bad
+ /* Bad */
}
apr_brigade_cleanup(bb);
- // Check to see if the last bucket in this brigade, it not
- // we have to wait until then.
+ /* Check to see if the last bucket in this brigade, it not
+ * we have to wait until then. */
if(!APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(pbb->bb))) {
return 0;
}
@@ -518,16 +533,16 @@ static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
apply_config(conf);
php_apache_request_ctor(f, ctx TSRMLS_CC);
- // It'd be nice if we could highlight based of a zend_file_handle here....
- // ...but we can't.
+ /* It'd be nice if we could highlight based of a zend_file_handle here....
+ * ...but we can't. */
zfd.type = ZEND_HANDLE_STREAM;
zfd.handle.stream.handle = pbb;
zfd.handle.stream.reader = php_apache_read_stream;
- zfd.handle.stream.closer = php_apache_close_stream;
- zfd.handle.stream.fteller = php_apache_fteller_stream;
- zfd.handle.stream.interactive = 0;
+ zfd.handle.stream.closer = NULL;
+ zfd.handle.stream.fsizer = php_apache_fsizer_stream;
+ zfd.handle.stream.isatty = 0;
zfd.filename = f->r->filename;
zfd.opened_path = NULL;
@@ -713,20 +728,20 @@ static size_t php_apache_read_stream(void *handle, char *buf, size_t wantlen TSR
readlen = wantlen;
apr_brigade_flatten(rbb, buf, &readlen);
apr_brigade_cleanup(rbb);
- pbb->total_len += readlen;
return readlen;
}
-static void php_apache_close_stream(void *handle TSRMLS_DC)
-{
- return;
-}
-
-static long php_apache_fteller_stream(void *handle TSRMLS_DC)
+static size_t php_apache_fsizer_stream(void *handle TSRMLS_DC)
{
php_apr_bucket_brigade *pbb = (php_apr_bucket_brigade *)handle;
- return pbb->total_len;
+ apr_off_t actual = 0;
+
+ if (apr_brigade_length(pbb->bb, 1, &actual) == APR_SUCCESS) {
+ return actual;
+ }
+
+ return 0;
}
AP_MODULE_DECLARE_DATA module php5_module = {