XF 2.1 Guzzle and memory error

Robert9

Well-known member
Code:
                    // get response

                    try

                    {

                        $client = \XF::app()->http()->client();

                        $response = $client->get($imglink);

                    }

                    catch (\GuzzleHttp\Exception\RequestException $e)

                    {

                        \XF::logException($e, false, "Error: ");

                        continue;

                    }

Most times this code works find efor me, but sometimes i get errors like this:

<b>Fatal error</b>: Allowed memory size of 268435456 bytes exhausted (tried to allocate 232787968 bytes)

268435456 <= allowed
232787968 <= needed

allowed > needed - i have no idea what to do. :(
 
There is no problem with memory_limit.

I can solve the problem with

Code:
header("Content-Type: image/jpeg");

$url = $imglink;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.1 Safari/537.11');
$response = curl_exec($ch);
$rescode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch) ;

instead of guzzle

Any idea how? Maybe the header?
 
Back
Top Bottom