1
0
Fork 0
mirror of https://github.com/kakwa/uts-server synced 2025-07-02 19:43:24 +02:00

Added lang to html.

Lazy calculation of static page size.
This commit is contained in:
Joao Alves 2021-09-22 09:05:59 +01:00
parent 4c5e5b8251
commit 9b49e5578f
2 changed files with 8 additions and 5 deletions

View file

@ -1,6 +1,6 @@
const char *content_static_page = \ const char *content_static_page = \
"<!DOCTYPE html>" \ "<!DOCTYPE html>" \
"<html>" \ "<html lang=\"en\">" \
"<head>" \ "<head>" \
" <meta charset=\"utf-8\">" \ " <meta charset=\"utf-8\">" \
" <title>uts-server</title>" \ " <title>uts-server</title>" \
@ -45,7 +45,6 @@ const char *content_static_page =
" border-radius: 2px;" \ " border-radius: 2px;" \
" padding: 10px 24px;" \ " padding: 10px 24px;" \
" margin: 0 auto;" \ " margin: 0 auto;" \
" display: inline;" \
" box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, " \ " box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, " \
"0, 0.19);" \ "0, 0.19);" \
" margin: 0 auto;" \ " margin: 0 auto;" \
@ -115,3 +114,5 @@ const char *content_static_page =
"</div>" \ "</div>" \
"</body>" \ "</body>" \
"</html>"; "</html>";
int static_page_size = 0;

View file

@ -195,14 +195,16 @@ int rfc3161_handler(struct mg_connection *conn, void *context) {
free(content); free(content);
} else { } else {
// default reply if we don't have a time-stamp request // default reply if we don't have a time-stamp request
content_length = strlen(content_static_page); if (static_page_size == 0) {
static_page_size = strlen(content_static_page);
}
mg_printf(conn, mg_printf(conn,
"HTTP/1.1 200 OK\r\n" "HTTP/1.1 200 OK\r\n"
"Content-Type: text/html\r\n" "Content-Type: text/html\r\n"
"Content-Length: %d\r\n" "Content-Length: %d\r\n"
"\r\n", "\r\n",
(int)content_length); (int)static_page_size);
mg_write(conn, content_static_page, content_length); mg_write(conn, content_static_page, static_page_size);
} }
// initialize a serial_id if not created by create_response // initialize a serial_id if not created by create_response
if (serial_id == NULL) { if (serial_id == NULL) {