Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.lang.php Subject: Re: How to handle curl_exec() so that it won't terminat my script abruptly without any exception? Date: Wed, 5 Jun 2019 06:54:44 +0200 Lines: 34 Message-ID: References: <1o3z8vwk6x9am$.54ia46ki18ga$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net TRPyxMTFUOu8K38Irv5DXA7xpqqPnQYdumJkXdd2Wgxtu2Z0Iq Cancel-Lock: sha1:glGmQxMokze4bHpE0Xk3nprszTc= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 In-Reply-To: <1o3z8vwk6x9am$.54ia46ki18ga$.dlg@40tude.net> Content-Language: en-US-large Xref: csiph.com comp.lang.php:17933 On 05/06/2019 05.45, JJ wrote: > I'm trying to make a simple proxy script for my web server in my local > network, but I've found that `curl_exec()` abruptly terminates my script > without any error or exception on some websites. Don't think curl ever throws an exception. > Here's the simplified script to reproduce the problem. > > function doResponseHeaders($cu, $dt) { > header($dt); > return strlen($dt); > } > $cu = curl_init('https://www.youtube.com/'); curl_setopt($cu, CURLOPT_FAILONERROR, true); > curl_setopt($cu, CURLOPT_HEADERFUNCTION, 'doResponseHeaders'); if(curl_exec($cu) === false) { trigger_error(curl_error($cu)); } > curl_close($cu); > echo 'ALL_DONE'; > ?> Hopefully you get an error to handle now. -- //Aho