mirror of
https://github.com/friendica/friendica
synced 2025-05-05 23:44:15 +02:00
Merge pull request #14267 from mexon/mat/permanent-redirect
Update feed URL after permanent redirect
This commit is contained in:
commit
491a5cab53
5 changed files with 63 additions and 2 deletions
|
@ -52,6 +52,8 @@ class GuzzleResponse extends Response implements ICanHandleHttpResponses, Respon
|
|||
private $redirectUrl = '';
|
||||
/** @var bool */
|
||||
private $isRedirectUrl = false;
|
||||
/** @var bool */
|
||||
private $redirectIsPermanent = false;
|
||||
|
||||
public function __construct(ResponseInterface $response, string $url, $errorNumber = 0, $error = '')
|
||||
{
|
||||
|
@ -91,6 +93,13 @@ class GuzzleResponse extends Response implements ICanHandleHttpResponses, Respon
|
|||
if (count($headersRedirect) > 0) {
|
||||
$this->redirectUrl = end($headersRedirect);
|
||||
$this->isRedirectUrl = true;
|
||||
|
||||
$this->redirectIsPermanent = true;
|
||||
foreach (($response->getHeader(RedirectMiddleware::STATUS_HISTORY_HEADER) ?? []) as $history) {
|
||||
if (preg_match('/30(2|3|4|7)/', $history)) {
|
||||
$this->redirectIsPermanent = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,6 +154,12 @@ class GuzzleResponse extends Response implements ICanHandleHttpResponses, Respon
|
|||
return $this->isRedirectUrl;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function redirectIsPermanent(): bool
|
||||
{
|
||||
return $this->redirectIsPermanent;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function getErrorNumber(): int
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue