From d2fedde41ce85d309be5456aa28494774400ed90 Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Wed, 11 Aug 2021 08:08:34 +0200 Subject: [PATCH] Fix HTTP header casing in existsRemote --- src/FileCache.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/FileCache.php b/src/FileCache.php index 9b053c9..0247860 100644 --- a/src/FileCache.php +++ b/src/FileCache.php @@ -257,6 +257,7 @@ protected function existsRemote($file) { $context = stream_context_create(['http' => ['method'=>'HEAD']]); $headers = get_headers($file->getUrl(), 1, $context); + $headers = array_change_key_case($headers, CASE_LOWER); $exists = explode(' ', $headers[0])[1][0] === '2'; @@ -265,14 +266,14 @@ protected function existsRemote($file) } if (!empty($this->config['mime_types'])) { - $type = trim(explode(';', $headers['Content-Type'])[0]); + $type = trim(explode(';', $headers['content-type'])[0]); if (!in_array($type, $this->config['mime_types'])) { throw new Exception("MIME type '{$type}' not allowed."); } } $maxBytes = intval($this->config['max_file_size']); - $size = intval($headers['Content-Length']); + $size = intval($headers['content-length']); if ($maxBytes >= 0 && $size > $maxBytes) { throw new Exception("The file is too large with more than {$maxBytes} bytes.");