[php-src] Issue #11197: PHp curl request return with error
| From: | kiran4455 | Date: | Sat, 06 May 2023 13:16:42 +0000 |
| Subject: | [php-src] Issue #11197: PHp curl request return with error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244389@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11197
Author: kiran4455
### Description
The following code:
```php
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => FALSE,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 1,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($requestArr),
CURLOPT_HTTPHEADER => [
"accept: application/json",
"cache-control: no-cache",
"content-type: application/json"
],
]);
try {
$response = curl_exec($curl);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
print_r($err);
}
} catch (Exception $e) {
echo $e->getMessage();
}
```
Resulted in this output:
```
Operation timed out after 1000 milliseconds with 0 bytes received
```
But I expected this output instead:
```
Older version return no error
```
### PHP Version
8.2.4
### Operating System
22.04