From f054de24e749da7d137fcb561ce4eca724f25e46 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Thu, 29 Dec 2005 18:09:29 +0000 Subject: [PATCH] - PHP only reads the request body if the request method is POST --- http_api.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/http_api.c b/http_api.c index 07cb9f4..1eed789 100644 --- a/http_api.c +++ b/http_api.c @@ -319,6 +319,33 @@ PHP_HTTP_API STATUS _http_get_request_body_ex(char **body, size_t *length, zend_ *body = (char *) (dup ? estrndup(SG(request_info).raw_post_data, *length) : SG(request_info).raw_post_data); return SUCCESS; } + + /* PHP only reads POST */ + if (sapi_module.read_post) { + char buf[4096]; + int len; + + while (0 < (len = sapi_module.read_post(buf, sizeof(buf) TSRMLS_CC))) { + *body = erealloc(*body, *length + len + 1); + memcpy(*body + *length, buf, len); + *length += len; + (*body)[*length] = '\0'; + } + + /* check for error */ + if (len >= 0) { + /* connect to sapi module so it'll be freed */ + if (!dup) { + SG(request_info).raw_post_data = *body; + SG(request_info).raw_post_data_length = *length; + } + return SUCCESS; + } else { + STR_FREE(*body); + *length = 0; + } + } + return FAILURE; } /* }}} */ -- 2.30.2