summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrofl0r <retnyg@gmx.net>2018-12-29 16:39:04 +0000
committerrofl0r <retnyg@gmx.net>2018-12-29 16:39:04 +0000
commit679b683331771d2ed196abf46ee7c2278f0f687f (patch)
tree298ed096a9942a6c713e8764554400b1a09f5709
parent7562c073291a4c542e2be82cc5aa332031ee4b29 (diff)
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.
-rw-r--r--src/conns.c2
-rw-r--r--src/conns.h9
-rw-r--r--src/reqs.c6
3 files changed, 13 insertions, 4 deletions
diff --git a/src/conns.c b/src/conns.c
index 94faeea..3859d69 100644
--- a/src/conns.c
+++ b/src/conns.c
@@ -68,7 +68,7 @@ struct conn_s *initialize_conn (int client_fd, const char *ipaddr,
connptr->error_string = NULL;
connptr->error_number = -1;
- connptr->connect_method = FALSE;
+ connptr->connect_method = CM_FALSE;
connptr->show_stats = FALSE;
connptr->protocol.major = connptr->protocol.minor = 0;
diff --git a/src/conns.h b/src/conns.h
index b63d026..322ead1 100644
--- a/src/conns.h
+++ b/src/conns.h
@@ -24,6 +24,12 @@
#include "main.h"
#include "hashmap.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 f356e02..9675980 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -438,7 +438,7 @@ BAD_REQUEST_ERROR:
goto fail;
}
- connptr->connect_method = TRUE;
+ connptr->connect_method = CM_TRUE;
} else {
#ifdef TRANSPARENT_PROXY
if (!do_transparent_proxy
@@ -1700,7 +1700,7 @@ void handle_connection (int fd)
connptr->server_fd);
if(hashmap_search(hashofheaders, "upgrade") > 0) {
- connptr->connect_method = TRUE;
+ connptr->connect_method = CM_UPGRADE;
safe_write (connptr->server_fd, lines, lines_len);
}
@@ -1718,6 +1718,8 @@ void handle_connection (int fd)
update_stats (STAT_BADCONN);
goto fail;
}
+ } else if (connptr->connect_method == CM_UPGRADE) {
+ /* NOP */ ;
} else {
if (send_ssl_response (connptr) < 0) {
log_message (LOG_ERR,