Bug #60826 [Com]: raw POST data missing with chunked encoding, FastCGI

From: Date: Wed, 28 Apr 2021 09:35:01 +0000
Subject: Bug #60826 [Com]: raw POST data missing with chunked encoding, FastCGI
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233604@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60826&edit=1 ID: 60826 Comment by: mdiss at talk21 dot com Reported by: clarkwise at gmail dot com Summary: raw POST data missing with chunked encoding, FastCGI Status: Not a bug 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: @ribarra Apache's bug for this is here https://bz.apache.org/bugzilla/show_bug.cgi?id=57087 and has apparently been fixed in Apache/2.4.47! Not had chance to test it yet. Previous Comments: ------------------------------------------------------------------------ [2021-02-16 22:50:49] ribarra at expedienteazul dot com Problem persists in Amazon Linux 2 distro. PHP 7.2.34 FPM Server version: Apache/2.4.46 () If I post a multipart/form-data with Content-Length defined it works, however if I post a multipart/form-data with Transfer-Encoding: chunked only, PHP doesn't get any of the _PÖST or _FILES variables. -= WORKING =- OST /upload.php HTTP/1.1 content-type: multipart/form-data; boundary=--------------------------657923799994993493862187 Host: 52.70.217.5 Content-Length: 2772 Connection: close --c67c245a-C-- ----------------------------657923799994993493862187^M Content-Disposition: form-data; name="my_field"^M ^M test^M ----------------------------657923799994993493862187^M Content-Disposition: form-data; name="my_logo"; filename="logo.png"^M Content-Type: image/png^M ^M <89>PNG^M.... -=NOT WORKING=- POST /upload.php?type=win HTTP/1.1 content-type: multipart/form-data; boundary=--------------------------701658193841349554663905 Host: 52.70.217.5 Connection: close Transfer-Encoding: chunked --486c8a2a-C-- ----------------------------701658193841349554663905^M Content-Disposition: form-data; name="my_field"^M ^M test^M ----------------------------701658193841349554663905^M Content-Disposition: form-data; name="my_logo"; filename="logo.png"^M Content-Type: image/png^M ^M <89>PNG^M... ------------------------------------------------------------------------ [2020-02-27 17:50:32] cmb@php.net In a strict sense this is indeed not a PHP bug, because the CGI specification (which is only informational, though), mandates[1]: | As transfer-codings are not supported on the request-body, the | server MUST remove any such codings from the message-body, and | recalculate the CONTENT_LENGTH. If this is not possible (for | example, because of large buffering requirements), the server | SHOULD reject the client request. However, even though this is not done by IIS, its behavior still appears to be reasonable, since it acknowledges the `Expect: 100-continue header by immediately responding with HTTP/1.1 100 Continue`, and then calls php-cgi.exe with CONTENT_LENGTH=-1 and makes the full payload available on stdin. So it seems the (F)CGI SAPI *could* support chunked uploads in combination with IIS. I have attached iis-cgi-chunked-poc as *PoC* for IIS and CGI only (not FCGI). [1] <https://tools.ietf.org/html/rfc3875#section-4.1.2> ------------------------------------------------------------------------ [2020-02-27 17:50:23] cmb@php.net The following patch has been added/updated: Patch Name: iis-cgi-chunked-poc Revision: 1582825823 URL: https://bugs.php.net/patch-display.php?bug=60826&patch=iis-cgi-chunked-poc&revision=1582825823 ------------------------------------------------------------------------ [2018-02-05 09:03:17] sukarsa at ingenovie dot com Hi, Is there any solution to request with chunked encoding with php? I observe that server is waiting indefinitely until client time-out and then process the packet with empty body. I'm using php 7.2 and I think it still have this problem. ------------------------------------------------------------------------ [2016-06-27 23:47:45] ravikumar dot nie at gmail dot com Well I am still facing this problem. Any hints to solve this issue. I am using fastcgi and php and trying to read the POST Data sent as transfer-encoding:chunked. Appreciate any help ------------------------------------------------------------------------ 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

« previous php.bugs (#233604) next »