diff options
author | Kim Alvefur <zash@zash.se> | 2023-11-11 23:48:45 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2023-11-11 23:48:45 +0100 |
commit | 019549e7381ef1524bbb6550eb0140661ae3d4a5 (patch) | |
tree | 3173a201a2357cd79e39bc5c1dea7b4f7d7e9d0b | |
parent | 8e2ecac95b17cabc13a61a3d91ed99f350412f75 (diff) | |
download | prosody-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
-rw-r--r-- | net/http.lua | 9 |
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 |