From a1c107826bf2a7b414d3ee660e95b281f93928ae Mon Sep 17 00:00:00 2001 From: Maks3w Date: Thu, 11 Jun 2015 23:22:08 +0200 Subject: [PATCH] [ServerRequest] Host header is not set when URI has one > You can opt-in to preserving the original state of the Host header by passing true for the second ($preserveHost) argument. When this argument is set to true, the returned request will not update the Host header of the returned message -- unless the message contains no Host header. **unless the message contains no Host header.** So $preserveHost MUST be ignored if message does not have a Host header --- src/RequestTrait.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/RequestTrait.php b/src/RequestTrait.php index 048ac4b7..7bddf002 100644 --- a/src/RequestTrait.php +++ b/src/RequestTrait.php @@ -26,6 +26,7 @@ * @property array $headers * @property array $headerNames * @property StreamInterface $stream + * @method bool hasHeader(string $header) */ trait RequestTrait { @@ -251,7 +252,7 @@ public function withUri(UriInterface $uri, $preserveHost = false) $new = clone $this; $new->uri = $uri; - if ($preserveHost) { + if ($preserveHost && $this->hasHeader('Host')) { return $new; }