Skip to content

Commit

Permalink
fixed protocol-relative URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Mar 27, 2014
1 parent 2a14639 commit d744878
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ protected function requestFromRequest(Request $request, $changeHistory = true)
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;
Expand Down
2 changes: 1 addition & 1 deletion Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public function testFollowRedirectWithMaxRedirects()
$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');
Expand Down

0 comments on commit d744878

Please sign in to comment.