Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why turn header off in curl?

Tags:

php

curl

In quite a few curl examples people use:

curl_setopt($ch, CURLOPT_HEADER, 0);

What is the benefit of doing this?

I managed to display an image and I want to know what options I should put on/off and why.

curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); // use?
curl_setopt($curlGetToken, CURLOPT_ENCODING, 'gzip'); // does it slow down MY server
like image 405
SuperSpy Avatar asked Jan 19 '12 00:01

SuperSpy


2 Answers

When CURLOPT_HEADER is set to 0 the only effect is that header info from the response is excluded from the output. So if you don't need it that's a few less KBs that curl will return to you.

like image 86
Justin Lucas Avatar answered Oct 01 '22 03:10

Justin Lucas


As per the docs, it controls whether the response header(s) will be returned alongside the response body. Generally, if you only care about the response body, you want this disabled (which is the default value, 0).

like image 20
alex Avatar answered Oct 01 '22 04:10

alex