Bug 63366

Summary: POST body is empty when REQUEST is send with transfer-encoding:chunked
Product: Apache httpd-2 Reporter: Max Cuttins <massimiliano.cuttini>
Component: mod_proxy_fcgiAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: NEW ---    
Severity: blocker    
Priority: P2    
Version: 2.4.39   
Target Milestone: ---   
Hardware: All   
OS: Linux   

Description Max Cuttins 2019-04-19 15:00:28 UTC
The POST raw data is completly empty when the POST is sent with "transfer-encoding: chunked". Read POST raw data as a stream should be the right way to handle this kind of transfer enconding, however it's completly useless.

<?php

$fp = fopen('php://input', 'rb');
stream_filter_append($fp, 'dechunk', STREAM_FILTER_READ);
$POST = stream_get_contents($fp);

?>

$POST is always empty if the request received has "transfer-econding:chuncked".

Same issue could be seen into all kind of handler:

- PHP CGI
- PHP FCGI
- PHP FCGI with FPM

This bug seems the consequences of this one:
https://bz.apache.org/bugzilla/show_bug.cgi?id=57087

However this is a more specific error and relates to more big issue.
Infact, by definition, with "transfer chuncked" there is no CONTENT-LENGTH at all and it's right that this it's not present. So, I would say that missing the CONTENT-LENGTH is right due to the design of the transfer chunked encoding.

Here the issue is not about the CONTENT-LENGTH but instead the issue is that the stream is not available in the php://input and is not readable causing dataloss on the POST value.
Comment 1 kisscool82 2020-04-28 13:45:26 UTC
I'm encountering the same bug. Please help us :(
Comment 2 kisscool82 2020-04-28 13:46:27 UTC
I'm encountering the same bug. Please help us :(
Comment 3 Felix Schwarz 2021-08-20 12:36:13 UTC
Can you try again with Apache 2.4.47+ and "SetEnv proxy-sendcl 1" ? As bug 57087 is fixed now I think this should just work.
Comment 4 AndrĂ¡s Parditka 2024-03-20 13:14:10 UTC
(In reply to Felix Schwarz from comment #3)
> Can you try again with Apache 2.4.47+ and "SetEnv proxy-sendcl 1" ? As bug
> 57087 is fixed now I think this should just work.

This solved the issue for me.