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

fix deprecation warnings for getHeader and getHeaders methods

refs #228
This commit is contained in:
Yassine Doghri 2022-08-01 10:13:16 +00:00
parent e66bf44341
commit 10a2ae0248
3 changed files with 9 additions and 4 deletions

View File

@ -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,

View File

@ -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);

View File

@ -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) ?>