PHP Класс Neos\Flow\Http\Request

Наследование: extends AbstractMessage
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$arguments array
$attributes array PSR-7
$baseUri Uri
$inputStreamUri string URI for the "input" stream wrapper which can be modified for testing purposes
$method string
$server array Data similar to that which is typically provided by $_SERVER
$uri Uri

Открытые методы

Метод Описание
__clone ( ) Creates a deep clone
__construct ( array $get, array $post, array $files, array $server ) Constructs a new Request object based on the given environment data.
__toString ( ) : string Cast the request to a string: return the content part of this response
create ( Uri $uri, string $method = 'GET', array $arguments = [], array $files = [], array $server = [] ) : Request Creates a new Request object from the given data.
createActionRequest ( ) : ActionRequest Creates a new Action Request request as a sub request to this HTTP request.
createFromEnvironment ( ) : Request Considers the environment information found in PHP's superglobals and Flow's environment configuration and creates a new instance of this Request class matching that data.
getAcceptedMediaTypes ( ) : array Returns an list of IANA media types defined in the Accept header.
getArgument ( string $name ) : mixed Returns the value of the specified GET / POST / PUT argument.
getArguments ( ) : array Returns the unified arguments of this request.
getAttribute ( string $name, mixed $default = null ) : mixed PSR-7
getAttributes ( ) : mixed[] PSR-7
getBaseUri ( ) : Uri Returns the detected base URI
getClientIpAddress ( ) : string Returns the best guess of the client's IP address.
getContent ( boolean $asResource = false ) : string | resource Returns the content of the request body
getMethod ( ) : string Returns the request method
getNegotiatedMediaType ( array $supportedMediaTypes, boolean $trim = true ) : string Returns the best fitting IANA media type after applying the content negotiation rules on a possible Accept header.
getPort ( ) : integer Returns the port used for this request
getRelativePath ( ) : string Returns the request's path relative to the $baseUri
getRequestLine ( ) : string Return the Request-Line of this Request Message, consisting of the method, the uri and the HTTP version Would be, for example, "GET /foo?bar=baz HTTP/1.1" Note that the URI part is, at the moment, only possible in the form "abs_path" since the actual requestUri of the Request cannot be determined during the creation of the Request.
getScriptRequestPath ( ) : string Returns the relative path (ie. relative to the web root) to the script as it was accessed through the web server.
getScriptRequestPathAndFilename ( ) : string Returns the relative path (ie. relative to the web root) and name of the script as it was accessed through the web server.
getServerParams ( ) : array PSR-7
getStartLine ( ) : string Returns the first line of this Request Message, which is the Request-Line in this case
getUri ( ) : Uri Returns the request URI
hasArgument ( string $name ) : boolean Checks if an argument of the given name exists in this request.
isMethodSafe ( ) : boolean Tells if the request method is "safe", that is, it is expected to not take any other action than retrieval. This should the case with "GET" and "HEAD" requests.
isSecure ( ) : boolean Indicates if this request has been received through a secure channel.
mediaRangeMatches ( string $mediaRange, string $mediaType ) : boolean Checks if the given media range and the media type match.
parseContentNegotiationQualityValues ( string $rawValues ) : array Parses a RFC 2616 content negotiation header field by evaluating the Quality Values and splitting the options into an array list, ordered by user preference.
parseMediaType ( string $rawMediaType ) : array Parses a RFC 2616 Media Type and returns its parts in an associative array.
renderHeaders ( ) : string Renders the HTTP headers - including the status header - of this request
setBaseUri ( Uri $baseUri )
setContent ( string | resource $content ) : void Explicitly sets the content of the request body
setMethod ( string $method ) : void Sets the request method
trimMediaType ( string $rawMediaType ) : string Strips off any parameters from the given media type and returns just the type and subtype in the format "type/subtype".
withAttribute ( string $name, mixed $value ) : self PSR-7
withoutAttribute ( string $name ) : self PSR-7

Защищенные методы

Метод Описание
buildUnifiedArguments ( array $getArguments, array $postArguments, array $uploadArguments ) : array Takes the raw GET & POST arguments and maps them into the request object.
calculateFieldPaths ( array $structure, string $firstLevelFieldName = null ) : array Returns and array of all possibles "field paths" for the given array.
detectBaseUri ( ) : void Tries to detect the base URI of request.
setAttribute ( string $name, mixed $value )
unsetAttribute ( string $name )
untangleFilesArray ( array $convolutedFiles ) : array Transforms the convoluted _FILES superglobal into a manageable form.

Описание методов

__clone() публичный Метод

Creates a deep clone
public __clone ( )

__construct() публичный Метод

Constructs a new Request object based on the given environment data.
См. также: create()
См. также: createFromEnvironment()
public __construct ( array $get, array $post, array $files, array $server )
$get array Data similar to that which is typically provided by $_GET
$post array Data similar to that which is typically provided by $_POST
$files array Data similar to that which is typically provided by $_FILES
$server array Data similar to that which is typically provided by $_SERVER

__toString() публичный Метод

Cast the request to a string: return the content part of this response
public __toString ( ) : string
Результат string The same as getContent()

buildUnifiedArguments() защищенный Метод

Afterwards all mapped arguments can be retrieved by the getArgument(s) method, no matter if they have been GET, POST or PUT arguments before.
protected buildUnifiedArguments ( array $getArguments, array $postArguments, array $uploadArguments ) : array
$getArguments array Arguments as found in $_GET
$postArguments array Arguments as found in $_POST
$uploadArguments array Arguments as found in $_FILES
Результат array the unified arguments

calculateFieldPaths() защищенный Метод

Returns and array of all possibles "field paths" for the given array.
protected calculateFieldPaths ( array $structure, string $firstLevelFieldName = null ) : array
$structure array The array to walk through
$firstLevelFieldName string
Результат array An array of paths (as strings) in the format "key1/key2/key3" ...

create() публичный статический Метод

Creates a new Request object from the given data.
public static create ( Uri $uri, string $method = 'GET', array $arguments = [], array $files = [], array $server = [] ) : Request
$uri Uri The request URI
$method string Request method, for example "GET"
$arguments array Arguments to send in the request body
$files array
$server array
Результат Request

createActionRequest() публичный Метод

Maps the arguments of this request to the new Action Request.
Устаревший: since Flow 2.3. Create the ActionRequest manually instead: $actionRequest = new ActionRequest($httpRequest)
public createActionRequest ( ) : ActionRequest
Результат Neos\Flow\Mvc\ActionRequest

createFromEnvironment() публичный статический Метод

Considers the environment information found in PHP's superglobals and Flow's environment configuration and creates a new instance of this Request class matching that data.
public static createFromEnvironment ( ) : Request
Результат Request

detectBaseUri() защищенный Метод

Tries to detect the base URI of request.
protected detectBaseUri ( ) : void
Результат void

getAcceptedMediaTypes() публичный Метод

The list is ordered by user preference, after evaluating the Quality Values specified in the header field value. First items in the list are the most preferred. If no Accept header is present, the media type representing "any" media type is returned.
public getAcceptedMediaTypes ( ) : array
Результат array A list of media types and sub types

getArgument() публичный Метод

Returns the value of the specified GET / POST / PUT argument.
public getArgument ( string $name ) : mixed
$name string Name of the argument
Результат mixed Value of the specified argument or NULL if it does not exist

getArguments() публичный Метод

GET, POST and PUT arguments, as well es uploaded files, are merged into a whole array of arguments.
public getArguments ( ) : array
Результат array

getAttribute() публичный Метод

Retrieve a single derived request attribute. Retrieves a single derived request attribute as described in getAttributes(). If the attribute has not been previously set, returns the default value as provided. This method obviates the need for a hasAttribute() method, as it allows specifying a default value to return if the attribute is not found.
См. также: getAttributes()
public getAttribute ( string $name, mixed $default = null ) : mixed
$name string The attribute name.
$default mixed Default value to return if the attribute does not exist.
Результат mixed

getAttributes() публичный Метод

Retrieve attributes derived from the request. The request "attributes" may be used to allow injection of any parameters derived from the request: e.g., the results of path match operations; the results of decrypting cookies; the results of deserializing non-form-encoded message bodies; etc. Attributes will be application and request specific, and CAN be mutable.
public getAttributes ( ) : mixed[]
Результат mixed[] Attributes derived from the request.

getBaseUri() публичный Метод

Returns the detected base URI
public getBaseUri ( ) : Uri
Результат Uri

getClientIpAddress() публичный Метод

Note that, depending on the actual source used, IP addresses can be spoofed and may not be reliable. Although several kinds of proxy headers are taken into account, certain combinations of ISPs and proxies might still produce wrong results. Don't rely on the client IP address as the only security measure!
public getClientIpAddress ( ) : string
Результат string The client's IP address

getContent() публичный Метод

If the request body has not been set with setContent() previously, this method will try to retrieve it from the input stream. If $asResource was set to TRUE, the stream resource will be returned instead of a string. If the content which has been set by setContent() originally was a stream resource, that resource will be returned, no matter if $asResource is set.
public getContent ( boolean $asResource = false ) : string | resource
$asResource boolean If set, the content is returned as a resource pointing to PHP's input stream
Результат string | resource

getMethod() публичный Метод

Returns the request method
public getMethod ( ) : string
Результат string The request method

getNegotiatedMediaType() публичный Метод

Returns the best fitting IANA media type after applying the content negotiation rules on a possible Accept header.
public getNegotiatedMediaType ( array $supportedMediaTypes, boolean $trim = true ) : string
$supportedMediaTypes array A list of media types which are supported by the application / controller
$trim boolean If TRUE, only the type/subtype of the media type is returned. If FALSE, the full original media type string is returned.
Результат string The media type and sub type which matched, NULL if none matched

getPort() публичный Метод

Returns the port used for this request
public getPort ( ) : integer
Результат integer

getRelativePath() публичный Метод

Returns the request's path relative to the $baseUri
public getRelativePath ( ) : string
Результат string

getRequestLine() публичный Метод

Return the Request-Line of this Request Message, consisting of the method, the uri and the HTTP version Would be, for example, "GET /foo?bar=baz HTTP/1.1" Note that the URI part is, at the moment, only possible in the form "abs_path" since the actual requestUri of the Request cannot be determined during the creation of the Request.
См. также: http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1
public getRequestLine ( ) : string
Результат string

getScriptRequestPath() публичный Метод

Returns the relative path (ie. relative to the web root) to the script as it was accessed through the web server.
public getScriptRequestPath ( ) : string
Результат string Relative path to the PHP script as accessed through the web

getScriptRequestPathAndFilename() публичный Метод

Returns the relative path (ie. relative to the web root) and name of the script as it was accessed through the web server.
public getScriptRequestPathAndFilename ( ) : string
Результат string Relative path and name of the PHP script as accessed through the web

getServerParams() публичный Метод

Retrieve server parameters. Retrieves data related to the incoming request environment, typically derived from PHP's $_SERVER superglobal. The data IS NOT REQUIRED to originate from $_SERVER.
public getServerParams ( ) : array
Результат array

getStartLine() публичный Метод

Returns the first line of this Request Message, which is the Request-Line in this case
См. также: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html chapter 4.1 "Message Types"
public getStartLine ( ) : string
Результат string The Request-Line of this Request

getUri() публичный Метод

Returns the request URI
public getUri ( ) : Uri
Результат Uri

hasArgument() публичный Метод

Applies to GET, POST and PUT arguments similarly.
public hasArgument ( string $name ) : boolean
$name string Name of the argument
Результат boolean

isMethodSafe() публичный Метод

Tells if the request method is "safe", that is, it is expected to not take any other action than retrieval. This should the case with "GET" and "HEAD" requests.
public isMethodSafe ( ) : boolean
Результат boolean

isSecure() публичный Метод

Indicates if this request has been received through a secure channel.
public isSecure ( ) : boolean
Результат boolean

mediaRangeMatches() публичный статический Метод

Checks if the given media range and the media type match.
См. также: MediaTypes::mediaRangeMatches()
Устаревший: since Flow 2.1. Use \Neos\Utility\MediaTypes::mediaRangeMatches() instead
public static mediaRangeMatches ( string $mediaRange, string $mediaType ) : boolean
$mediaRange string The media range, for example "text/*"
$mediaType string The media type to match against, for example "text/html"
Результат boolean TRUE if both match, FALSE if they don't match or either of them is invalid

parseContentNegotiationQualityValues() публичный статический Метод

Parses a RFC 2616 content negotiation header field by evaluating the Quality Values and splitting the options into an array list, ordered by user preference.
public static parseContentNegotiationQualityValues ( string $rawValues ) : array
$rawValues string The raw Accept* Header field value
Результат array The parsed list of field values, ordered by user preference

parseMediaType() публичный статический Метод

Parses a RFC 2616 Media Type and returns its parts in an associative array.
См. также: MediaTypes::parseMediaType()
Устаревший: since Flow 2.1. Use \Neos\Utility\MediaTypes::parseMediaType() instead
public static parseMediaType ( string $rawMediaType ) : array
$rawMediaType string The raw media type, for example "application/json; charset=UTF-8"
Результат array An associative array with parsed information

renderHeaders() публичный Метод

Renders the HTTP headers - including the status header - of this request
public renderHeaders ( ) : string
Результат string The HTTP headers, one per line, separated by \r\n as required by RFC 2616 sec 5

setAttribute() защищенный Метод

protected setAttribute ( string $name, mixed $value )
$name string The attribute name.
$value mixed The value of the attribute.

setBaseUri() публичный Метод

public setBaseUri ( Uri $baseUri )
$baseUri Uri

setContent() публичный Метод

In most cases, content is just a string representation of the request body. In order to reduce memory consumption for uploads and other big data, it is also possible to pass a stream resource. The easies way to convert a local file into a stream resource is probably: $resource = fopen('file://path/to/file', 'rb');
public setContent ( string | resource $content ) : void
$content string | resource The body content, for example arguments of a PUT request, or a stream resource
Результат void

setMethod() публичный Метод

Sets the request method
public setMethod ( string $method ) : void
$method string The request method, for example "GET".
Результат void

trimMediaType() публичный статический Метод

Strips off any parameters from the given media type and returns just the type and subtype in the format "type/subtype".
См. также: Neos\Utility\MediaTypes::trimMediaType()
Устаревший: since Flow 2.1. Use \Neos\Utility\MediaTypes::trimMediaType() instead
public static trimMediaType ( string $rawMediaType ) : string
$rawMediaType string The full media type, for example "application/json; charset=UTF-8"
Результат string Just the type and subtype, for example "application/json"

unsetAttribute() защищенный Метод

protected unsetAttribute ( string $name )
$name string The attribute name.

untangleFilesArray() защищенный Метод

Transforms the convoluted _FILES superglobal into a manageable form.
protected untangleFilesArray ( array $convolutedFiles ) : array
$convolutedFiles array The _FILES superglobal
Результат array Untangled files

withAttribute() публичный Метод

Return an instance with the specified derived request attribute. This method allows setting a single derived request attribute as described in getAttributes(). This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated attribute.
См. также: getAttributes()
public withAttribute ( string $name, mixed $value ) : self
$name string The attribute name.
$value mixed The value of the attribute.
Результат self

withoutAttribute() публичный Метод

Return an instance that removes the specified derived request attribute. This method allows removing a single derived request attribute as described in getAttributes(). This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that removes the attribute.
См. также: getAttributes()
public withoutAttribute ( string $name ) : self
$name string The attribute name.
Результат self

Описание свойств

$arguments защищенное свойство

protected array $arguments
Результат array

$attributes защищенное свойство

PSR-7
protected array $attributes
Результат array

$baseUri защищенное свойство

protected Uri,Neos\Flow\Http $baseUri
Результат Uri

$inputStreamUri защищенное свойство

URI for the "input" stream wrapper which can be modified for testing purposes
protected string $inputStreamUri
Результат string

$method защищенное свойство

protected string $method
Результат string

$server защищенное свойство

Data similar to that which is typically provided by $_SERVER
protected array $server
Результат array

$uri защищенное свойство

protected Uri,Neos\Flow\Http $uri
Результат Uri