Bug #25321 ยป geturl-headers-with-get.diff
t3lib/class.t3lib_div.php | ||
---|---|---|
* Usage: 83
|
||
*
|
||
* @param string File/URL to read
|
||
* @param integer Whether the HTTP header should be fetched or not. 0=disable, 1=fetch header+content, 2=fetch header only
|
||
* @param integer Whether the HTTP header should be fetched or not. 0=disable, 1=fetch header+content, 2=fetch header (head), 3=fetch header (get)
|
||
* @param array HTTP headers to be used in the request
|
||
* @param array Error code/message and, if $includeHeader is 1, response meta data (HTTP status and content type)
|
||
* @return string The content from the resource given as input. FALSE if an error has occured.
|
||
... | ... | |
curl_setopt($ch, CURLOPT_URL, $url);
|
||
curl_setopt($ch, CURLOPT_HEADER, $includeHeader ? 1 : 0);
|
||
curl_setopt($ch, CURLOPT_NOBODY, $includeHeader == 2 ? 1 : 0);
|
||
curl_setopt($ch, CURLOPT_NOBODY, ($includeHeader == 2 || $includeHeader == 3) ? 1 : 0);
|
||
curl_setopt($ch, CURLOPT_HTTPGET, $includeHeader == 2 ? 'HEAD' : 'GET');
|
||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
|
||
... | ... | |
break; // Stop at the first empty line (= end of header)
|
||
}
|
||
}
|
||
if ($includeHeader != 2) {
|
||
if ($includeHeader != 2 && $includeHeader != 3) {
|
||
$content .= stream_get_contents($fp);
|
||
}
|
||
fclose($fp);
|