com\setasign\SetaFramework\Request
ServerRequest Class Request
File: /SetaFramework/src/Request/ServerRequest.php
A wrapper for the psr request.
Class hierarchy
Implements
- \Psr\Http\Message\MessageInterface
- \Psr\Http\Message\RequestInterface
- \Psr\Http\Message\ServerRequestInterface
Summary
Methods
- __construct()
- doesAccept()
- getAttribute()
- getAttributes()
- getBody()
- getCookieParams()
- getGet()
- getGetArray()
- getHeader()
- getHeaderLine()
- getHeaders()
- getJson()
- getJsonArray()
- getMethod()
- getParsedBody()
- getPost()
- getPostArray()
- getProtocolVersion()
- getQueryParams()
- getRemoteAddress()
- getRequest()
- getRequestTarget()
- getServerParams()
- getUploadedFiles()
- getUri()
- hasHeader()
- isFromTrustedProxy()
- isJson()
- isPost()
- setTrustedProxies()
- withAddedHeader()
- withAttribute()
- withBody()
- withCookieParams()
- withHeader()
- withMethod()
- withParsedBody()
- withProtocolVersion()
- withQueryParams()
- withRequestTarget()
- withUploadedFiles()
- withUri()
- withoutAttribute()
- withoutHeader()
Properties
$request
$trustAny
$trustedProxies
$trustedProxiesIpHeader
Methods
doesAccept()
Checks the accept-header whether $contentType is included.
If the request doesn't have an accept-header every contentType will return true!
Parameters
- $contentType
getAttribute()
Retrieve a single derived request attribute.
Parameters
- $name : string
The attribute name.
- $default : mixed
Default value to return if the attribute does not exist.
See
- \Psr\Http\Message\ServerRequestInterface::getAttributes()
getAttributes()
Retrieve attributes derived from the request.
Return Values
Attributes derived from the request.
getHeader()
Retrieves a message header value by the given case-insensitive name.
Parameters
- $name : string
Case-insensitive header field name.
Return Values
An array of string values as provided for the given header. If the header does not appear in the message, this method MUST return an empty array.
getHeaderLine()
Retrieves a comma-separated string of the values for a single header.
Parameters
- $name : string
Case-insensitive header field name.
Return Values
A string of values as provided for the given header concatenated together using a comma. If the header does not appear in the message, this method MUST return an empty string.
getHeaders()
Retrieves all message header values.
Return Values
Returns an associative array of the message's headers. Each key MUST be a header name, and each value MUST be an array of strings for that header.
getJson()
Gets the content of the incoming json data.
Parameters
- $key : string
- $default : mixed
Exceptions
Throws \BadMethodCallException
See
getParsedBody()
Retrieve any parameters provided in the request body.
Return Values
The deserialized body parameters, if any. These will typically be an array or object.
getProtocolVersion()
Retrieves the HTTP protocol version as a string.
Return Values
HTTP protocol version.
getUploadedFiles()
Retrieve normalized file upload data.
Return Values
An array tree of UploadedFileInterface instances; an empty array MUST be returned if no data is present.
getUri()
Retrieves the URI instance.
Return Values
Returns a UriInterface instance representing the URI of the request.
hasHeader()
Checks if a header exists by the given case-insensitive name.
Parameters
- $name : string
Case-insensitive header field name.
Return Values
Returns true if any header names match the given header name using a case-insensitive string comparison. Returns false if no matching header name is found in the message.
withAddedHeader()
string|string[] $value
Return an instance with the specified header appended with the given value.
Parameters
- $name : string
Case-insensitive header field name to add.
- $value : string|string[]
Header value(s).
Exceptions
Throws \InvalidArgumentException for invalid header names or values.
withAttribute()
mixed $value
Return an instance with the specified derived request attribute.
Parameters
- $name : string
The attribute name.
- $value : mixed
The value of the attribute.
See
- \Psr\Http\Message\ServerRequestInterface::getAttributes()
withBody()
Return an instance with the specified message body.
Parameters
- $body : \Psr\Http\Message\StreamInterface
Body.
Exceptions
Throws \InvalidArgumentException When the body is not valid.
withCookieParams()
Return an instance with the specified cookies.
Parameters
- $cookies : array
Array of key/value pairs representing cookies.
withHeader()
string|string[] $value
Return an instance with the provided value replacing the specified header.
Parameters
- $name : string
Case-insensitive header field name.
- $value : string|string[]
Header value(s).
Exceptions
Throws \InvalidArgumentException for invalid header names or values.
withMethod()
Return an instance with the provided HTTP method.
Parameters
- $method : string
Case-sensitive method.
Exceptions
Throws \InvalidArgumentException for invalid HTTP methods.
withParsedBody()
Return an instance with the specified body parameters.
Parameters
- $data : null|array|object
The deserialized body data. This will typically be in an array or object.
Exceptions
Throws \InvalidArgumentException if an unsupported argument type is provided.
withProtocolVersion()
Return an instance with the specified HTTP protocol version.
Parameters
- $version : string
HTTP protocol version
withQueryParams()
Return an instance with the specified query string arguments.
Parameters
- $query : array
Array of query string arguments, typically from $_GET.
withRequestTarget()
Return an instance with the specific request-target.
Parameters
- $requestTarget : string
withUploadedFiles()
Create a new instance with the specified uploaded files.
Parameters
- $uploadedFiles : array
An array tree of UploadedFileInterface instances.
Exceptions
Throws \InvalidArgumentException if an invalid structure is provided.
withUri()
bool $preserveHost = false
Returns an instance with the provided URI.
Parameters
- $uri : \Psr\Http\Message\UriInterface
New request URI to use.
- $preserveHost : bool
Preserve the original state of the Host header.
withoutAttribute()
Return an instance that removes the specified derived request attribute.
Parameters
- $name : string
The attribute name.
See
- \Psr\Http\Message\ServerRequestInterface::getAttributes()
withoutHeader()
Return an instance without the specified header.
Parameters
- $name : string
Case-insensitive header field name to remove.
