From 54971620f099e6b5d5dae55f9050b9b0ea46825e Mon Sep 17 00:00:00 2001 From: tuxmain Date: Mon, 13 Jun 2022 15:51:14 +0200 Subject: [PATCH] Fix HTTP compression --- init.lua | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 1b26783..5f439e2 100644 --- a/init.lua +++ b/init.lua @@ -74,7 +74,10 @@ function MatrixChat:get_sync_table(timeout) if #params > 0 then u = u .. "?" .. table.concat(params, "&") end - local h = {"Authorization: Bearer " .. self.token} + local h = { + "Authorization: Bearer " .. self.token, + "Accept-Encoding: identity" + } return {url=u, method="GET", extra_headers=h} end @@ -105,7 +108,10 @@ end function MatrixChat:login() local u = self.server .."/_matrix/client/r0/login" local d = '{"type":"m.login.password","password":"'.. self.password ..'","identifier":{"type":"m.id.user","user":"'.. self.username ..'"}}' - local h = {"Content-Type: application/json"} + local h = { + "Content-Type: application/json", + "Accept-Encoding: identity" + } http.fetch({url=u, method="POST", extra_headers=h, post_data=d}, function(res) if res.code == 200 then @@ -134,7 +140,11 @@ function MatrixChat:send(msg) end local txid = os.time() local u = self.server .."/_matrix/client/r0/rooms/".. self.room .."/send/m.room.message/" .. txid -- ?access_token=..token - local h = {"Content-Type: application/json", "Authorization: Bearer " .. self.token} + local h = { + "Content-Type: application/json", + "Authorization: Bearer " .. self.token, + "Accept-Encoding: identity" + } local d = minetest.write_json({msgtype="m.text", body=msg}) local req if self.proxy then @@ -164,7 +174,10 @@ end -- POST /logout/all function MatrixChat:logout() local u = self.server .."/logout/all" - local h = {"Authorization: Bearer " .. self.token} + local h = { + "Authorization: Bearer " .. self.token, + "Accept-Encoding: identity" + } http.fetch({url=u, method="POST", extra_headers=h, function(res) end}) minetest.log("action", "matrix_bridge - signing out.") end