X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_api.c;h=6046052f1be597943442acb832b0109d00ea4b62;hb=fac50662a1ea545b40f15613f8c4806a1ed745b0;hp=a5ecb12ec66fbdae50e81974a144c526ddb841b0;hpb=a19f558421040b5396b3d76e6c4878d7eda85aba;p=m6w6%2Fext-http diff --git a/http_api.c b/http_api.c index a5ecb12..6046052 100644 --- a/http_api.c +++ b/http_api.c @@ -6,7 +6,7 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2005, Michael Wallner | + | Copyright (c) 2004-2006, Michael Wallner | +--------------------------------------------------------------------+ */ @@ -29,8 +29,6 @@ # include "php_http_exception_object.h" #endif -ZEND_EXTERN_MODULE_GLOBALS(http); - PHP_MINIT_FUNCTION(http_support) { HTTP_LONG_CONSTANT("HTTP_SUPPORT", HTTP_SUPPORT); @@ -321,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; } /* }}} */