From: Michael Wallner Date: Tue, 22 Apr 2014 09:58:06 +0000 (+0200) Subject: fix JSON POST handler in PHP-5.6+ X-Git-Tag: RELEASE_2_0_7~26 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=8ec2c825719482e62222163a300b0e18319591d0;p=m6w6%2Fext-http fix JSON POST handler in PHP-5.6+ --- diff --git a/php_http_env.c b/php_http_env.c index fdc7b96..30ee32d 100644 --- a/php_http_env.c +++ b/php_http_env.c @@ -957,8 +957,11 @@ static SAPI_POST_HANDLER_FUNC(php_http_json_post_handler) size_t json_len = 0; #if PHP_VERSION_ID >= 50600 - php_http_message_body_to_string(php_http_env_get_request_body(TSRMLS_C), - &json_str, &json_len, 0, -1); + if (SG(request_info).request_body) { + /* FG(stream_wrappers) not initialized yet, so we cannot use php://input */ + php_stream_rewind(SG(request_info).request_body); + json_len = php_stream_copy_to_mem(SG(request_info).request_body, &json_str, PHP_STREAM_COPY_ALL, 0); + } #else json_str = SG(request_info).raw_post_data; json_len = SG(request_info).raw_post_data_length;