CURLFile POST missing Content-Length header
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
php |
Unknown
|
Unknown
|
|||
php7.4 (Ubuntu) |
Fix Released
|
Medium
|
Bryce Harrington | ||
Focal |
Fix Released
|
Medium
|
Bryce Harrington |
Bug Description
[Impact]
* PHP7.4.3 has an issue with cURL where it is defaulting to chunked mode when transferring a file via POST. Setting the HTTP version does not impact it. For third-party servers that don't support chunked but expect a content-length, there is no way to make it work.
* See https:/
[Test Case]
* Here is a sample similar to what I'm doing, with url/token/file removed:
-----------------
<?php
$url = '';
$access_token = '';
$file = '';
$ch = curl_init($url);
$options = [
CURLOPT_
CURLOPT_
CURLOPT_
'
'
],
CURLOPT_
CURLOPT_
CURLOPT_
CURLINFO_
CURLOPT_
];
$file = curl_file_
$data = ['file' => $file, 'name' => basename($file)];
$options[
curl_setopt_
$response = curl_exec($ch);
$curl_info = curl_getinfo($ch);
$curl_error = curl_error($ch);
curl_close($ch);
?>
-----------------
This works in Ubuntu 18, but not Ubuntu 20.
[Regression Potential]
The fix itself for this bug is reasonably straightforward, but it builds on an earlier patch that involved a fair bit of refactoring code.
This includes code which detects and adapts to libcurl > 7.56.0, so behavioral regressions narrowable to the newer versions of libcurl could potentially indicate a regression caused by this SRU.
[Other Info]
Upgrading Ubuntu's supported PHP version to 7.4.4 *should* fix the issue, or backporting the patch in the link I included.
package: php7.4 (7.4.3-
release: Ubuntu 20.04 LTS
Expect: PHP-cURL to POST HTTP1.1 multipart/form-data with automatically generated Content-Length and empty Transfer-Encoding headers.
Actual: PHP-cURL POSTS HTTP1.1 multipart/form-data with Transfer-Encoding: chunked and empty Content-Length headers.
Related branches
- Christian Ehrhardt (community): Approve
- Canonical Server: Pending requested
-
Diff: 615 lines (+587/-0)4 files modifieddebian/changelog (+15/-0)
debian/patches/0041-Fix-79019-Copied-cURL-handles-upload-empty-file.patch (+501/-0)
debian/patches/0042-Fix-79013-Content-Length-missing-when-posting-a-curl.patch (+68/-0)
debian/patches/series (+3/-0)
tags: | added: server-next |
Changed in php7.4 (Ubuntu): | |
importance: | Undecided → Medium |
tags: | added: patch |
description: | updated |
Changed in php7.4 (Ubuntu Focal): | |
status: | Incomplete → Triaged |
Changed in php7.4 (Ubuntu Focal): | |
importance: | Undecided → Medium |
assignee: | nobody → Bryce Harrington (bryce) |
description: | updated |
Hi Stephen - thanks for the report,
a merge of 7.4.5 is currently going on and will resolve this in groovy.
From there SRUs can be considered as needed.