Merge pull request #11727 from nupplaphil/bug/redirect
Fix HTTP Client redirect Bug
This commit is contained in:
commit
a2c929d128
|
@ -96,7 +96,7 @@ class HttpClient extends BaseFactory
|
||||||
RequestOptions::ALLOW_REDIRECTS => [
|
RequestOptions::ALLOW_REDIRECTS => [
|
||||||
'max' => 8,
|
'max' => 8,
|
||||||
'on_redirect' => $onRedirect,
|
'on_redirect' => $onRedirect,
|
||||||
'track_redirect' => true,
|
'track_redirects' => true,
|
||||||
'strict' => true,
|
'strict' => true,
|
||||||
'referer' => true,
|
'referer' => true,
|
||||||
],
|
],
|
||||||
|
|
|
@ -49,4 +49,19 @@ class HTTPClientTest extends MockedTest
|
||||||
|
|
||||||
self::assertFalse(DI::httpClient()->get('https://friendica.local')->isSuccess());
|
self::assertFalse(DI::httpClient()->get('https://friendica.local')->isSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for issue https://github.com/friendica/friendica/issues/11726
|
||||||
|
*/
|
||||||
|
public function testRedirect()
|
||||||
|
{
|
||||||
|
$this->httpRequestHandler->setHandler(new MockHandler([
|
||||||
|
new Response(302, ['Location' => 'https://mastodon.social/about']),
|
||||||
|
new Response(200, ['Location' => 'https://mastodon.social']),
|
||||||
|
]));
|
||||||
|
|
||||||
|
$result = DI::httpClient()->get('https://mastodon.social');
|
||||||
|
self::assertEquals('https://mastodon.social', $result->getUrl());
|
||||||
|
self::assertEquals('https://mastodon.social/about', $result->getRedirectUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user