upgrade zend (#1559)
[openemr.git] / vendor / zendframework / zend-diactoros / src / Request.php
blobaacc2dd31d5a4bd4c295d04c13890b6a36b68c44
1 <?php
2 /**
3 * @see https://github.com/zendframework/zend-diactoros for the canonical source repository
4 * @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
5 * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
6 */
8 namespace Zend\Diactoros;
10 use Psr\Http\Message\RequestInterface;
11 use Psr\Http\Message\StreamInterface;
12 use Psr\Http\Message\UriInterface;
14 /**
15 * HTTP Request encapsulation
17 * Requests are considered immutable; all methods that might change state are
18 * implemented such that they retain the internal state of the current
19 * message and return a new instance that contains the changed state.
21 class Request implements RequestInterface
23 use RequestTrait;
25 /**
26 * @param null|string|UriInterface $uri URI for the request, if any.
27 * @param null|string $method HTTP method for the request, if any.
28 * @param string|resource|StreamInterface $body Message body, if any.
29 * @param array $headers Headers for the message, if any.
30 * @throws \InvalidArgumentException for any invalid value.
32 public function __construct($uri = null, $method = null, $body = 'php://temp', array $headers = [])
34 $this->initialize($uri, $method, $body, $headers);
37 /**
38 * {@inheritdoc}
40 public function getHeaders()
42 $headers = $this->headers;
43 if (! $this->hasHeader('host')
44 && $this->uri->getHost()
45 ) {
46 $headers['Host'] = [$this->getHostFromUri()];
49 return $headers;
52 /**
53 * {@inheritdoc}
55 public function getHeader($header)
57 if (! $this->hasHeader($header)) {
58 if (strtolower($header) === 'host'
59 && $this->uri->getHost()
60 ) {
61 return [$this->getHostFromUri()];
64 return [];
67 $header = $this->headerNames[strtolower($header)];
69 return $this->headers[$header];