fix headers

This commit is contained in:
Karol Wypchlo 2022-04-22 15:19:07 +02:00
parent 5301384609
commit 39f9b4d196
No known key found for this signature in database
GPG Key ID: B515DE9EEBE241E1
1 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,5 @@
local _M = {}
local cjson = require("cjson")
local utils = require("utils")
function _M.track_download_timer(premature, skylink, status, auth_headers, body_bytes_sent)
@ -36,10 +35,18 @@ function _M.track_upload_timer(premature, skylink, auth_headers, uploader_ip)
local httpc = require("resty.http").new()
-- set correct content type header and include auth headers
local headers = {
["Content-Type"] = "application/x-www-form-urlencoded",
}
for key, value in ipairs(auth_headers) do
headers[key] = value
end
-- 10.10.10.70 points to accounts service (alias not available when using resty-http)
local res, err = httpc:request_uri("http://10.10.10.70:3000/track/upload/" .. skylink, {
method = "POST",
headers = auth_headers,
headers = headers,
body = "ip=" .. uploader_ip,
})