From: Michael Wallner Date: Thu, 29 Dec 2005 18:09:29 +0000 (+0000) Subject: - PHP only reads the request body if the request method is POST X-Git-Tag: RELEASE_0_21_0~14 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=f054de24e749da7d137fcb561ce4eca724f25e46;p=m6w6%2Fext-http - PHP only reads the request body if the request method is POST --- 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; } /* }}} */