Welcome! Log In Create A New Profile

Advanced

[PATCH 1 of 4] HTTP/2: reject HTTP/2 requests with "Connection" header

Piotr Sikora via nginx-devel
June 13, 2017 08:22AM
# HG changeset patch
# User Piotr Sikora <piotrsikora@google.com>
# Date 1490516709 25200
# Sun Mar 26 01:25:09 2017 -0700
# Node ID 10c3f4c37f96ef496eff859b6f6815817e79455a
# Parent e6f399a176e7cae0fa08f1183d31315bce3b9ecb
HTTP/2: reject HTTP/2 requests with "Connection" header.

While there, populate r->headers_in.connection.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>

diff -r e6f399a176e7 -r 10c3f4c37f96 src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1678,6 +1678,22 @@ static ngx_int_t
ngx_http_process_connection(ngx_http_request_t *r, ngx_table_elt_t *h,
ngx_uint_t offset)
{
+ if (r->headers_in.connection == NULL) {
+ r->headers_in.connection = h;
+ }
+
+#if (NGX_HTTP_V2)
+
+ if (r->stream) {
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+ "client sent HTTP/2 request with \"Connection\" header");
+
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ return NGX_ERROR;
+ }
+
+#endif
+
if (ngx_strcasestrn(h->value.data, "close", 5 - 1)) {
r->headers_in.connection_type = NGX_HTTP_CONNECTION_CLOSE;

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 1 of 4] HTTP/2: reject HTTP/2 requests with "Connection" header

Piotr Sikora via nginx-devel 344 June 13, 2017 08:22AM

[PATCH 2 of 4] HTTP/2: reject HTTP/2 requests with invalid "TE" header value

Piotr Sikora via nginx-devel 168 June 13, 2017 08:22AM

[PATCH 3 of 4] HTTP/2: reject HTTP/2 requests with "Transfer-Encoding" header

Piotr Sikora via nginx-devel 156 June 13, 2017 08:22AM

[PATCH 4 of 4] HTTP/2: reject HTTP/2 requests with connection-specific headers

Piotr Sikora via nginx-devel 172 June 13, 2017 08:22AM

Re: [PATCH 4 of 4] HTTP/2: reject HTTP/2 requests with connection-specific headers

Maxim Dounin 172 June 14, 2017 03:02PM

Re: [PATCH 4 of 4] HTTP/2: reject HTTP/2 requests with connection-specific headers

Piotr Sikora via nginx-devel 139 June 17, 2017 04:58PM

Re: [PATCH 4 of 4] HTTP/2: reject HTTP/2 requests with connection-specific headers

Maxim Dounin 171 June 19, 2017 09:48AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 175
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready