Update of Default error doc

This commit is contained in:
2021-01-01 21:44:34 +01:00
parent bcdf36527f
commit 566ac0ca93
2 changed files with 6 additions and 3 deletions

View File

@ -102,6 +102,8 @@ int client_request_handler(sock *client, unsigned long client_num, unsigned int
client_keep_alive = hdr_connection != NULL && strcmp(hdr_connection, "keep-alive") == 0; client_keep_alive = hdr_connection != NULL && strcmp(hdr_connection, "keep-alive") == 0;
host = http_get_header_field(&req.hdr, "Host"); host = http_get_header_field(&req.hdr, "Host");
if (host == NULL || strchr(host, '/') != NULL) { if (host == NULL || strchr(host, '/') != NULL) {
// TODO fix IPv6 address in URL
host = client_addr_str;
res.status = http_get_status(400); res.status = http_get_status(400);
sprintf(err_msg, "The client provided no or an invalid Host header field."); sprintf(err_msg, "The client provided no or an invalid Host header field.");
goto respond; goto respond;
@ -333,7 +335,7 @@ int client_request_handler(sock *client, unsigned long client_num, unsigned int
http_msg != NULL ? http_msg->err_msg : "", err_msg[0] != 0 ? err_msg : ""); http_msg != NULL ? http_msg->err_msg : "", err_msg[0] != 0 ? err_msg : "");
content_length = sprintf(msg_buf, http_default_document, res.status->code, res.status->msg, content_length = sprintf(msg_buf, http_default_document, res.status->code, res.status->msg,
msg_pre_buf, res.status->code >= 300 && res.status->code < 400 ? "info" : "error", msg_pre_buf, res.status->code >= 300 && res.status->code < 400 ? "info" : "error",
http_error_icon, "#C00000"); http_error_icon, "#C00000", host);
http_add_header_field(&res.hdr, "Content-Type", "text/html; charset=UTF-8"); http_add_header_field(&res.hdr, "Content-Type", "text/html; charset=UTF-8");
} }
if (content_length >= 0) { if (content_length >= 0) {

View File

@ -123,7 +123,7 @@ const char *http_default_document =
"<!DOCTYPE html>\n" "<!DOCTYPE html>\n"
"<html lang=\"en\">\n" "<html lang=\"en\">\n"
"<head>\n" "<head>\n"
" <title>%1$i %2$s</title>\n" " <title>%1$i %2$s - %7$s</title>\n"
" <meta charset=\"UTF-8\"/>\n" " <meta charset=\"UTF-8\"/>\n"
" <meta name=\"theme-color\" content=\"%6$s\"/>\n" " <meta name=\"theme-color\" content=\"%6$s\"/>\n"
" <meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\"/>\n" " <meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\"/>\n"
@ -137,12 +137,13 @@ const char *http_default_document =
" h1{margin:0.5em 0;font-size:1.5em;}\n" " h1{margin:0.5em 0;font-size:1.5em;}\n"
" p{text-align:center;}\n" " p{text-align:center;}\n"
" div.footer{color:#808080;font-size:0.75em;text-align:center;margin:0.5em 0;}\n" " div.footer{color:#808080;font-size:0.75em;text-align:center;margin:0.5em 0;}\n"
" div.footer a{color:#808080;}\n"
" </style>\n" " </style>\n"
"</head>\n" "</head>\n"
"<body>\n" "<body>\n"
" <main>\n" " <main>\n"
"%3$s" "%3$s"
" <div class=\"footer\">Necronda web server " NECRONDA_VERSION "</div>\n" " <div class=\"footer\"><a href=\"https://%7$s/\">%7$s</a> - Necronda web server " NECRONDA_VERSION "</div>\n"
" </main>\n" " </main>\n"
"</body>\n" "</body>\n"
"</html>\n"; "</html>\n";