bug #9445 [BrowserKit] fixed protocol-relative url redirection
This commit is contained in:
parent
99f3b3fefe
commit
e8b5c84c12
@ -484,6 +484,11 @@ abstract class Client
|
||||
);
|
||||
}
|
||||
|
||||
// protocol relative URL
|
||||
if (0 === strpos($uri, '//')) {
|
||||
return parse_url($currentUri, PHP_URL_SCHEME).':'.$uri;
|
||||
}
|
||||
|
||||
// anchor?
|
||||
if (!$uri || '#' == $uri[0]) {
|
||||
return preg_replace('/#.*?$/', '', $currentUri).$uri;
|
||||
|
@ -327,6 +327,18 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() automatically follows redirects if followRedirects is true');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('', 302, array('Location' => '/redirected')));
|
||||
$client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
|
||||
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows relative URLs');
|
||||
|
||||
$client = new TestClient();
|
||||
$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');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected')));
|
||||
$client->request('POST', 'http://www.example.com/foo/foobar', array('name' => 'bar'));
|
||||
|
Reference in New Issue
Block a user