mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-01-19 08:57:55 +00:00
support 404.html
This commit is contained in:
parent
594331d432
commit
4b15fb1017
1 changed files with 7 additions and 1 deletions
|
@ -64,9 +64,15 @@ $command = "sh -c \"cd '$git_root' && /usr/bin/git show 'master:$file_url'\"";
|
||||||
## We are executing command twice (first for send_response-checking, then for actual raw output to stream),
|
## We are executing command twice (first for send_response-checking, then for actual raw output to stream),
|
||||||
## which seems wasteful, but it seems exec+echo cannot do raw binary output? Is this true?
|
## which seems wasteful, but it seems exec+echo cannot do raw binary output? Is this true?
|
||||||
exec($command, $output, $retval);
|
exec($command, $output, $retval);
|
||||||
|
if ($retval != 0) {
|
||||||
|
# check for a 404.html before we return an error. TODO: return 404 as response code
|
||||||
|
$file_url = "404.html";
|
||||||
|
$command = "sh -c \"cd '$git_root' && /usr/bin/git show 'master:$file_url'\"";
|
||||||
|
exec($command, $output, $retval);
|
||||||
if ($retval != 0) {
|
if ($retval != 0) {
|
||||||
send_response(404 , "no such file in repo: '" . htmlspecialchars($file_url) . "'");
|
send_response(404 , "no such file in repo: '" . htmlspecialchars($file_url) . "'");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$mime_types = array(
|
$mime_types = array(
|
||||||
"svg" => "image/svg+xml",
|
"svg" => "image/svg+xml",
|
||||||
|
|
Loading…
Reference in a new issue