Skip to content

Latest commit

 

History

History
502 lines (178 loc) · 4.44 KB

MessageTrait.md

File metadata and controls

502 lines (178 loc) · 4.44 KB

MessageTrait

Trait implementing functionality common to requests and responses.

  • Full name: \GuzzleHttp\Psr7\MessageTrait

Properties

headers

private array<string,string[]> $headers

headerNames

private array<string,string> $headerNames

protocol

private string $protocol

stream

private \Psr\Http\Message\StreamInterface|null $stream

Methods

getProtocolVersion

public getProtocolVersion(): string

withProtocolVersion

public withProtocolVersion(mixed $version): \Psr\Http\Message\MessageInterface

Parameters:

Parameter Type Description
$version mixed

getHeaders

public getHeaders(): array

hasHeader

public hasHeader(mixed $header): bool

Parameters:

Parameter Type Description
$header mixed

getHeader

public getHeader(mixed $header): array

Parameters:

Parameter Type Description
$header mixed

getHeaderLine

public getHeaderLine(mixed $header): string

Parameters:

Parameter Type Description
$header mixed

withHeader

public withHeader(mixed $header, mixed $value): \Psr\Http\Message\MessageInterface

Parameters:

Parameter Type Description
$header mixed
$value mixed

withAddedHeader

public withAddedHeader(mixed $header, mixed $value): \Psr\Http\Message\MessageInterface

Parameters:

Parameter Type Description
$header mixed
$value mixed

withoutHeader

public withoutHeader(mixed $header): \Psr\Http\Message\MessageInterface

Parameters:

Parameter Type Description
$header mixed

getBody

public getBody(): \Psr\Http\Message\StreamInterface

withBody

public withBody(\Psr\Http\Message\StreamInterface $body): \Psr\Http\Message\MessageInterface

Parameters:

Parameter Type Description
$body \Psr\Http\Message\StreamInterface

setHeaders

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

Parameters:

Parameter Type Description
$headers array<string|int,string|string[]>

normalizeHeaderValue

private normalizeHeaderValue(mixed $value): string[]

Parameters:

Parameter Type Description
$value mixed

trimAndValidateHeaderValues

Trims whitespace from the header values.

private trimAndValidateHeaderValues(array $values): 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:

Parameter Type Description
$values array Header values

Return Value:

Trimmed header values

See Also:


assertHeader

private assertHeader(mixed $header): void

Parameters:

Parameter Type Description
$header mixed

See Also:


assertValue

private assertValue(string $value): void

Parameters:

Parameter Type Description
$value string

See Also:

  • https://tools.ietf.org/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 )