Http responses contain body

This commit is contained in:
2021-05-16 12:23:34 +02:00
parent a8c6962b20
commit 782ad13e48
7 changed files with 175 additions and 30 deletions

View File

@ -89,3 +89,66 @@ pub static HTTP_STATUSES: [(u16, StatusClass, &str, &str); 41] = [
(505, ServerError, "HTTP Version Not Supported",
"The server does not support, or refuses to support, the HTTP protocol version that was used in the request message."),
];
pub static DEFAULT_DOCUMENT: &str = "\
<!DOCTYPE html>\n\
<html lang=\"en\">\n\
<head>\n\
\t<title>{status_code} {status_message} - Locutus - {hostname}</title>\n\
\t<meta charset=\"UTF-8\"/>\n\
\t<meta name=\"theme-color\" content=\"{theme_color}\"/>\n\
\t<meta name=\"color-scheme\" content=\"light dark\"/>\n\
\t<meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\"/>\n\
\t<meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\"/>\n\
\t<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\"/>\n\
\t<style>\n\
\t\thtml{{font-family:\"Arial\",sans-serif;--error:#C00000;--warning:#E0C000;--success:#008000;--info:#606060;--color:var(--{color_name});}}\n\
\t\tbody{{background-color:#F0F0F0;margin:0;}}\n\
\t\tmain{{max-width:650px;margin:2em auto;}}\n\
\t\tsection{{margin:1em;background-color:#FFFFFF;border: 1px solid var(--color);border-radius:4px;padding:1em;}}\n\
\t\th1,h2,h3,h4,h5,h6,h7{{text-align:center;color:var(--color);font-weight:normal;}}\n\
\t\th1{{font-size:3em;margin:0.125em 0 0.125em 0;}}\n\
\t\th2{{font-size:1.5em;margin:0.25em 0 1em 0;}}\n\
\t\tp{{text-align:center;font-size:0.875em;}}\n\
\t\tdiv.footer{{color:#808080;font-size:0.75em;text-align:center;margin:2em 0 0.5em 0;}}\n\
\t\tdiv.footer a{{color:#808080;}}\n\
\t\t@media(prefers-color-scheme:dark){{\n\
\t\t\thtml{{color:#FFFFFF;}}\n\
\t\t\tbody{{background-color:#101010;}}\n\
\t\t\tsection{{background-color:#181818;}}\n\
\t\t}}\n\
\t</style>\n\
</head>\n\
<body>\n\
\t<main>\n\
\t\t<section>\n\
{doc}\
\t\t\t<div class=\"footer\"><a href=\"https://{hostname}/\">{hostname}</a> - {server_str}</div>\n\
\t\t</section>\n\
\t</main>\n\
</body>\n\
</html>\n";
pub static ERROR_DOCUMENT: &str = "\
\t\t\t<h1>{code}</h1>\n\
\t\t\t<h2>{message} :&#xFEFF;(</h2>\n\
\t\t\t<p>{desc}</p>\n\
\t\t\t<p>{info}</p>\n";
pub static WARNING_DOCUMENT: &str = "\
\t\t\t<h1>{code}</h1>\n\
\t\t\t<h2>{message} :&#xFEFF;o</h2>\n\
\t\t\t<p>{desc}</p>\n\
\t\t\t<p>{info}</p>\n";
pub static SUCCESS_DOCUMENT: &str = "\
\t\t\t<h1>{code}</h1>\n\
\t\t\t<h2>{message} :&#xFEFF;)</h2>\n\
\t\t\t<p>{desc}</p>\n\
\t\t\t<p>{info}</p>\n";
pub static INFO_DOCUMENT: &str = "\
\t\t\t<h1>{code}</h1>\n\
\t\t\t<h2>{message} :&#xFEFF;)</h2>\n\
\t\t\t<p>{desc}</p>\n\
\t\t\t<p>{info}</p>\n";