Handle better curl calls - give better error feedback
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 205
- Forks
- 129
- PR merge metrics
- No merged PRs in 30d
Description
Many problems (and unnecessary issues) cames from not friendly error messages.
When AbstractAuth.php call curl on makeRequest, it don't handle many possible errors (server faults, timeouts, and things like that), that make us think that mauti api are failing.
It just say The response has unexpected status code (0) or something like that.
In my case now, I was getting that The response has unexpected status code (0) message on my prod server. Checking, I changed in prod some lines of makeRequest just for debug it:
//Make CURL request
$curl = curl_init();
curl_setopt_array($curl, $options);
$content = curl_exec($curl);
if ($content === false) {
var_dump(curl_error($curl));
var_dump(curl_errno($curl));
}
$response = new Response($content, curl_getinfo($curl));
And then I got:
string(81) "Failed to connect to mautic.desafiodocodigo.com.br port 443: Connection timed out"
int(7)
Checking curl errors I saw many error codes (other than 7) that could happen... but mautic api just says 'The response has unexpected status code (0)'
It's just a suggestion, to easy our life using your such amazing tool. :)
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Contributor guide
No contributing guide indexed for this repository
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
Start in AbstractAuth.php at makeRequest, where curl_exec and the Response are handled. Reproduce a failed request and inspect the curl error and errno shown in the issue, then trace how the resulting response becomes status code 0. Done means curl failures such as timeouts produce useful error feedback instead of only the generic unexpected-status message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100