Message
in package
Table of Contents
- bodySummary() : string|null
- Get a short summary of the message body.
- parseMessage() : array<string|int, mixed>
- Parses an HTTP message into an associative array.
- parseRequest() : Request
- Parses a request message string into a request object.
- parseRequestUri() : string
- Constructs a URI for an HTTP request message.
- parseResponse() : Response
- Parses a response message string into a response object.
- rewindBody() : mixed
- Attempts to rewind a message body and throws an exception on failure.
- toString() : string
- Returns the string representation of an HTTP message.
Methods
bodySummary()
Get a short summary of the message body.
public
static bodySummary(MessageInterface $message[, int $truncateAt = 120 ]) : string|null
Will return null
if the response is not printable.
Parameters
- $message : MessageInterface
-
The message to get the body summary
- $truncateAt : int = 120
-
The maximum allowed size of the summary
Return values
string|null —parseMessage()
Parses an HTTP message into an associative array.
public
static parseMessage(string $message) : array<string|int, mixed>
The array contains the "start-line" key containing the start line of the message, "headers" key containing an associative array of header array values, and a "body" key containing the body of the message.
Parameters
- $message : string
-
HTTP request or response to parse.
Return values
array<string|int, mixed> —parseRequest()
Parses a request message string into a request object.
public
static parseRequest(string $message) : Request
Parameters
- $message : string
-
Request message string.
Return values
Request —parseRequestUri()
Constructs a URI for an HTTP request message.
public
static parseRequestUri(string $path, array<string|int, mixed> $headers) : string
Parameters
- $path : string
-
Path from the start-line
- $headers : array<string|int, mixed>
-
Array of headers (each value an array).
Return values
string —parseResponse()
Parses a response message string into a response object.
public
static parseResponse(string $message) : Response
Parameters
- $message : string
-
Response message string.
Return values
Response —rewindBody()
Attempts to rewind a message body and throws an exception on failure.
public
static rewindBody(MessageInterface $message) : mixed
The body of the message will only be rewound if a call to tell()
returns a value other than 0
.
Parameters
- $message : MessageInterface
-
Message to rewind
Tags
Return values
mixed —toString()
Returns the string representation of an HTTP message.
public
static toString(MessageInterface $message) : string
Parameters
- $message : MessageInterface
-
Message to convert to a string.