Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 4136139

Browse files
Maks3wweierophinney
authored andcommitted
[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
1 parent 185e615 commit 4136139

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/RequestTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* @property array $headers
2727
* @property array $headerNames
2828
* @property StreamInterface $stream
29+
* @method bool hasHeader(string $header)
2930
*/
3031
trait RequestTrait
3132
{
@@ -251,7 +252,7 @@ public function withUri(UriInterface $uri, $preserveHost = false)
251252
$new = clone $this;
252253
$new->uri = $uri;
253254

254-
if ($preserveHost) {
255+
if ($preserveHost && $this->hasHeader('Host')) {
255256
return $new;
256257
}
257258

0 commit comments

Comments
 (0)