aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-11-11 23:48:45 +0100
committerKim Alvefur <zash@zash.se>2023-11-11 23:48:45 +0100
commit019549e7381ef1524bbb6550eb0140661ae3d4a5 (patch)
tree3173a201a2357cd79e39bc5c1dea7b4f7d7e9d0b /net
parent8e2ecac95b17cabc13a61a3d91ed99f350412f75 (diff)
downloadprosody-019549e7381ef1524bbb6550eb0140661ae3d4a5.tar.gz
prosody-019549e7381ef1524bbb6550eb0140661ae3d4a5.zip
net.http: Set Connection header based on connection pool usage
Connection: keep-alive is implicit in HTTP/1.1 but explicit > implicit
Diffstat (limited to 'net')
-rw-r--r--net/http.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/net/http.lua b/net/http.lua
index 2685b491..bea1e905 100644
--- a/net/http.lua
+++ b/net/http.lua
@@ -115,7 +115,8 @@ local function request_reader(request, data, err)
request.callback(r.body, r.code, r, request);
request.callback = nil;
end
- destroy_request(request);
+ local persistent = (","..(r.headers.connection or "keep-alive")..","):find(",keep-alive,")
+ destroy_request(request, persistent);
end
local function options_cb()
return request;
@@ -269,6 +270,12 @@ local function request(self, u, ex, callback)
["User-Agent"] = "Prosody XMPP Server";
};
+ if self.pool then
+ headers["Connection"] = "keep-alive";
+ else
+ headers["Connection"] = "close";
+ end
+
if req.userinfo then
headers["Authorization"] = "Basic "..b64(req.userinfo);
end