php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79033 Curl timeout error with specific url and post
Submitted: 2019-12-26 01:07 UTC Modified: 2019-12-28 18:05 UTC
Votes:2
Avg. Score:2.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dav dot tur19 at gmail dot com Assigned: cmb (profile)
Status: Closed Package: cURL related
PHP Version: 7.4.1 OS: linux/windows
Private report: No CVE-ID: None
 [2019-12-26 01:07 UTC] dav dot tur19 at gmail dot com
Description:
------------
If an empty array is set to CURLOPT_POSTFIELDS, the request will timeout, this does not happen on php7.3 or with CURLOPT_POSTFIELDS with other values.
The problem occurs on both windows and linux.

Test script:
---------------
<?php
$token = '12341234:WASDWASD';
$method = 'getMe';
$args = [];

$curlRequestSession = curl_init();
curl_setopt_array($curlRequestSession, [
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_POST => true,
	CURLOPT_TIMEOUT => 3,
	CURLOPT_URL => 'https://api.telegram.org/bot' . $token . '/' . $method,
	CURLOPT_POSTFIELDS => $args,
]);

$response = curl_exec($curlRequestSession);
if($response === false) {
	echo curl_error($curlRequestSession) . PHP_EOL . var_export(curl_getinfo($curlRequestSession), true) . PHP_EOL;
} else {
	echo 'Success: ' . $response . PHP_EOL;
}



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-27 21:58 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2019-12-27 21:58 UTC] cmb@php.net
This regression has been introduced with commit a83b68b[1].

[1] <http://git.php.net/?p=php-src.git;a=commit;h=a83b68ba56714bfa06737a61af795460caa4a105>
 [2019-12-28 09:50 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c47b18a222ceb1d78810d2822170cbf6e110a98c
Log: Fix #79033: Curl timeout error with specific url and post
 [2019-12-28 09:50 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2019-12-28 14:53 UTC] dav dot tur19 at gmail dot com
have you checked the test file? the problem seemed to occur only on that specific url (https://api.telegram.org/bot12341234:WASDWASD/getMe), I couldn't even reproduce it on my webserver by setting 401 as http code and some other header.
 [2019-12-28 15:17 UTC] cmb@php.net
Yes, I've also checked with the given test script, and that
returned "success" with the fix.  You can verify with
<https://windows.php.net/downloads/snaps/php-7.4/r6d1dff6/>.
 [2019-12-28 16:17 UTC] dav dot tur19 at gmail dot com
I mean that the bug does not occur unless under certain conditions, for example with a normal page it did not occur
 [2019-12-28 18:05 UTC] cmb@php.net
With PHP 7.4.1, the request that is sent is

POST /bot12341234:WASDWASD/getMe HTTP/1.1
Host: api.telegram.org
Accept: */*
Content-Length: 46
Content-Type: multipart/form-data; boundary=------------------------3f43f848cba8eb3d

--------------------------3f43f848cba8eb3d--

To my knowledge, this is a valid request, but apparently the empty
part may cause issues, and since former PHP versions sent

POST /bot12341234:WASDWASD/getMe HTTP/1.1
Host: api.telegram.org
Accept: */*
Content-Length: 0

it seems to be prudent to generally switch back to that behavior.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Oct 26 01:01:23 2020 UTC