str()
str(\Psr\Http\Message\MessageInterface $message) : string
Returns the string representation of an HTTP message.
Parameters
\Psr\Http\Message\MessageInterface | $message | Message to convert to a string. |
uri_for(string|\Psr\Http\Message\UriInterface $uri) : \Psr\Http\Message\UriInterface
Returns a UriInterface for the given value.
This function accepts a string or UriInterface and returns a UriInterface for the given value. If the value is already a UriInterface, it is returned as-is.
string|\Psr\Http\Message\UriInterface | $uri |
package |
Application |
---|
stream_for(resource|string|int|float|bool|\Psr\Http\Message\StreamInterface|callable|\Iterator|null $resource = '', array $options = []) : \Psr\Http\Message\StreamInterface
Create a new stream based on the input type.
Options is an associative array that can contain the following keys:
This method accepts the following $resource
types:
Psr\Http\Message\StreamInterface
: Returns the value as-is.string
: Creates a stream object that uses the given string as the contents.resource
: Creates a stream object that wraps the given PHP stream resource.Iterator
: If the provided value implements Iterator
, then a read-only
stream object will be created that wraps the given iterable. Each time the
stream is read from, data from the iterator will fill a buffer and will be
continuously called until the buffer is equal to the requested read size.
Subsequent read calls will first read from the buffer and then call next
on the underlying iterator until it is exhausted.object
with __toString()
: If the object has the __toString()
method,
the object will be cast to a string and then a stream will be returned that
uses the string value.NULL
: When null
is passed, an empty stream object is returned.callable
When a callable is passed, a read-only stream object will be
created that invokes the given callable. The callable is invoked with the
number of suggested bytes to read. The callable can return any number of
bytes, but MUST return false
when there is no more data to return. The
stream object that wraps the callable will invoke the callable until the
number of requested bytes are available. Any additional bytes will be
buffered and used in subsequent reads.resource|string|int|float|bool|\Psr\Http\Message\StreamInterface|callable|\Iterator|null | $resource | Entity body data |
array | $options | Additional options |
if the $resource arg is not valid.
package |
Application |
---|
parse_header(string|array $header) : array
Parse an array of header values containing ";" separated data into an array of associative arrays representing the header key value pair data of the header. When a parameter does not contain a value, but just contains a key, this function will inject a key with a '' string value.
string|array | $header | Header to parse into components. |
Returns the parsed header values.
package |
Application |
---|
normalize_header(string|array $header) : array
Converts an array of header values that may contain comma separated headers into an array of headers with no comma separated values.
string|array | $header | Header to normalize. |
Returns the normalized header field values.
package |
Application |
---|
modify_request(\Psr\Http\Message\RequestInterface $request, array $changes) : \Psr\Http\Message\RequestInterface
Clone and modify a request with the given changes.
This method is useful for reducing the number of clones needed to mutate a message.
The changes can be one of:
\Psr\Http\Message\RequestInterface | $request | Request to clone and modify. |
array | $changes | Changes to apply. |
package |
Application |
---|
rewind_body(\Psr\Http\Message\MessageInterface $message) : mixed
Attempts to rewind a message body and throws an exception on failure.
The body of the message will only be rewound if a call to tell()
returns a
value other than 0
.
\Psr\Http\Message\MessageInterface | $message | Message to rewind |
package |
Application |
---|
try_fopen(string $filename, string $mode) : resource
Safely opens a PHP stream resource using a filename.
When fopen fails, PHP normally raises a warning. This function adds an error handler that checks for errors and throws an exception instead.
string | $filename | File to open |
string | $mode | Mode used to open the file |
if the file cannot be opened
package |
Application |
---|
copy_to_string(\Psr\Http\Message\StreamInterface $stream, int $maxLen = -1) : string
Copy the contents of a stream into a string until the given number of bytes have been read.
\Psr\Http\Message\StreamInterface | $stream | Stream to read |
int | $maxLen | Maximum number of bytes to read. Pass -1 to read the entire stream. |
on error.
package |
Application |
---|
copy_to_stream(\Psr\Http\Message\StreamInterface $source, \Psr\Http\Message\StreamInterface $dest, int $maxLen = -1) : mixed
Copy the contents of a stream into another stream until the given number of bytes have been read.
\Psr\Http\Message\StreamInterface | $source | Stream to read from |
\Psr\Http\Message\StreamInterface | $dest | Stream to write to |
int | $maxLen | Maximum number of bytes to read. Pass -1 to read the entire stream. |
on error.
package |
Application |
---|
hash(\Psr\Http\Message\StreamInterface $stream, string $algo, bool $rawOutput = false) : string
Calculate a hash of a stream.
This method reads the entire stream to calculate a rolling hash, based on
PHP's hash_init
functions.
\Psr\Http\Message\StreamInterface | $stream | Stream to calculate the hash for |
string | $algo | Hash algorithm (e.g. md5, crc32, etc) |
bool | $rawOutput | Whether or not to use raw output |
on error.
Returns the hash of the stream
package |
Application |
---|
readline(\Psr\Http\Message\StreamInterface $stream, int|null $maxLength = null) : string
Read a line from the stream up to the maximum allowed buffer length.
\Psr\Http\Message\StreamInterface | $stream | Stream to read from |
int|null | $maxLength | Maximum buffer length |
package |
Application |
---|
parse_request(string $message) : \GuzzleHttp\Psr7\Request
Parses a request message string into a request object.
string | $message | Request message string. |
package |
Application |
---|
parse_response(string $message) : \GuzzleHttp\Psr7\Response
Parses a response message string into a response object.
string | $message | Response message string. |
package |
Application |
---|
parse_query(string $str, int|bool $urlEncoding = true) : array
Parse a query string into an associative array.
If multiple values are found for the same key, the value of that key value
pair will become an array. This function does not parse nested PHP style
arrays into an associative array (e.g., foo[a]=1&foo[b]=2
will be parsed
into ['foo[a]' => '1', 'foo[b]' => '2'])
.
string | $str | Query string to parse |
int|bool | $urlEncoding | How the query string is encoded |
package |
Application |
---|
build_query(array $params, int|false $encoding = PHP_QUERY_RFC3986) : string
Build a query string from an array of key value pairs.
This function can use the return value of parse_query()
to build a query
string. This function does not modify the provided keys when an array is
encountered (like http_build_query()
would).
array | $params | Query string parameters. |
int|false | $encoding | Set to false to not encode, PHP_QUERY_RFC3986 to encode using RFC3986, or PHP_QUERY_RFC1738 to encode using RFC1738. |
package |
Application |
---|
mimetype_from_filename(string $filename) : string|null
Determines the mimetype of a file by looking at its extension.
string | $filename |
package |
Application |
---|
mimetype_from_extension( $extension) : string|null
Maps a file extensions to a mimetype.
$extension | string The file extension. |
package |
Application |
---|
get_message_body_summary(\Psr\Http\Message\MessageInterface $message, int $truncateAt = 120) : string|null
Get a short summary of the message body.
Will return null
if the response is not printable.
\Psr\Http\Message\MessageInterface | $message | The message to get the body summary |
int | $truncateAt | The maximum allowed size of the summary |
package |
Application |
---|