false, CURLOPT_FAILONERROR => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_TCP_FASTOPEN => true, CURLOPT_CONNECTTIMEOUT => 2, CURLOPT_MAXREDIRS => 4, CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS, CURLOPT_TIMEOUT => 10, CURLOPT_USERAGENT => 'Mozilla/5.0 (compatible) Misuzu/' . git_tag(), ]); $curlBody = curl_exec($curl); curl_close($curl); $finfo = finfo_open(FILEINFO_MIME_TYPE); $fileMime = finfo_buffer($finfo, $curlBody); finfo_close($finfo); if (!in_array($fileMime, $acceptedMimeTypes, true)) { echo render_error(404); return; } $fileSize = strlen($curlBody); $fileName = basename($parsedUrl['path'] ?? "proxied-image-{$expectedHash}"); header("Content-Type: {$fileMime}"); header("Content-Length: {$fileSize}"); header("Content-Disposition: inline; filename=\"{$fileName}\""); echo $curlBody;