summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_h1proto.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2018-09-20 15:05:38 +0300
committerIgor Sysoev <igor@sysoev.ru>2018-09-20 15:05:38 +0300
commitb5d76454ed41cdc38ac801ef143ca0ab516d741f (patch)
tree63f88996d9555e61d8539929056eb4caa2de3b0c /src/nxt_h1proto.c
parent96cd68b34037f8b6d9a1d43f67b8fe7c1df2ef9e (diff)
downloadunit-b5d76454ed41cdc38ac801ef143ca0ab516d741f.tar.gz
unit-b5d76454ed41cdc38ac801ef143ca0ab516d741f.tar.bz2
Added nginx error 497 response.
Diffstat (limited to '')
-rw-r--r--src/nxt_h1proto.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/nxt_h1proto.c b/src/nxt_h1proto.c
index 040e8b3f..3e5044b7 100644
--- a/src/nxt_h1proto.c
+++ b/src/nxt_h1proto.c
@@ -514,6 +514,14 @@ nxt_h1p_conn_request_header_parse(nxt_task_t *task, void *obj, void *data)
ret = nxt_h1p_header_process(h1p, r);
if (nxt_fast_path(ret == NXT_OK)) {
+
+#if (NXT_TLS)
+ if (c->u.tls == NULL && r->conf->socket_conf->tls != NULL) {
+ status = NXT_HTTP_TO_HTTPS;
+ goto error;
+ }
+#endif
+
r->state->ready_handler(task, r, NULL);
return;
}
@@ -870,6 +878,15 @@ static const nxt_str_t nxt_http_client_error[] = {
};
+#define NXT_HTTP_LAST_NGINX_ERROR \
+ (NXT_HTTP_TO_HTTPS + nxt_nitems(nxt_http_nginx_error) - 1)
+
+static const nxt_str_t nxt_http_nginx_error[] = {
+ nxt_string("HTTP/1.1 400 "
+ "The plain HTTP request was sent to HTTPS port\r\n"),
+};
+
+
#define NXT_HTTP_LAST_SERVER_ERROR \
(NXT_HTTP_INTERNAL_SERVER_ERROR + nxt_nitems(nxt_http_server_error) - 1)
@@ -926,6 +943,9 @@ nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r)
} else if (n >= NXT_HTTP_BAD_REQUEST && n <= NXT_HTTP_LAST_CLIENT_ERROR) {
status = &nxt_http_client_error[n - NXT_HTTP_BAD_REQUEST];
+ } else if (n >= NXT_HTTP_TO_HTTPS && n <= NXT_HTTP_LAST_NGINX_ERROR) {
+ status = &nxt_http_nginx_error[n - NXT_HTTP_TO_HTTPS];
+
} else if (n >= NXT_HTTP_INTERNAL_SERVER_ERROR
&& n <= NXT_HTTP_LAST_SERVER_ERROR)
{