From d37c300d872b378ceda7c7c52564580bb469fd16 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Thu, 10 Oct 2024 19:44:09 -0300 Subject: [PATCH] Honor c->is_resp with Connection:close --- mongoose.c | 2 +- src/http.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index 3f6ef069..284f6662 100644 --- a/mongoose.c +++ b/mongoose.c @@ -3310,7 +3310,7 @@ static void http_cb(struct mg_connection *c, int ev, void *ev_data) { if (c->is_accepted) c->is_resp = 1; // Start generating response mg_call(c, MG_EV_HTTP_MSG, &hm); // User handler can clear is_resp - if (c->is_accepted) { + if (c->is_accepted && !c->is_resp) { struct mg_str *cc = mg_http_get_header(&hm, "Connection"); if (cc != NULL && mg_strcasecmp(*cc, mg_str("close")) == 0) { c->is_draining = 1; // honor "Connection: close" diff --git a/src/http.c b/src/http.c index 680e4a02..68ec32ad 100644 --- a/src/http.c +++ b/src/http.c @@ -1094,7 +1094,7 @@ static void http_cb(struct mg_connection *c, int ev, void *ev_data) { if (c->is_accepted) c->is_resp = 1; // Start generating response mg_call(c, MG_EV_HTTP_MSG, &hm); // User handler can clear is_resp - if (c->is_accepted) { + if (c->is_accepted && !c->is_resp) { struct mg_str *cc = mg_http_get_header(&hm, "Connection"); if (cc != NULL && mg_strcasecmp(*cc, mg_str("close")) == 0) { c->is_draining = 1; // honor "Connection: close"