Parcourir la source

Send correct HTTP error code when serving an error page. Currently, this is broken and even 404 errors are served with HTTP 200 OK while they clearly shouldn't.

Signed-off-by: DL6ER <dl6er@dl6er.de>
DL6ER il y a 10 mois
Parent
commit
b1251ad6cc
1 fichiers modifiés avec 4 ajouts et 1 suppressions
  1. 4 1
      src/mod_lua.inl

+ 4 - 1
src/mod_lua.inl

@@ -641,7 +641,10 @@ run_lsp_kepler(struct mg_connection *conn,
 		/* Only send a HTML header, if this is the top level page.
 		/* Only send a HTML header, if this is the top level page.
 		 * If this page is included by some mg.include calls, do not add a
 		 * If this page is included by some mg.include calls, do not add a
 		 * header. */
 		 * header. */
-		mg_printf(conn, "HTTP/1.1 200 OK\r\n");
+		if(conn->status_code < 0)
+			mg_printf(conn, "HTTP/1.1 200 OK\r\n");
+		else
+			mg_printf(conn, "HTTP/1.1 %d %s\r\n", conn->status_code, mg_get_response_code_text(conn, conn->status_code));
 		send_no_cache_header(conn);
 		send_no_cache_header(conn);
 		send_additional_header(conn);
 		send_additional_header(conn);
 		mg_printf(conn,
 		mg_printf(conn,