Bug #79013 [ReO]: Content-Length missing when posting a curlFile with curl
| From: | cmb@php.net | Date: | Mon, 02 Mar 2020 18:01:16 +0000 |
| Subject: | Bug #79013 [ReO]: Content-Length missing when posting a curlFile with curl | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225844@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79013&edit=1
ID: 79013
Updated by: cmb@php.net
Reported by: christian at klemmer dot io
Summary: Content-Length missing when posting a curlFile with
curl
Status: Re-Opened
Type: Bug
Package: cURL related
Operating System: debian 10.2
PHP Version: 7.4.1
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> Is there any alternative to who is running with 7.4.3?
If you can enforce HTTP/2, that should be sufficient.
Previous Comments:
------------------------------------------------------------------------
[2020-03-02 15:10:53] carlospauluk at gmail dot com
Is there any alternative to who is running with 7.4.3?
------------------------------------------------------------------------
[2020-02-28 10:12:55] cmb@php.net
The following pull request has been associated:
Patch Name: Fix #79013: Content-Length missing when posting a curlFile with curl
On GitHub: https://github.com/php/php-src/pull/5219
Patch: https://github.com/php/php-src/pull/5219.patch
------------------------------------------------------------------------
[2020-02-20 12:41:43] cmb@php.net
Related To: Bug #79289
------------------------------------------------------------------------
[2020-02-13 18:53:38] andrewscaya at yahoo dot ca
I can confirm that when PHP 7.4 reverts to using chunked file uploads, PHP scripts that were working
fine on PHP 7.2 or 7.3, no longer post anything to the server.
EXAMPLE SCRIPT
--------------
/* http://example.com:
<?php var_dump($_FILES); ?>
*/
// Create a cURL handle
$ch = curl_init('http://example.com/index.php');
$cfile = curl_file_create('example.txt','text/plain','test_name');
// Assign POST data
$postdata = ['file' => $cfile];
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
// Execute the handle
echo curl_exec($ch);
ACTUAL RESULTS
--------------
Using cURL 7.68.0 and PHP 7.3
-----------------------------
$_FILES:
/srv/www/index.php:5:
array (size=1)
'file' =>
array (size=5)
'name' => 'test_name' (length=9)
'type' => 'text/plain' (length=10)
'tmp_name' => '/tmp/php69gfI5' (length=14)
'error' => 0
'size' => 25
POST /index.php HTTP/1.1
Content-Type: multipart/form-data; boundary=------------------------63a96cbe43cf28f8
Content-Length: 212
Accept: */*
Host: example.com
Using cURL 7.68.0 and PHP 7.4
-----------------------------
$_FILES:
/srv/www/index.php:5:
array (size=0)
empty
POST /index.php HTTP/1.1
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------46680d0956db253f
Transfer-Encoding: chunked
Accept: */*
Host: example.com
EXPECTED RESULTS
----------------
Should be the same.
------------------------------------------------------------------------
[2020-01-24 13:11:41] cmb@php.net
For me, using current PHP-7.4 the test script outputs:
Linux, curl 7.64.0:
POST / HTTP/2
Host: example.com
Accept: */*
Transfer-Encoding: chunked
Content-Type: multipart/form-data; boundary=------------------------df0efab1e65ad7e7
Linux, curl 7.68.0:
POST / HTTP/2
Host: example.com
accept: */*
content-type: multipart/form-data; boundary=------------------------f55b79edfe19cb82
Windows, curl 7.67.0
POST / HTTP/2
Host: example.com
accept: */*
content-type: multipart/form-data; boundary=------------------------1e758282c5b98dfb
So obviously a bug in libcurl which has been fixed in the meantime.
------------------------------------------------------------------------
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=79013
--
Edit this bug report at https://bugs.php.net/bug.php?id=79013&edit=1