mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-24 01:53:58 +01:00
The "Host" header is being preserved, if it was set manually.
This commit is contained in:
parent
789bd2309e
commit
afaa8917cb
@ -93,7 +93,7 @@ class Client implements ClientInterface
|
||||
$options = $this->prepareDefaults($options);
|
||||
|
||||
return $this->transfer(
|
||||
$request->withUri($this->buildUri($request->getUri(), $options)),
|
||||
$request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader("Host")),
|
||||
$options
|
||||
);
|
||||
}
|
||||
|
@ -592,4 +592,27 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$client->send($request, ['query' => ['foo' => 'bar', 'john' => 'doe']]);
|
||||
$this->assertEquals('foo=bar&john=doe', $mock->getLastRequest()->getUri()->getQuery());
|
||||
}
|
||||
|
||||
public function testSendSendsWithIpAddressAndPortAndHostHeaderInRequestTheHostShouldBePreserved()
|
||||
{
|
||||
$mockHandler = new MockHandler([new Response(200)]);
|
||||
$client = new Client(['base_uri' => '127.0.0.1:8585', 'handler' => $mockHandler]);
|
||||
$request = new Request('GET', '/test', ["Host"=>"foo.com"]);
|
||||
|
||||
$client->send($request);
|
||||
|
||||
$this->assertEquals("foo.com", $mockHandler->getLastRequest()->getHeader("Host")[0]);
|
||||
}
|
||||
|
||||
public function testSendSendsWithDomainAndHostHeaderInRequestTheHostShouldBePreserved()
|
||||
{
|
||||
$mockHandler = new MockHandler([new Response(200)]);
|
||||
$client = new Client(['base_uri' => 'http://foo2.com', 'handler' => $mockHandler]);
|
||||
$request = new Request('GET', '/test', ["Host"=>"foo.com"]);
|
||||
|
||||
$client->send($request);
|
||||
|
||||
$this->assertEquals("foo.com", $mockHandler->getLastRequest()->getHeader("Host")[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user