Bug 63366 - POST body is empty when REQUEST is send with transfer-encoding:chunked
Summary: POST body is empty when REQUEST is send with transfer-encoding:chunked
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_proxy_fcgi (show other bugs)
Version: 2.4.39
Hardware: All Linux
: P2 blocker (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-19 15:00 UTC by Max Cuttins
Modified: 2019-04-19 15:00 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.