0

cURL is enabled in the server. But it's showing some error from the curl_exec($curl) point. No other error is showing from curl_error($curl);

Fatal error: Original Handler not found! in /public_html/curl_test.php on line 18

The cURL package is curl-7.29.0-46.el7.x86_64.

Could anyone suggest me any solution or can help me to troubleshoot the issue?

if (!function_exists('curl_init')){
    die('Sorry cURL is not installed!');
}

$curl = curl_init();
curl_setopt_array($curl, Array(
    CURLOPT_URL            => 'http://someurl.com',
    CURLOPT_TIMEOUT        => 120,
    CURLOPT_CONNECTTIMEOUT => 30,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_ENCODING       => 'UTF-8'
));


if(curl_exec($curl) === false)
{
    echo 'Curl error: ' . curl_error($curl);
}
else
{
    $data = curl_exec($curl);
    echo 'Operation completed without any errors';
}

curl_close($curl);
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Banty Roy
  • 914
  • 6
  • 23
  • 1
    Have you tried the exact same code (or as close as possible) in a controlled environment, like your local server? –  Aug 17 '18 at 13:25
  • The request website has this are original handler? https://stackoverflow.com/questions/7564832/how-to-bypass-access-control-allow-origin – MrKampf Aug 17 '18 at 13:27
  • @RiggsFolly do you have any solution for this? – Banty Roy Aug 17 '18 at 13:36
  • As with most questions on SO if you show us some relevant code you are more likely to get some useful help – RiggsFolly Aug 17 '18 at 13:37
  • @RiggsFolly thank you for your suggestion. I have added the code snippet. – Banty Roy Aug 17 '18 at 13:43
  • Out of interest, why are you doing `curl_exec($curl)` twice? I would guess thats your problem – RiggsFolly Aug 17 '18 at 13:47
  • What version of PHP are you running? – unixmiah Aug 17 '18 at 13:49
  • @RiggsFolly No dear just test purpose I have written that. From the first line, the errors are coming – Banty Roy Aug 17 '18 at 13:50
  • if i read this correctly, when your curl_exec works, first thing you do is to curl_exec again with the same resource `$curl`. hmmmm. You should read the fabulous manual **[for curl_exec](http://php.net/manual/en/function.curl-exec.php)**. – YvesLeBorg Aug 17 '18 at 14:04
  • As first if you use a curl_exec with that settings you will never get back a true or false Since the error state about row 18 which is the parentesis after the else likely the code you posted is not complete, so please report the original content of the row which is triggering the error. Further explanation about return from curl_exec can be found at: https://stackoverflow.com/questions/16452636/php-curl-what-does-curl-exec-return – A. Lion Aug 17 '18 at 14:26
  • This post may be of help https://stackoverflow.com/questions/3757071/php-debugging-curl – Fergal Andrews Aug 17 '18 at 14:30

1 Answers1

0

The issue was in the zlib.output_compression. It fixed and curl is working now.

Banty Roy
  • 914
  • 6
  • 23