|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-01-20 21:15 UTC] clarkwise at gmail dot com
Description: ------------ When a POST is sent with the header "Transfer-Encoding: chunked" and PHP 5.3 is running via FastCGI, $HTTP_RAW_POST_DATA is not set. In IIS, the receiving PHP process simply hangs and does not execute at all. If chunked encoding is not set, it executes successfully and $HTTP_RAW_POST_DATA is populated. Comparing ISAPI to FastCGI (using PHP 5.2 which has both implementations), PHP ISAPI works fine with "Transfer-Encoding: chunked" but PHP FastCGI does not. This issue also occurred running Linux/Apache with PHP 5.3 FastCGI. In that scenario, the PHP process did not completely hang, but $HTTP_RAW_POST_DATA and php://input were empty when the script executed. Test script: --------------- Two files, postsend.php and postreceive.php, can be found within the question here: http://stackoverflow.com/questions/8899239/http-raw-post-data-not-being-populated-after-upgrade-to-php-5-3 Expected result: ---------------- $HTTP_RAW_POST_DATA and the php://input stream should contain the raw binary data that was sent in the POST. Actual result: -------------- On Windows/IIS, the PHP process hangs and does not execute. On Linux/Apache, the PHP process executes but $HTTP_RAW_POST_DATA and php://input are empty. Patchesiis-cgi-chunked-poc (last revision 2020-02-27 17:50 UTC by cmb@php.net)IIS-FastCGI-transfer-encoding-chuncked (last revision 2012-04-11 13:52 UTC by andres at fenestrae dot com) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 23:00:01 2025 UTC |
Same problem here. Apache 2.2.15 and PHP 5.3.10 running as FastCGI. POST datas sent with "Transfer-encoding: chunked" are not received as they should be. The raw request looks like this : POST receiveChunk.php HTTP/1.1 User-Agent: PECL::HTTP/1.7.2 (PHP/5.3.8) Host: www.test.fr Accept: */* Pragma: no-cache Connection: keep-alive Cache-Control: no-cache Content-Length: 682668 Transfer-Encoding: chunked Content-Type: text/html; charset=UTF-8 3ff4 (here, the datas) 0 and the request as the receiving script sees it : User-Agent: PECL::HTTP/1.7.2 (PHP/5.3.8) Host: www.test.fr Accept: */* Pragma: no-cache Connection: close Cache-Control: no-cache As you can see, the request body is empty. However, this problem does not occur when PHP runs as mod_php under Apache. Problem confirmed under PHP 5.3.8 and 5.3.9. I don't know if that is a PHP bug and maybe the developers could confirm or not that the request body are wrong before it reaches PHP. I think that it appears to be a mod_fcgid bug and should be reported as one to Apache bug list. Here are the scripts to reproduce the bug : sendChunk.php : <?php $fileContentToUp = 'ICAgICAgICAgIgICAgIA=='; $header_array = array( 'Pragma' => 'no-cache', 'Connection' => 'keep-alive', 'Cache-Control' => 'no-cache', 'Content-Length' => strlen($fileContentToUp) , 'Transfer-Encoding' => 'chunked' ); $options = array(headers => $header_array); $r = new HttpRequest('receiveChunk.php', HTTP_METH_POST, $options); $r->setContentType('text/html; charset=UTF-8'); $r->setBody($fileContentToUp); $result = $r->send(); echo '$r->getRawRequestMessage() => '; print_r($r->getRawRequestMessage()); echo "\n\n"; echo '$r->send()->getBody() => '; print_r($r->send()->getBody()); echo "\n\n"; ?> receiveChunk.php : <?php $HttpResponse = new HttpResponse(); echo 'http_get_request_header => '."\n"; print_r($HttpResponse->getRequestHeaders()); echo "\n\n"; echo 'http_get_request_body => '."\n"; print_r($HttpResponse->getRequestBody()); echo "\n\n"; ?> Hope that helps.