Fixed redirects

This commit is contained in:
aymm 2021-03-11 16:18:37 +00:00
parent c938ede0a2
commit 7264b523a6

View File

@ -158,7 +158,7 @@ class APnutI
break; break;
case 'location': case 'location':
case 'Location': case 'Location':
$this->redirectTarget = $v; $this->redirect_target = $v;
break; break;
} }
} }
@ -230,6 +230,9 @@ class APnutI
$response = $this->parseHeaders($response); $response = $this->parseHeaders($response);
if (!empty($response)) { if (!empty($response)) {
$response = json_decode($response, true); $response = json_decode($response, true);
if ($response === null && !empty($this->redirect_target)) {
throw new HttpPnutRedirectException($this->redirect_target);
}
try { try {
$this->meta = new Meta($response); $this->meta = new Meta($response);
} catch (NotAuthorizedException $nae) { } catch (NotAuthorizedException $nae) {