Bug fixes

- Bypass for downloads
- Always set CORS headers
This commit is contained in:
Kieran 2018-12-06 18:41:39 +08:00
parent 06581ffa26
commit bd443ccb30
2 changed files with 7 additions and 8 deletions

View File

@ -36,7 +36,8 @@
}
case "file_info": {
$rsp->ok = true;
$rsp->data = $fs->GetFileInfo($cmd->id);
$rsp->data = $fs->GetFileInfo($cmd->id);
$rsp->data->DownloadHost = Upload::GetUploadHost(); //bypass CF proxy for downloads (slow..)
break;
}
case 'captcha_info': {

View File

@ -31,11 +31,12 @@
$abuse->CheckDownload($id);
$tracking->TrackDownload($this->Fs, $id);
header("Access-Control-Allow-Origin: " . $_SERVER["HTTP_ORIGIN"]);
header("Access-Control-Allow-Headers: x-void-embeded");
header("Access-Control-Allow-Method: GET");
//allow embeded header from preflight check
if($_SERVER["REQUEST_METHOD"] === "OPTIONS"){
header("Access-Control-Allow-Origin: " . $_SERVER["HTTP_ORIGIN"]);
header("Access-Control-Allow-Headers: x-void-embeded");
} else {
if($_SERVER["REQUEST_METHOD"] === "GET") {
if(isset($_SERVER['HTTP_X_VOID_EMBEDED'])) {
$this->SendFile($this->Fs->GetAbsoluteFilePath($id), 604800);
} else {
@ -45,9 +46,6 @@
}
function SendFile($location, $expire){
header("Access-Control-Allow-Origin: " . $_SERVER["HTTP_ORIGIN"]);
header("Access-Control-Allow-Headers: x-void-embeded");
header("Access-Control-Allow-Method: GET");
header("Content-Type: application/octet-stream");
header('Content-Length: ' . filesize($location));
flush();