fixed protocol-relative URLs

This commit is contained in:
Fabien Potencier 2014-03-27 10:02:54 +01:00
parent 289da16681
commit d9cf28d016
2 changed files with 3 additions and 2 deletions

View File

@ -613,7 +613,8 @@ abstract class Client
private function updateServerFromUri($server, $uri)
{
$server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST);
$server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME);
$scheme = parse_url($uri, PHP_URL_SCHEME);
$server['HTTPS'] = null === $scheme ? $server['HTTPS'] : 'https' == $scheme;
unset($server['HTTP_IF_NONE_MATCH'], $server['HTTP_IF_MODIFIED_SINCE']);
return $server;

View File

@ -399,7 +399,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows relative URLs');
$client = new TestClient();
$client->setNextResponse(new Response('', 302, array('Location' => 'https://www.example.org/')));
$client->setNextResponse(new Response('', 302, array('Location' => '//www.example.org/')));
$client->request('GET', 'https://www.example.com/');
$this->assertEquals('https://www.example.org/', $client->getRequest()->getUri(), '->followRedirect() follows protocol-relative URLs');