Skip to content
Snippets Groups Projects
Commit 10a2ae02 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix(router): check if Accept header is set before getting value

fix deprecation warnings for getHeader and getHeaders methods

refs #228
parent e66bf443
No related branches found
No related tags found
No related merge requests found
......@@ -69,7 +69,7 @@ if (! function_exists('download_file')) {
true,
)
) {
$newFileUrl = trim($response->getHeader('location')->getValue());
$newFileUrl = trim($response->header('location')->getValue());
$response = $client->get($newFileUrl, [
'headers' => [
'User-Agent' => 'Castopod/' . CP_VERSION,
......
......@@ -110,7 +110,12 @@ class Router extends CodeIgniterRouter
$request = Services::request();
$negotiate = Services::negotiator();
$acceptHeader = $request->getHeader('Accept')
// Accept header is mandatory
if ($request->header('Accept') === null) {
break;
}
$acceptHeader = $request->header('Accept')
->getValue();
$parsedHeader = $negotiate->parseHeader($acceptHeader);
......
......@@ -272,7 +272,7 @@ $error_id = uniqid('error', true); ?>
<?php endif; ?>
<?php $headers = $request->getHeaders(); ?>
<?php $headers = $request->headers(); ?>
<?php if (! empty($headers)) : ?>
<h3>Headers</h3>
......@@ -320,7 +320,7 @@ $error_id = uniqid('error', true); ?>
</tr>
</table>
<?php $headers = $response->getHeaders(); ?>
<?php $headers = $response->headers(); ?>
<?php if (! empty($headers)) : ?>
<?php natsort($headers) ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment