curl_getinfo($ch, CURLINFO_CONTENT_TYPE) returns false when Content-Type header is not set
Open
Nobody has claimed this yet.
Bug
Extension: curl
Status: Needs Triage
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code:
<?php
$ch = curl_init();
$url = 'https://epapucs.hu/wp-content/uploads/2024/11/F318482161_2.webp';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, $url);
curl_exec($ch);
$ct = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
var_dump($ct);
$info = curl_getinfo($ch)['content_type'];
var_dump($info);
curl_close($ch);
Resulted in this output:
bool(false)
NULL
I'd expect these two values to be the same. It's hard to handle errors when a false value is returned when there's no error.
These are the first elements of curl_getinfo associative_array:
array(41) {
["url"]=>
string(63) "https://epapucs.hu/wp-content/uploads/2024/11/F318482161_2.webp"
["content_type"]=>
NULL
["http_code"]=>
int(200)
PHP Version
PHP 8.4.1
Operating System
macOS 15.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report provides no repository file or test entry point. Start by running the supplied PHP reproduction against a response without a Content-Type header, then inspect how the scalar and associative curl_getinfo results are produced. Done means the two forms have consistent, documented behavior for this response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100