Server-side HTTP request

Extends the Request definition to add methods for accessing incoming data,
specifically server parameters, cookies, matched path parameters, query
string arguments, body parameters, and upload file information.

"Attributes" are discovered via decomposing the request (and usually
specifically the URI path), and typically will be injected by the application.

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.

CloneableInstantiable
ExtendsGuzzleHttp\Psr7\Request
ImplementsPsr\Http\Message\MessageInterface
Psr\Http\Message\RequestInterface
Psr\Http\Message\ServerRequestInterface
Methods
public __construct( $method, $uri, array $headers = [], $body = NULL, $version = '1.1', array $serverParams = [])
 
    public static fromGlobals()
     

    Return a ServerRequest populated with superglobals:
    $_GET
    $_POST
    $_COOKIE
    $_FILES
    $_SERVER

    • return ServerRequestInterface
    public getAttribute( $attribute, $default = NULL)
     

    {@inheritdoc}

    public getAttributes()
     

    {@inheritdoc}

    public GuzzleHttp\Psr7\Request::getBody()
    public getCookieParams()
     

    {@inheritdoc}

    public GuzzleHttp\Psr7\Request::getHeader( $header)
    public GuzzleHttp\Psr7\Request::getHeaderLine( $header)
    public GuzzleHttp\Psr7\Request::getHeaders()
    public GuzzleHttp\Psr7\Request::getMethod()
    public getParsedBody()
     

    {@inheritdoc}

    public GuzzleHttp\Psr7\Request::getProtocolVersion()
    public getQueryParams()
     

    {@inheritdoc}

    public GuzzleHttp\Psr7\Request::getRequestTarget()
    public getServerParams()
     

    {@inheritdoc}

    public getUploadedFiles()
     

    {@inheritdoc}

    public GuzzleHttp\Psr7\Request::getUri()
    public static getUriFromGlobals()
     

    Get a Uri populated with values from $_SERVER.

    • return UriInterface
    public GuzzleHttp\Psr7\Request::hasHeader( $header)
    public static normalizeFiles(array $files)
     

    Return an UploadedFile instance array.

    • throws InvalidArgumentException for unrecognized values
    • return array
    public GuzzleHttp\Psr7\Request::withAddedHeader( $header, $value)
    public withAttribute( $attribute, $value)
     

    {@inheritdoc}

    public GuzzleHttp\Psr7\Request::withBody(Psr\Http\Message\StreamInterface $body)
    public withCookieParams(array $cookies)
     

    {@inheritdoc}

    public GuzzleHttp\Psr7\Request::withHeader( $header, $value)
    public GuzzleHttp\Psr7\Request::withMethod( $method)
    public withoutAttribute( $attribute)
     

    {@inheritdoc}

    public GuzzleHttp\Psr7\Request::withoutHeader( $header)
    public withParsedBody( $data)
     

    {@inheritdoc}

    public GuzzleHttp\Psr7\Request::withProtocolVersion( $version)
    public withQueryParams(array $query)
     

    {@inheritdoc}

    public GuzzleHttp\Psr7\Request::withRequestTarget( $requestTarget)
    public withUploadedFiles(array $uploadedFiles)
     

    {@inheritdoc}

    public GuzzleHttp\Psr7\Request::withUri(Psr\Http\Message\UriInterface $uri, $preserveHost = false)
    Properties
    private $attributes
     
    • var array
    private $cookieParams
     
    • var array
    private $parsedBody
     
    • var null|array|object
    private $queryParams
     
    • var array
    private $serverParams
     
    • var array
    private $uploadedFiles
     
    • var array
    Methods
    private GuzzleHttp\Psr7\Request::assertHeader( $header)
    private GuzzleHttp\Psr7\Request::assertMethod( $method)
    private static createUploadedFileFromSpec(array $value)
     

    Create and return an UploadedFile instance from a $_FILES specification.

    If the specification represents an array of values, this method will
    delegate to normalizeNestedFileSpec() and return that return value.

    • return array|\UploadedFileInterface
    private static extractHostAndPortFromAuthority( $authority)
    private GuzzleHttp\Psr7\Request::normalizeHeaderValue( $value)
    private static normalizeNestedFileSpec(array $files = [])
     

    Normalize an array of file specifications.

    Loops through all nested files and returns a normalized array of
    UploadedFileInterface instances.

    • return UploadedFileInterface[]
    private GuzzleHttp\Psr7\Request::setHeaders(array $headers)
    private GuzzleHttp\Psr7\Request::trimHeaderValues(array $values)
     

    Trims whitespace from the header values.

    Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field.

    header-field = field-name ":" OWS field-value OWS
    OWS = *( SP / HTAB )

    • return string[] Trimmed header values
    • see https://tools.ietf.org/html/rfc7230#section-3.2.4
    private GuzzleHttp\Psr7\Request::updateHostFromUri()
    Methods
    private static createUploadedFileFromSpec(array $value)
     

    Create and return an UploadedFile instance from a $_FILES specification.

    If the specification represents an array of values, this method will
    delegate to normalizeNestedFileSpec() and return that return value.

    • return array|\UploadedFileInterface
    private static extractHostAndPortFromAuthority( $authority)
    public static fromGlobals()
     

    Return a ServerRequest populated with superglobals:
    $_GET
    $_POST
    $_COOKIE
    $_FILES
    $_SERVER

    • return ServerRequestInterface
    public static getUriFromGlobals()
     

    Get a Uri populated with values from $_SERVER.

    • return UriInterface
    public static normalizeFiles(array $files)
     

    Return an UploadedFile instance array.

    • throws InvalidArgumentException for unrecognized values
    • return array
    private static normalizeNestedFileSpec(array $files = [])
     

    Normalize an array of file specifications.

    Loops through all nested files and returns a normalized array of
    UploadedFileInterface instances.

    • return UploadedFileInterface[]
    © 2020 Bruce Wells
    Search Namespaces \ Classes
    ConfigurationNumbers (0-9.) only