diff --git a/src/client.c b/src/client.c index b6bac35..999351d 100644 --- a/src/client.c +++ b/src/client.c @@ -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; host = http_get_header_field(&req.hdr, "Host"); if (host == NULL || strchr(host, '/') != NULL) { + // TODO fix IPv6 address in URL + host = client_addr_str; res.status = http_get_status(400); sprintf(err_msg, "The client provided no or an invalid Host header field."); 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 : ""); 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", - http_error_icon, "#C00000"); + http_error_icon, "#C00000", host); http_add_header_field(&res.hdr, "Content-Type", "text/html; charset=UTF-8"); } if (content_length >= 0) { diff --git a/src/http.h b/src/http.h index d43bdd4..b89ec12 100644 --- a/src/http.h +++ b/src/http.h @@ -123,7 +123,7 @@ const char *http_default_document = "\n" "\n" "\n" - " %1$i %2$s\n" + " %1$i %2$s - %7$s\n" " \n" " \n" " \n" @@ -137,12 +137,13 @@ const char *http_default_document = " h1{margin:0.5em 0;font-size:1.5em;}\n" " p{text-align:center;}\n" " div.footer{color:#808080;font-size:0.75em;text-align:center;margin:0.5em 0;}\n" + " div.footer a{color:#808080;}\n" " \n" "\n" "\n" "
\n" "%3$s" - "
Necronda web server " NECRONDA_VERSION "
\n" + "
%7$s - Necronda web server " NECRONDA_VERSION "
\n" "
\n" "\n" "\n";