You are here

class Request in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/http-foundation/Request.php \Symfony\Component\HttpFoundation\Request
  2. 8 vendor/symfony/browser-kit/Request.php \Symfony\Component\BrowserKit\Request
  3. 8 vendor/zendframework/zend-diactoros/src/Request.php \Zend\Diactoros\Request
  4. 8 vendor/zendframework/zend-stdlib/src/Request.php \Zend\Stdlib\Request
  5. 8 vendor/guzzlehttp/psr7/src/Request.php \GuzzleHttp\Psr7\Request
  6. 8 vendor/jcalderonzumba/gastonjs/src/NetworkTraffic/Request.php \Zumba\GastonJS\NetworkTraffic\Request
Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-diactoros/src/Request.php \Zend\Diactoros\Request

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.

Hierarchy

Expanded class hierarchy of Request

1 file declares its use of Request
Serializer.php in vendor/zendframework/zend-diactoros/src/Request/Serializer.php
3 string references to 'Request'
legacy-services6.yml in vendor/symfony/dependency-injection/Tests/Fixtures/yaml/legacy-services6.yml
vendor/symfony/dependency-injection/Tests/Fixtures/yaml/legacy-services6.yml
services20.yml in vendor/symfony/dependency-injection/Tests/Fixtures/yaml/services20.yml
vendor/symfony/dependency-injection/Tests/Fixtures/yaml/services20.yml
services9.yml in vendor/symfony/dependency-injection/Tests/Fixtures/yaml/services9.yml
vendor/symfony/dependency-injection/Tests/Fixtures/yaml/services9.yml

File

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

Namespace

Zend\Diactoros
View source
class Request implements RequestInterface {
  use MessageTrait, RequestTrait;

  /**
   * @param null|string $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 && $this->uri
      ->getHost())) {
      $headers['Host'] = [
        $this
          ->getHostFromUri(),
      ];
    }
    return $headers;
  }

  /**
   * {@inheritdoc}
   */
  public function getHeader($header) {
    if (!$this
      ->hasHeader($header)) {
      if (strtolower($header) === 'host' && ($this->uri && $this->uri
        ->getHost())) {
        return [
          $this
            ->getHostFromUri(),
        ];
      }
      return [];
    }
    $header = $this->headerNames[strtolower($header)];
    $value = $this->headers[$header];
    $value = is_array($value) ? $value : [
      $value,
    ];
    return $value;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MessageTrait::$headerNames protected property Map of normalized header name to original name used to register header.
MessageTrait::$headers protected property List of all registered headers, as key => array of values.
MessageTrait::$protocol private property
MessageTrait::$stream private property
MessageTrait::arrayContainsOnlyStrings private function Test that an array contains only strings
MessageTrait::assertValidHeaderValue private static function Assert that the provided header values are valid.
MessageTrait::filterHeaders private function Filter a set of headers to ensure they are in the correct internal format.
MessageTrait::filterStringValue private static function Test if a value is a string
MessageTrait::getBody public function Gets the body of the message.
MessageTrait::getHeaderLine public function Retrieves a comma-separated string of the values for a single header.
MessageTrait::getProtocolVersion public function Retrieves the HTTP protocol version as a string.
MessageTrait::hasHeader public function Checks if a header exists by the given case-insensitive name.
MessageTrait::withAddedHeader public function Return an instance with the specified header appended with the given value.
MessageTrait::withBody public function Return an instance with the specified message body.
MessageTrait::withHeader public function Return an instance with the provided header, replacing any existing values of any headers with the same case-insensitive name.
MessageTrait::withoutHeader public function Return an instance without the specified header.
MessageTrait::withProtocolVersion public function Return an instance with the specified HTTP protocol version.
Request::getHeader public function Retrieves a message header value by the given case-insensitive name. Overrides MessageTrait::getHeader
Request::getHeaders public function Retrieves all message headers. Overrides MessageTrait::getHeaders
Request::__construct public function
RequestInterface::getMethod public function Retrieves the HTTP method of the request. 3
RequestInterface::getRequestTarget public function Retrieves the message's request target. 2
RequestInterface::getUri public function Retrieves the URI instance. 2
RequestInterface::withMethod public function Return an instance with the provided HTTP method. 3
RequestInterface::withRequestTarget public function Return an instance with the specific request-target. 2
RequestInterface::withUri public function Returns an instance with the provided URI. 2