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()  : static
withBody()  : static
withHeader()  : static
withoutHeader()  : static
withProtocolVersion()  : static
assertHeader()  : void
assertNoLineSeparators()  : void
assertProtocolVersion()  : 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

withAddedHeader()

public withAddedHeader(mixed $header, mixed $value) : static
Parameters
$header : mixed
$value : mixed
Return values
static

withHeader()

public withHeader(mixed $header, mixed $value) : static
Parameters
$header : mixed
$value : mixed
Return values
static

withoutHeader()

public withoutHeader(mixed $header) : static
Parameters
$header : mixed
Return values
static

withProtocolVersion()

public withProtocolVersion(mixed $version) : static
Parameters
$version : mixed
Return values
static

assertNoLineSeparators()

private assertNoLineSeparators(string $value, string $field) : void
Parameters
$value : string
$field : string

assertProtocolVersion()

private assertProtocolVersion(mixed $version) : void
Parameters
$version : mixed

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