Skip to content

Commit 48e5793

Browse files
author
Vasyl Vavrychuk
committed
Fixed mongoose lying to client about keep alive
If ENABLE_KEEP_ALIVE option set to no and client requests 'Connection: keep-alive' then mongoose respond with 'Connection: keep-alive' but after that actually closes the connection. It is happening because of difference beatween suggest_connection_header and process_new_connection functions.
1 parent 3f87ac1 commit 48e5793

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/third_party/mongoose/mongoose.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ static int should_keep_alive(const struct mg_connection *conn) {
791791
}
792792

793793
static const char *suggest_connection_header(const struct mg_connection *conn) {
794-
return should_keep_alive(conn) ? "keep-alive" : "close";
794+
int keep_alive_enabled = !strcmp(conn->ctx->config[ENABLE_KEEP_ALIVE], "yes");
795+
return keep_alive_enabled && should_keep_alive(conn) ? "keep-alive" : "close";
795796
}
796797

797798
static void send_http_error(struct mg_connection *conn, int status,

0 commit comments

Comments
 (0)