populateHeaders example

/** * Returns an array containing all Headers. * * @return array<string, Header> An array of the Header objects */
    public function headers(): array
    {
        // If no headers are defined, but the user is         // requesting it, then it's likely they want         // it to be populated so do that...         if (empty($this->headers)) {
            $this->populateHeaders();
        }

        return $this->headers;
    }

    /** * Returns a single Header object. If multiple headers with the same * name exist, then will return an array of header objects. * * @param string $name * * @return array|Header|null */

    public function __construct($config, ?URI $uri = null, $body = 'php://input', ?UserAgent $userAgent = null)
    {
        if (empty($uri) || empty($userAgent)) {
            throw new InvalidArgumentException('You must supply the parameters: uri, userAgent.');
        }

        $this->populateHeaders();

        if (
            $body === 'php://input'
            // php://input is not available with enctype="multipart/form-data".             // See https://www.php.net/manual/en/wrappers.php.php#wrappers.php.input             && strpos($this->getHeaderLine('Content-Type'), 'multipart/form-data') === false
            && (int) $this->getHeaderLine('Content-Length') <= $this->getPostMaxSize()
        ) {
            // Get our body from php://input             $body = file_get_contents('php://input');
        }

        
Home | Imprint | This part of the site doesn't use cookies.