Mercurial > hg > cmmr2012-drupal-site
diff vendor/zendframework/zend-diactoros/src/Request.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | 5311817fb629 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/zendframework/zend-diactoros/src/Request.php Thu Jul 05 14:24:15 2018 +0000 @@ -0,0 +1,73 @@ +<?php +/** + * Zend Framework (http://framework.zend.com/) + * + * @see http://github.com/zendframework/zend-diactoros for the canonical source repository + * @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com) + * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License + */ + +namespace Zend\Diactoros; + +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UriInterface; + +/** + * HTTP Request encapsulation + * + * Requests are considered immutable; all methods that might change state are + * implemented such that they retain the internal state of the current + * message and return a new instance that contains the changed state. + */ +class Request implements RequestInterface +{ + use RequestTrait; + + /** + * @param null|string|UriInterface $uri URI for the request, if any. + * @param null|string $method HTTP method for the request, if any. + * @param string|resource|StreamInterface $body Message body, if any. + * @param array $headers Headers for the message, if any. + * @throws \InvalidArgumentException for any invalid value. + */ + public function __construct($uri = null, $method = null, $body = 'php://temp', array $headers = []) + { + $this->initialize($uri, $method, $body, $headers); + } + + /** + * {@inheritdoc} + */ + public function getHeaders() + { + $headers = $this->headers; + if (! $this->hasHeader('host') + && $this->uri->getHost() + ) { + $headers['Host'] = [$this->getHostFromUri()]; + } + + return $headers; + } + + /** + * {@inheritdoc} + */ + public function getHeader($header) + { + if (! $this->hasHeader($header)) { + if (strtolower($header) === 'host' + && $this->uri->getHost() + ) { + return [$this->getHostFromUri()]; + } + + return []; + } + + $header = $this->headerNames[strtolower($header)]; + + return $this->headers[$header]; + } +}