Edit report at https://bugs.php.net/bug.php?id=60826&edit=1
ID: 60826 Comment by: clarkwise at gmail dot com Reported by: clarkwise at gmail dot com Summary: raw POST data missing with chunked encoding, FastCGI Status: Assigned Type: Bug Package: CGI/CLI related Operating System: Windows XP PHP Version: 5.3.9 Assigned To: ab Block user comment: N Private report: N New Comment: Making the chunked request to a stock nginx 1.0.13 installation on Ubuntu yields a "411 Length Required" message, but enabling the ngx_chunkin module does indeed correctly serve the request and populate php://input and $HTTP_RAW_POST_DATA. This was done with both Ubuntu's distribution of PHP 5.3.6 and the php5.4-201203221530 snapshot. Previous Comments: ------------------------------------------------------------------------ [2012-03-13 05:58:19] florian dot fernandez at navaho dot fr First of all, the problem is still here with PHP 5.4 and Apache 2.4.1, I previously made the mistake to precise the content-length in my headers. So here is what I found. If you send chunked http request but do not send the content-length (as we should do using HTTP 1.1 protocol) the body part of the request is empty (php://input returns nothing). This result remains valid for the following configuration where PHP runs via FastCGI : PHP 5.3.10 - APACHE 2.4.1 PHP 5.3-201203101230 - APACHE 2.4.1 PHP 5.4 - APACHE 2.4.1 PHP 5.4-201203101230 - APACHE 2.4.1 The same configuration with PHP running as mod_php is fine, the body request is available through php://input. ------------------------------------------------------------------------ [2012-03-09 09:48:29] paj...@php.net Try a snapshot please, 5.3.10 has nothing else but security fixes unrelated to this issue. ------------------------------------------------------------------------ [2012-03-09 09:33:06] florian dot fernandez at navaho dot fr The problem seems to have been resolved with php 5.4.0 and apache 2.4.1. I can't reproduce it with this configuration and chunked http requests are now coming through to php now. I am going to try with php 5.3.10 and apache 2.4.1 and give feedback on where it goes. ------------------------------------------------------------------------ [2012-03-05 11:46:27] florian dot fernandez at navaho dot fr I forgot to mention that this is on a Linux system ------------------------------------------------------------------------ [2012-03-05 10:08:17] florian dot fernandez at navaho dot fr 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. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=60826 -- Edit this bug report at https://bugs.php.net/bug.php?id=60826&edit=1