Merge pull request #2938 from cesanta/isresp

Honor c->is_resp with Connection:close
This commit is contained in:
Sergio R. Caprile 2024-10-10 19:47:59 -03:00 committed by GitHub
commit 3c10b36651
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -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 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 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"); struct mg_str *cc = mg_http_get_header(&hm, "Connection");
if (cc != NULL && mg_strcasecmp(*cc, mg_str("close")) == 0) { if (cc != NULL && mg_strcasecmp(*cc, mg_str("close")) == 0) {
c->is_draining = 1; // honor "Connection: close" c->is_draining = 1; // honor "Connection: close"

View File

@ -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 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 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"); struct mg_str *cc = mg_http_get_header(&hm, "Connection");
if (cc != NULL && mg_strcasecmp(*cc, mg_str("close")) == 0) { if (cc != NULL && mg_strcasecmp(*cc, mg_str("close")) == 0) {
c->is_draining = 1; // honor "Connection: close" c->is_draining = 1; // honor "Connection: close"