summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_http_error.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2019-10-02 20:04:52 +0300
committerValentin Bartenev <vbart@nginx.com>2019-10-02 20:04:52 +0300
commit73f096f79614403b93f23e7397f312eea49b0938 (patch)
treee7a3240e50a39509b433b6ff30e9627542fec5e7 /src/nxt_http_error.c
parent9b4e45cafcc8f1f74bcfce3071866ee5eab176a5 (diff)
downloadunit-73f096f79614403b93f23e7397f312eea49b0938.tar.gz
unit-73f096f79614403b93f23e7397f312eea49b0938.tar.bz2
Added response status code to error page body.
Also the error page markup is now valid according to HTML5 specification. All optional tags were omitted.
Diffstat (limited to 'src/nxt_http_error.c')
-rw-r--r--src/nxt_http_error.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/nxt_http_error.c b/src/nxt_http_error.c
index 1dcd8783..8e8b80f1 100644
--- a/src/nxt_http_error.c
+++ b/src/nxt_http_error.c
@@ -16,8 +16,12 @@ static const nxt_http_request_state_t nxt_http_request_send_error_body_state;
static const char error[] =
- "<html><head><title>Error</title></head>"
- "<body>Error.</body></html>\r\n";
+ "<!DOCTYPE html>"
+ "<title>Error %03d</title>"
+ "<p>Error %03d.\r\n";
+
+/* Two %03d (4 chars) patterns are replaced by status code (3 chars). */
+#define NXT_HTTP_ERROR_LEN (nxt_length(error) - 2)
void
@@ -49,7 +53,7 @@ nxt_http_request_error(nxt_task_t *task, nxt_http_request_t *r,
nxt_http_field_set(content_type, "Content-Type", "text/html");
r->resp.content_length = NULL;
- r->resp.content_length_n = nxt_length(error);
+ r->resp.content_length_n = NXT_HTTP_ERROR_LEN;
r->state = &nxt_http_request_send_error_body_state;
@@ -80,15 +84,13 @@ nxt_http_request_send_error_body(nxt_task_t *task, void *obj, void *data)
nxt_debug(task, "http request send error body");
- out = nxt_http_buf_mem(task, r, 0);
+ out = nxt_http_buf_mem(task, r, NXT_HTTP_ERROR_LEN);
if (nxt_slow_path(out == NULL)) {
goto fail;
}
- out->mem.start = (u_char *) error;
- out->mem.pos = out->mem.start;
- out->mem.free = out->mem.start + nxt_length(error);
- out->mem.end = out->mem.free;
+ out->mem.free = nxt_sprintf(out->mem.pos, out->mem.end, error,
+ r->status, r->status);
out->next = nxt_http_buf_last(r);