Documentation

MessageTrait

Trait implementing functionality common to requests and responses.

Table of Contents

Properties

$headerNames  : array<string|int, string>
$headers  : array<string|int, array<string|int, string>>
$protocol  : string
$stream  : StreamInterface|null

Methods

getBody()  : StreamInterface
getHeader()  : array<string|int, mixed>
getHeaderLine()  : string
getHeaders()  : array<string|int, mixed>
getProtocolVersion()  : string
hasHeader()  : bool
withAddedHeader()  : MessageInterface
withBody()  : MessageInterface
withHeader()  : MessageInterface
withoutHeader()  : MessageInterface
withProtocolVersion()  : MessageInterface
assertHeader()  : void
assertValue()  : void
normalizeHeaderValue()  : array<string|int, string>
setHeaders()  : void
trimAndValidateHeaderValues()  : array<string|int, string>
Trims whitespace from the header values.

Properties

$headerNames

private array<string|int, string> $headerNames = []

Map of lowercase header name => original name at registration

$headers

private array<string|int, array<string|int, string>> $headers = []

Map of all registered headers, as original name => array of values

Methods

getHeader()

public getHeader(mixed $header) : array<string|int, mixed>
Parameters
$header : mixed
Return values
array<string|int, mixed>

getHeaderLine()

public getHeaderLine(mixed $header) : string
Parameters
$header : mixed
Return values
string

getHeaders()

public getHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>

getProtocolVersion()

public getProtocolVersion() : string
Return values
string

hasHeader()

public hasHeader(mixed $header) : bool
Parameters
$header : mixed
Return values
bool

assertValue()

private assertValue(string $value) : void
Parameters
$value : string
Tags
see
https://datatracker.ietf.org/doc/html/rfc7230#section-3.2

field-value = ( field-content / obs-fold ) field-content = field-vchar [ 1( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text VCHAR = %x21-7E obs-text = %x80-FF obs-fold = CRLF 1*( SP / HTAB )

normalizeHeaderValue()

private normalizeHeaderValue(mixed $value) : array<string|int, string>
Parameters
$value : mixed
Return values
array<string|int, string>

setHeaders()

private setHeaders(array<string|int, string|array<string|int, string>> $headers) : void
Parameters
$headers : array<string|int, string|array<string|int, string>>

trimAndValidateHeaderValues()

Trims whitespace from the header values.

private trimAndValidateHeaderValues(array<string|int, mixed> $values) : array<string|int, string>

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 )

Parameters
$values : array<string|int, mixed>

Header values

Tags
see
https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4
Return values
array<string|int, string>

Trimmed header values


        
On this page

Search results