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

Commit

Permalink
[ServerRequest] Host header is not set when URI has one
Browse files Browse the repository at this point in the history
> 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
  • Loading branch information
Maks3w committed Jun 11, 2015
1 parent 6bb1641 commit a1c1078
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/RequestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @property array $headers
* @property array $headerNames
* @property StreamInterface $stream
* @method bool hasHeader(string $header)
*/
trait RequestTrait
{
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit a1c1078

Please sign in to comment.