mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-23 20:11:49 +00:00
handle 'Connection: close'
This commit is contained in:
1 parent
793171e9e0
commit
9974be3fdc
2 files changed
+14
No files matched your search
@@ -3299,6 +3299,13 @@ 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) {
|
||||||
|
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"
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ofs > 0) mg_iobuf_del(&c->recv, 0, ofs); // Delete processed data
|
if (ofs > 0) mg_iobuf_del(&c->recv, 0, ofs); // Delete processed data
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1083,6 +1083,13 @@ 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) {
|
||||||
|
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"
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ofs > 0) mg_iobuf_del(&c->recv, 0, ofs); // Delete processed data
|
if (ofs > 0) mg_iobuf_del(&c->recv, 0, ofs); // Delete processed data
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user