phasync
Request / withUri

Method

Request::withUri

Returns an instance with the provided URI.

Description#

public Request::withUri(
    $uri,
    $preserveHost = false
): RequestInterface

This method MUST update the Host header of the returned request by default if the URI contains a host component. If the URI does not contain a host component, any pre-existing Host header MUST be carried over to the returned request.

You can opt-in to preserving the original state of the Host header by setting $preserveHost to true. When $preserveHost is set to true, this method interacts with the Host header in the following ways:

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new UriInterface instance.

Parameters#

$uri
New request URI to use.
$preserveHost = false
Preserve the original state of the Host header.

Return values#

RequestInterface