Req #51191 [Opn]: Request body is 0-size when chunked requests are used

From: Date: Sat, 27 Nov 2021 19:44:02 +0000
Subject: Req #51191 [Opn]: Request body is 0-size when chunked requests are used
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238010@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=51191&edit=1

 ID:                 51191
 Updated by:         bukka@php.net
 Reported by:        evert at rooftopsolutions dot nl
 Summary:            Request body is 0-size when chunked requests are
                     used
 Status:             Open
 Type:               Feature/Change Request
 Package:            CGI/CLI related
 Operating System:   *
 PHP Version:        5.3.1
 Block user comment: N
 Private report:     N

 New Comment:

I think FastCGI spec is quite clear about using CGI/1.1 in responder - see http://www.mit.edu/~yandros/doc/specs/fcgi-spec.html#S6.2
. It means that CONTENT_LENGTH is required by spec because it is required by CGI/1.1. Thus I
don't think this is a bug and to change that, we would need to change a spec.


Previous Comments:
------------------------------------------------------------------------
[2021-09-23 11:40:33] cmb@php.net

See <https://bugs.php.net/bug.php?id=60826#1582825832>.
 However,
the FastCGI specs are less clear on that, and I tend to agree that
it makes sense to support chunked requests.

------------------------------------------------------------------------
[2021-09-23 11:01:48] tim dot siebels at iserv dot eu

The following pull request has been associated:

Patch Name: Fixed reading in streamed body using fastcgi
On GitHub:  https://github.com/php/php-src/pull/7509
Patch:      https://github.com/php/php-src/pull/7509.patch

------------------------------------------------------------------------
[2021-09-15 07:11:36] tim dot siebels at iserv dot eu

We are encountering this issue when disabling fastcgi_request_buffering in nginx.
Apparently, others are too [0,1]. The older bug [1] led to apache "fixing" this issue by
buffering all chunked requests.

I've opened a thread on the nginx mailinglist [2] regarding this. The assessment there is, that
fastcgi is a inherently chunked protocol and thus php should not depend on the CONTENT_LENGTH
variable, and rather read out all the fastcgi records to get the body.

How do you feel about this? Do you agree that this should be fixed in php?

[0] https://trac.cyberduck.io/wiki/help/en/howto/mount/issues/fastcgi
[1] https://bugs.php.net/bug.php?id=60826
[2] http://mailman.nginx.org/pipermail/nginx/2021-September/061029.html

------------------------------------------------------------------------
[2010-08-04 09:14:01] evert at rooftopsolutions dot nl

I can confirm this is only happening for CGI and FastCGI.

Nginx and Lighttpd don't seem to support this feature at all, and simply return 411 Length
Required, but with Apache the request goes through but PHP ends up with an empty request body.

------------------------------------------------------------------------
[2010-08-04 08:05:38] jpa at php dot mail dot kapsi dot fi

Here is a test case for the bug, using netcat to send the request:
http://koti.kapsi.fi/~jpa/stuff/other/php-chunked-test.tgz

A simple bash cgi script correctly receives the request, so the problem is with PHP's CGI and
FCGI interfaces. Instead of requiring a CONTENT_LENGTH header, PHP should simply read to EOF on
stdin when TRANSFER_ENCODING is chunked.

------------------------------------------------------------------------


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=51191


--
Edit this bug report at https://bugs.php.net/bug.php?id=51191&edit=1


Thread (8 messages)

« previous php.bugs (#238010) next »