From: Sascha Schumann Date: Fri, 27 Oct 2000 23:02:20 +0000 (+0000) Subject: POST handler for my ubercool new Apache 2.0 function ap_get_req_body. X-Git-Tag: php-4.0.4RC3~483 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d943274af77c18a90fcae7ff19d1cfddcc4a4b93;p=php POST handler for my ubercool new Apache 2.0 function ap_get_req_body. --- diff --git a/sapi/apache2filter/php_apache.h b/sapi/apache2filter/php_apache.h index bd5e277c78..f1feb4f65a 100644 --- a/sapi/apache2filter/php_apache.h +++ b/sapi/apache2filter/php_apache.h @@ -5,6 +5,7 @@ typedef struct php_struct { int state; ap_bucket_brigade *bb; ap_filter_t *f; + int post_index; } php_struct; void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf); diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c index 1dcdc2351d..e30b8e4fdb 100644 --- a/sapi/apache2filter/sapi_apache2.c +++ b/sapi/apache2filter/sapi_apache2.c @@ -88,8 +88,22 @@ php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers SLS_DC) static int php_apache_sapi_read_post(char *buf, uint count_bytes SLS_DC) { + long total; + long n; + long start; + php_struct *ctx = SG(server_context); + + start = ctx->post_index; + for (total = 0; total < count_bytes; total += n) { + n = ap_get_req_body(ctx->f->r, count_bytes - total, &ctx->post_index); + if (n <= 0) break; + } - return 0; + if (total > 0) { + memcpy(buf, &ctx->f->r->req_body[start], total); + } + + return total; } static char * @@ -220,15 +234,15 @@ static int php_filter(ap_filter_t *f, ap_bucket_brigade *bb) SLS_FETCH(); apply_config(conf); - php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC); ctx->state++; /* XXX: Lots of startup crap. Should be moved into its own func */ PG(during_request_startup) = 0; SG(sapi_headers).http_response_code = 200; + SG(request_info).content_type = apr_table_get(f->r->headers_in, "Content-Type"); SG(request_info).query_string = f->r->args; - SG(request_info).request_method = f->r->method; + SG(request_info).request_method = (char *) f->r->method; SG(request_info).request_uri = f->r->uri; f->r->no_cache = f->r->no_local_copy = 1; content_type = sapi_get_default_content_type(SLS_C); @@ -239,6 +253,8 @@ static int php_filter(ap_filter_t *f, ap_bucket_brigade *bb) apr_table_unset(f->r->headers_out, "Expires"); auth = apr_table_get(f->r->headers_in, "Authorization"); php_handle_auth_data(auth SLS_CC); + + php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC); } /* moves all buckets from bb to ctx->bb */