mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-08 02:40:28 +00:00
Update redbean Fetch to close connection upon server request
This commit is contained in:
parent
745abb2ef5
commit
0a7b1718c2
1 changed files with 10 additions and 1 deletions
|
@ -227,7 +227,7 @@ static int LuaFetch(lua_State *L) {
|
|||
requestlen = appendz(request).i;
|
||||
_gc(request);
|
||||
|
||||
if (keepalive != kaKEEP && keepalive != kaCLOSE) {
|
||||
if (keepalive == kaNONE || keepalive == kaOPEN) {
|
||||
/*
|
||||
* Perform DNS lookup.
|
||||
*/
|
||||
|
@ -449,6 +449,15 @@ Finished:
|
|||
msg.status, urlarg, FetchHeaderLength(kHttpServer),
|
||||
FetchHeaderData(kHttpServer));
|
||||
|
||||
// check if the server has requested to close the connection
|
||||
// https://www.rfc-editor.org/rfc/rfc2616#section-14.10
|
||||
if (keepalive && keepalive != kaCLOSE
|
||||
&& FetchHasHeader(kHttpConnection)
|
||||
&& FetchHeaderEqualCase(kHttpConnection, "close")) {
|
||||
VERBOSEF("(ftch) close keepalive on server request");
|
||||
keepalive = kaCLOSE;
|
||||
}
|
||||
|
||||
// need to save updated sock for keepalive
|
||||
if (keepalive && keepalive != kaCLOSE && lua_istable(L, 2)) {
|
||||
lua_getfield(L, 2, "keepalive");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue