Trait RequestTrait
Representation of an outgoing, client-side request.
Per the HTTP specification, this interface includes properties for each of the following:
- Protocol version
- HTTP method
- URI
- Headers
- Message body
During construction, implementations MUST attempt to set the Host header from a provided URI if no Host header is provided.
Requests are considered immutable; all methods that might change state MUST be implemented such that they retain the internal state of the current message and return an instance that contains the changed state.
Traits provide extended method support to classes without requiring a direct, linear chain of inheritance. This allows functions to inherit subsets of related methods without declaring a parent class.
In Oroboros core, ALL methods are granted to classes via traits, and the classes themselves are just containers that correlate their methods to an interface they are expected to honor. This approach maximizes interoperability, by entirely removing class inheritance as a requirement for extension of any class in this system.
3rd parties using this package are not expected to follow this approach,
but ALL of our internal class and logic structure does.
- oroboros\core\traits\libraries\request\RequestTrait uses oroboros\core\traits\libraries\stream\MessageTrait
Direct Known Users
oroboros\core\abstracts\libraries\request\AbstractRequest
,
oroboros\core\traits\libraries\request\ServerRequestTrait
Indirect Known Users
Package: oroboros\core\psr7
Category: traits
License: The MIT License (MIT)
Author: Brian Dayhoff mopsyd@me.com
Version: 0.2.4
Since: 0.2.4-alpha
Used by: oroboros\core\interfaces\api\psr\Psr7Api::REQUEST_ABSTRACT_CLASS
Link: bitbucket.org/oroborosframework/oroboros-core/wiki/development/api/traits.md
Satisfies: \oroboros\core\interfaces\contract\libraries\request\RequestContract
Satisfies: \Psr\Http\Message\RequestInterface
Located at core/traits/libraries/request/RequestTrait.php
Methods summary
public
|
#
__construct( scalar|resource|Psr\Http\Message\StreamInterface $body, array $headers = null, type $protocol = null, string $host = null, string $uri = null, string $method = null )
|
public
string
|
|
public
static
|
|
public
string
|
|
public
static
|
|
public
UriInterface
|
|
public
static
|
|
protected
|
#
_initializeRequest( mixed $body, array $headers = null, array $protocol = null, string $host = null, $uri = null, $method = null )
|
private
|
#
_validateRequestHost( string $host )
Validates the host. Host must be a valid url, localhost, IPv4 or IPv6 |
private
|
#
_validateRequestUri( string $uri )
Validates the uri. Uri must be a valid url, localhost, IPv4 or IPv6 |
private
|
#
_validateRequestMethod( string $method )
Validates the request method. Request method must be a valid HTTP request method (GET, POST, PUT, DELETE, etc) |
private
|
#
_setRequestUri( string $uri )
Creates an object that represents the request uri, and stores it internally. |
private
|
#
_setRequestMethod( string $method )
Creates an object that represents the request method, and stores it internally. |
private
|
#
_setRequestHostHeader( string $host = null, array $headers = null )
Sets the host header, if it is not provided. |
private
string
|
|
private
string
|
#
_getRequestDefaultUri( )
Returns the default local page uri if none is provided, or the localized IP address if current execution came from CLI. |
private
string
|
#
_getRequestDefaultRequestMethod( )
Returns the default local uri request method if none is provided, or the GET if it could not be determined (or if the request came from CLI). |
private
array
|
#
_getMessageValues( )
Returns the current internal values, for instantiation of new object instances while rendering the current object immutable. |
private
|
#
_instantiateMessageNewInstance( array $params = null )
Creates a new instance based off of the default parameters, substituting any values passed in. |
Methods used from oroboros\core\traits\libraries\stream\MessageTrait
_checkMessageHeader()
,
_getMessageHeaders()
,
_getMessageValidRequestHeaders()
,
_getMessageValidResponseHeaders()
,
_initializeMessage()
,
_setMessageBody()
,
_setMessageHeaders()
,
_setMessageProtocol()
,
_validateMessageHeader()
,
getBody()
,
getHeader()
,
getHeaderLine()
,
getHeaders()
,
getProtocolVersion()
,
hasHeader()
,
withAddedHeader()
,
withBody()
,
withHeader()
,
withProtocolVersion()
,
withoutHeader()
Properties summary
private
Psr\Http\Message\UriInterface
|
$_request_uri
Represents the current request uri. |
|
private
boolean
|
$_request_uri_provided
If no request uri was provided, this value will be false. |
#
false
|
private
|
$_request_method
Represents the current request method. |
|
private
boolean
|
$_request_is_initialized
Represents whether the request has been correctly initialized. |
#
false
|