]> granicus.if.org Git - php/commitdiff
POST handler for my ubercool new Apache 2.0 function ap_get_req_body.
authorSascha Schumann <sas@php.net>
Fri, 27 Oct 2000 23:02:20 +0000 (23:02 +0000)
committerSascha Schumann <sas@php.net>
Fri, 27 Oct 2000 23:02:20 +0000 (23:02 +0000)
sapi/apache2filter/php_apache.h
sapi/apache2filter/sapi_apache2.c

index bd5e277c78063cf2d09efe4178c9e5b4dce15d81..f1feb4f65adfec69dd011b32e639127226965ae2 100644 (file)
@@ -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);
index 1dcdc2351dbbc00b281d3e88afe7b77ea144eb62..e30b8e4fdb9c790492eaf58497bca10569c75c37 100644 (file)
@@ -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 */