Try to unify API responses
This commit is contained in:
@ -5,8 +5,8 @@ function http_401_unauthorized(): void {
|
||||
header('Status: 401');
|
||||
header('WWW-Authenticate: Basic realm="Elwig"');
|
||||
header('Content-Type: text/plain; charset=UTF-8');
|
||||
header('Content-Length: 20');
|
||||
exit("401 Unauthorized :(\n");
|
||||
header('Content-Length: 17');
|
||||
exit("401 Unauthorized\n");
|
||||
}
|
||||
|
||||
function authenticate(): void {
|
||||
|
@ -7,10 +7,12 @@ function get_fmt(): string {
|
||||
if ($fmt === 'ascii') {
|
||||
header('Status: 303');
|
||||
header('Location: ?format=text');
|
||||
exit();
|
||||
header('Content-Length: 14');
|
||||
exit("303 See Other\n");
|
||||
} else if ($fmt !== 'json' && $fmt !== 'html' && $fmt !== 'text') {
|
||||
header('Status: 300');
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
header('Content-Length: 162');
|
||||
echo "<!DOCTYPE html><html><head></head><body>\n<a href='?format=html'>HTML</a><br/>\n<a href='?format=json'>JSON</a><br/>\n<a href='?format=text'>Text</a>\n</body></html>\n";
|
||||
exit();
|
||||
}
|
||||
|
Reference in New Issue
Block a user