Trait MessageTrait
HTTP messages consist of requests from a client to a server and responses from a server to a client. This interface defines the methods common to each.
Messages 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\stream\MessageTrait uses oroboros\core\traits\libraries\stream\StreamTrait
Direct Known Users
oroboros\core\abstracts\libraries\stream\AbstractMessage
,
oroboros\core\traits\libraries\request\RequestTrait
,
oroboros\core\traits\libraries\response\ResponseTrait
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::MESSAGE_ABSTRACT_CLASS
Link: bitbucket.org/oroborosframework/oroboros-core/wiki/development/api/traits.md
Link: http://www.ietf.org/rfc/rfc7230.txt
Link: http://www.ietf.org/rfc/rfc7231.txt
Satisfies: \oroboros\core\interfaces\contract\libraries\message\MessageContract
Satisfies: \Psr\Http\Message\MessageInterface
Located at core/traits/libraries/stream/MessageTrait.php
Methods summary
public
|
#
__construct( scalar|resource|Psr\Http\Message\StreamInterface $body, array $headers = null, type $protocol = null )
|
public
string
|
|
public
static
|
#
withProtocolVersion( string $version )
Return an instance with the specified HTTP protocol version. |
public
string[][]
|
|
public
boolean
|
|
public
string[]
|
|
public
string
|
#
getHeaderLine( string $name )
Retrieves a comma-separated string of the values for a single header. |
public
static
|
#
withHeader( string $name, string|string[] $value )
Return an instance with the provided value replacing the specified header. |
public
static
|
#
withAddedHeader( string $name, string|string[] $value )
Return an instance with the specified header appended with the given value. |
public
static
|
|
public
StreamInterface
|
|
public
static
|
|
protected
|
#
_initializeMessage( mixed $body, resource|string $headers = null, array $protocol = null , string $protocol,… )
|
protected
array
|
|
private
|
#
_validateMessageHeader( string $name, string|string[] $value )
Validates header parameters according to Psr-7 standards. |
private
boolean
|
#
_checkMessageHeader( string $name )
Checks if the supplied header name exists in a case-insensitive way. |
private
|
#
_getMessageValidRequestHeaders( )
Initialization method to obtain the valid request headers from the dedicated enumerator. |
private
|
#
_getMessageValidResponseHeaders( )
Initialization method to obtain the valid response headers from the dedicated enumerator. |
private
|
#
_setMessageHeaders( array $headers )
Sets the headers passed into initialization as header objects, and sets an array of the names locally for reference. |
private
|
#
_setMessageBody( scalar|Psr\Http\Message\StreamInterface $body )
Sets the message body as a stream resource. Accepts an existing resource, and creates one if passed a scalar value. |
private
|
|
private
array
|
#
_getMessageValues( )
Returns an array of the existing message values for this object, for substitution when returning instances that must retain object immutability. |
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\StreamTrait
__destruct()
,
__toString()
,
_createCacheStreamFile()
,
_createStreamCacheFileName()
,
_initializeStream()
,
close()
,
detach()
,
eof()
,
getContents()
,
getMetadata()
,
getSize()
,
isReadable()
,
isSeekable()
,
isWritable()
,
read()
,
rewind()
,
seek()
,
tell()
,
write()
Properties summary
private
array
|
$_message_headers
Represents the header values of headers passed in for the message. |
#
array()
|
private
array
|
$_message_valid_protocols
Represents valid HTTP request methods. If HTTP/2 becomes prominent and supported at a later date, it will be added here also. |
#
array(
'1.0',
'1.1',
)
|
private
string
|
$_message_protocol_default
Represents the default HTTP transfer protocol. |
#
'1.1'
|
private
|
$_message_protocol
The current message protocol. |
|
private
boolean
|
$_message_is_initialized
Represents whether the message is properly initialized. |
#
false
|
private static
array
|
$_message_headers_valid
|
#
array(
'request' => array(),
'response' => array()
)
|
Properties used from oroboros\core\traits\libraries\stream\StreamTrait
$_cache_file
,
$_meta
,
$_offset
,
$_purge_file_on_destruct
,
$_readable
,
$_seekable
,
$_size
,
$_stream
,
$_uri
,
$_writeable