The input filter in the apache2filter doesn't serve any real purpose
as PHP is not transforming any of the data.

IMHO, it would be better if it switched to just grabbing the input
when it needs it via the sapi_read_post function.

Please let me know if you have any questions.  -- justin

Index: sapi/apache2filter/php_apache.h
===================================================================
RCS file: /repository/php4/sapi/apache2filter/php_apache.h,v
retrieving revision 1.14
diff -u -r1.14 php_apache.h
--- sapi/apache2filter/php_apache.h     18 Apr 2002 22:10:57 -0000      1.14
+++ sapi/apache2filter/php_apache.h     10 Jun 2002 20:56:57 -0000
@@ -34,12 +34,6 @@
        int state;
        request_rec *r;
        ap_filter_t *f; /* downstream output filters after the PHP filter. */
-       /* 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;
Index: sapi/apache2filter/sapi_apache2.c
===================================================================
RCS file: /repository/php4/sapi/apache2filter/sapi_apache2.c,v
retrieving revision 1.77
diff -u -r1.77 sapi_apache2.c
--- sapi/apache2filter/sapi_apache2.c   8 Jun 2002 18:11:03 -0000       1.77
+++ sapi/apache2filter/sapi_apache2.c   10 Jun 2002 20:56:57 -0000
@@ -127,22 +127,32 @@
 static int
 php_apache_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC)
 {
-       int n;
-       int to_read;
        php_struct *ctx = SG(server_context);
+       request_rec *r = ctx->r;
+       apr_bucket_brigade *brigade;
+       apr_status_t rv;
+       apr_off_t length;
+
+       brigade = apr_brigade_create(r->pool, r->connection->bucket_alloc);
+
+       /* The contract here is that we can not read more than count_bytes. */
+       rv = ap_get_brigade(r->input_filters, brigade, AP_MODE_READBYTES,
+                           APR_BLOCK_READ, count_bytes);
+       if (rv != APR_SUCCESS) {
+           return 0;
+       }
+
+       rv = apr_brigade_length(brigade, 1, &length);
+       if (rv != APR_SUCCESS) {
+           return 0;
+       }
+
+       rv = apr_brigade_flatten(brigade, buf, length);
+       if (rv != APR_SUCCESS) {
+           return 0;
+       }
 
-       to_read = ctx->post_len - ctx->post_idx;
-       n = MIN(to_read, count_bytes);
-       
-       if (n > 0) {
-               memcpy(buf, ctx->post_data + ctx->post_idx, n);
-               ctx->post_idx += n;
-       } else {
-               if (ctx->post_data) free(ctx->post_data);
-               ctx->post_data = NULL;
-       }
-
-       return n;
+       return length;
 }
 
 static char *
@@ -261,44 +271,6 @@
        STANDARD_SAPI_MODULE_PROPERTIES
 };
 
-static int php_input_filter(ap_filter_t *f, apr_bucket_brigade *bb, 
-               ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes)
-{
-       php_struct *ctx;
-       long old_index;
-       apr_bucket *b;
-       const char *str;
-       apr_size_t n;
-       apr_status_t rv;
-       TSRMLS_FETCH();
-
-       if (f->r->proxyreq) {
-               return ap_get_brigade(f->next, bb, mode, block, readbytes);
-       }
-
-       ctx = SG(server_context);
-       if (ctx == NULL) {
-               ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, f->r,
-                                        "php failed to get server context");
-               return HTTP_INTERNAL_SERVER_ERROR;
-       }
-
-       if ((rv = ap_get_brigade(f->next, bb, mode, block, readbytes)) != APR_SUCCESS) 
{
-               return rv;
-       }
-
-       APR_BRIGADE_FOREACH(b, bb) {
-               apr_bucket_read(b, &str, &n, 1);
-               if (n > 0) {
-                       old_index = ctx->post_len;
-                       ctx->post_len += n;
-                       ctx->post_data = realloc(ctx->post_data, ctx->post_len + 1);
-                       memcpy(ctx->post_data + old_index, str, n);
-               }
-       }
-       return APR_SUCCESS;
-}
-
 static void php_apache_request_ctor(ap_filter_t *f, php_struct *ctx TSRMLS_DC)
 {
        char *content_type;
@@ -315,8 +287,6 @@
        f->r->no_local_copy = 1;
        content_type = sapi_get_default_content_type(TSRMLS_C);
        f->r->content_type = apr_pstrdup(f->r->pool, content_type);
-       SG(request_info).post_data = ctx->post_data;
-       SG(request_info).post_data_length = ctx->post_len;
        efree(content_type);
        apr_table_unset(f->r->headers_out, "Content-Length");
        apr_table_unset(f->r->headers_out, "Last-Modified");
@@ -549,7 +519,6 @@
        ap_hook_insert_filter(php_insert_filter, NULL, NULL, APR_HOOK_MIDDLE);
        ap_hook_post_read_request(php_post_read_request, NULL, NULL, APR_HOOK_MIDDLE);
        ap_register_output_filter("PHP", php_output_filter, AP_FTYPE_RESOURCE);
-       ap_register_input_filter("PHP", php_input_filter, AP_FTYPE_RESOURCE);
 }
 
 AP_MODULE_DECLARE_DATA module php4_module = {

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to