Debugging redirections

This commit is contained in:
aymm 2021-03-11 16:09:39 +00:00
parent 6b69e990e1
commit c938ede0a2

View File

@ -213,6 +213,7 @@ class APnutI
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE); $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$effectiveURL = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); $effectiveURL = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_close($ch); curl_close($ch);
$this->logger->debug("{$method} Request to {$url}. Received status: {$http_status}. Response: {$response}");
if ($http_status === 0) { if ($http_status === 0) {
throw new \Exception('Unable to connect to Pnut ' . $url); throw new \Exception('Unable to connect to Pnut ' . $url);
} }
@ -221,12 +222,12 @@ class APnutI
throw new \Exception('SSL verification failed, connection terminated: ' . $url); throw new \Exception('SSL verification failed, connection terminated: ' . $url);
} }
} }
if ($http_status == 302) {
#echo json_encode(preg_match_all('/^Location:(.*)$/mi', $response, $matches));
throw new HttpPnutRedirectException($response);
}
if (!empty($response)) { if (!empty($response)) {
$response = $this->parseHeaders($response); $response = $this->parseHeaders($response);
if ($http_status == 302) {
#echo json_encode(preg_match_all('/^Location:(.*)$/mi', $response, $matches));
throw new HttpPnutRedirectException($response);
}
if (!empty($response)) { if (!empty($response)) {
$response = json_decode($response, true); $response = json_decode($response, true);
try { try {