Message
in package
Table of Contents
Methods
- 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() : RequestInterface
- Parses a request message string into a request object.
- parseRequestUri() : string
- Constructs a URI for an HTTP request message.
- parseResponse() : ResponseInterface
- Parses a response message string into a response object.
- rewindBody() : void
- 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|nullparseMessage()
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) : RequestInterface
Parameters
- $message : string
-
Request message string.
Return values
RequestInterfaceparseRequestUri()
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
stringparseResponse()
Parses a response message string into a response object.
public
static parseResponse(string $message) : ResponseInterface
Parameters
- $message : string
-
Response message string.
Return values
ResponseInterfacerewindBody()
Attempts to rewind a message body and throws an exception on failure.
public
static rewindBody(MessageInterface $message) : void
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
toString()
Returns the string representation of an HTTP message.
public
static toString(MessageInterface $message) : string
Parameters
- $message : MessageInterface
-
Message to convert to a string.