From 01e094d95d344d5196fb58ccea68bf5cca6e1ec6 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sat, 16 Jan 2021 12:27:41 +0800 Subject: [PATCH] return json with content-type --- common.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common.php b/common.php index c43ab03..30ba836 100644 --- a/common.php +++ b/common.php @@ -191,7 +191,6 @@ function main($path) // echo 'count$disk:'.count($disktags); if (count($disktags)>1) { if ($path=='/'||$path=='') { - if (getConfig('autoJumpFirstDisk')) return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0].'/') ]); $files['type'] = 'folder'; $files['childcount'] = count($disktags); $files['showname'] = 'root'; @@ -202,8 +201,9 @@ function main($path) } if ($_GET['json']) { // return a json - return output(json_encode($files)); + return output(json_encode($files), 200, ['Content-Type' => 'application/json']); } + if (getConfig('autoJumpFirstDisk')) return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0].'/') ]); } else { $_SERVER['disktag'] = splitfirst( substr(path_format($path), 1), '/' )[0]; //$pos = strpos($path, '/'); @@ -331,7 +331,7 @@ function main($path) if ($_GET['json']) { // return a json - return output(json_encode($files)); + return output(json_encode($files), 200, ['Content-Type' => 'application/json']); } // random file if (isset($_GET['random'])&&$_GET['random']!=='') {