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

 ID:                 60826
 Comment by:         andres at fenestrae 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:

@florian dot fernandez at navaho dot fr

Florian,

I'm afraid i cannot help you any further on Linux.
The solution is not specific for Windows.
What I did to tackle the problem at first is to write a small program that ran 
instead of php-cgi which copied whatever it received on stdin to an other a 
mailslot.
This output I fed into php-cgi to reproduce an pinpoint the cause. 

Regards Andre


Previous Comments:
------------------------------------------------------------------------
[2012-04-23 10:59:25] florian dot fernandez at navaho dot fr

Maybe I did something wrong but the patch doesn't seem to work with PHP 5.4.0 
on Linux.

------------------------------------------------------------------------
[2012-04-23 08:08:19] florian dot fernandez at navaho dot fr

Sorry, I didn't see it before. I'll give it a try with 5.4.0

------------------------------------------------------------------------
[2012-04-23 08:00:32] andres at fenestrae dot com

florian dot fernandez at navaho dot fr 

I have been able to try my solution in combination with 5.2.17.

See the patches in this topic for the exact code-changes I made.

------------------------------------------------------------------------
[2012-04-23 07:52:12] florian dot fernandez at navaho dot fr

@ andres at fenestrae dot com

Have you been able to try what you suggested in your last post ?

------------------------------------------------------------------------
[2012-04-11 13:24:05] andres at fenestrae dot com

The problem lies in php-cgi.exe.
I have been able to reproduce the problem on IIS 7.5.
In Fast-cgi the data is delivered using method similar to chunking.

In case of "Transfer-Encoding: chunked" IIS supplies Content-length:-1 in the 
request data, which is casted to uint in sapi_cgi_read_post. Causing the 
routine to read data until it has read the full 4G (2^32-1).
Also, both the methods sapi_cgi_read_post(cgi_main.c) and fcgi_read(fastcgi.c) 
try to read the complete buffer time after time, causing the end-marker 
(0-sized chunk) only to be seen when it would be at buffer-boundary. However 
the sapi_cgi_read_post funtion is called several times after the actual content 
has been read causing the fcgi_read method to block.
I expect similar cause to apply for apache.

Solution appears
1) do not loop in fcgi_read; this way when reading the final marker, it is 
returned to the calling code.
2) Set SG(request_info).content_length to SG(read_post_bytes) + read_bytes when 
tmp_read_bytes ==0 && SG(request_info).content_length == -1

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


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

Reply via email to