Enable the possibility to fetch a specific header variable
This commit is contained in:
parent
f16bf04f54
commit
18198b4aaa
1 changed files with 18 additions and 3 deletions
|
@ -226,13 +226,28 @@ class CurlResult
|
||||||
/**
|
/**
|
||||||
* Returns the Curl headers
|
* Returns the Curl headers
|
||||||
*
|
*
|
||||||
* @return string the Curl headers
|
* @param string $field optional header field. Return all fields if empty
|
||||||
|
*
|
||||||
|
* @return string|bool the Curl headers, "false" when field isn't found
|
||||||
*/
|
*/
|
||||||
public function getHeader()
|
public function getHeader($field = '')
|
||||||
{
|
{
|
||||||
|
if (empty($field)) {
|
||||||
return $this->header;
|
return $this->header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$lines = explode("\n", $this->header);
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
$parts = explode(':', $line);
|
||||||
|
$headerfield = array_shift($parts);
|
||||||
|
if (strtolower(trim($field)) == strtolower(trim($headerfield))) {
|
||||||
|
return implode(':', $parts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue