From 991e47d8ebd4b12710828b2b486535e4c25ba26c Mon Sep 17 00:00:00 2001 From: rofl0r Date: Sat, 29 Dec 2018 16:39:04 +0000 Subject: [PATCH] connection upgrade: do not emit 200 header when establishing conn a tri-state connect_method enum was introduced for this purpose. if connect_method is set to CM_UPGRADE, the "HTTP/1.0 200 Connection established" response won't be emitted. --- src/conns.h | 9 ++++++++- src/reqs.c | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/conns.h b/src/conns.h index 9618efb..2f33b36 100644 --- a/src/conns.h +++ b/src/conns.h @@ -24,6 +24,12 @@ #include "main.h" #include "hsearch.h" +enum connect_method_e { + CM_FALSE = 0, + CM_TRUE = 1, + CM_UPGRADE = 2, +}; + /* * Connection Definition */ @@ -37,8 +43,9 @@ struct conn_s { /* The request line (first line) from the client */ char *request_line; + enum connect_method_e connect_method; + /* Booleans */ - unsigned int connect_method; unsigned int show_stats; /* diff --git a/src/reqs.c b/src/reqs.c index dfa56b1..911fb34 100644 --- a/src/reqs.c +++ b/src/reqs.c @@ -454,7 +454,7 @@ BAD_REQUEST_ERROR: goto fail; } - connptr->connect_method = TRUE; + connptr->connect_method = CM_TRUE; } else { #ifdef TRANSPARENT_PROXY if (!do_transparent_proxy @@ -1756,7 +1756,7 @@ e401: connptr->server_fd); if(orderedmap_find (hashofheaders, "upgrade")) { - connptr->connect_method = TRUE; + connptr->connect_method = CM_UPGRADE; safe_write (connptr->server_fd, lines, lines_len); } @@ -1786,6 +1786,8 @@ e401: HC_FAIL(); } + } else if (connptr->connect_method == CM_UPGRADE) { + /* NOP */ ; } else { if (send_ssl_response (connptr) < 0) { log_message (LOG_ERR,