You are here

public function Request::getHeaders in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-diactoros/src/Request.php \Zend\Diactoros\Request::getHeaders()
  2. 8 vendor/jcalderonzumba/gastonjs/src/NetworkTraffic/Request.php \Zumba\GastonJS\NetworkTraffic\Request::getHeaders()
Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-diactoros/src/Request.php \Zend\Diactoros\Request::getHeaders()

Retrieves all message headers.

The keys represent the header name as it will be sent over the wire, and each value is an array of strings associated with the header.

// Represent the headers as a string foreach ($message->getHeaders() as $name => $values) { echo $name . ": " . implode(", ", $values); }

// Emit headers iteratively: foreach ($message->getHeaders() as $name => $values) { foreach ($values as $value) { header(sprintf('%s: %s', $name, $value), false); } }

Return value

array Returns an associative array of the message's headers. Each key MUST be a header name, and each value MUST be an array of strings.

Overrides MessageTrait::getHeaders

File

vendor/zendframework/zend-diactoros/src/Request.php, line 41

Class

Request
HTTP Request encapsulation

Namespace

Zend\Diactoros

Code

public function getHeaders() {
  $headers = $this->headers;
  if (!$this
    ->hasHeader('host') && ($this->uri && $this->uri
    ->getHost())) {
    $headers['Host'] = [
      $this
        ->getHostFromUri(),
    ];
  }
  return $headers;
}