You are here

public function HttpClientRequest::getHeader in Http Client 7.2

Same name and namespace in other branches
  1. 6.2 includes/HttpClient.inc \HttpClientRequest::getHeader()

Gets the values of a header, or the value of the header if $treat_as_single is set to true.

Parameters

string $name:

string $treat_as_single: Optional. If set to FALSE an array of values will be returned. Otherwise The first value of the header will be returned.

Return value

string|array

File

includes/HttpClient.inc, line 577

Class

HttpClientRequest
This is a convenience class that allows the manipulation of a http request before it's handed over to curl.

Code

public function getHeader($name, $treat_as_single = TRUE) {
  $value = NULL;
  if (!empty($this->headers[$name])) {
    if ($treat_as_single) {
      $value = reset($this->headers[$name]);
    }
    else {
      $value = $this->headers[$name];
    }
  }
  return $value;
}