Fix bad authentication handling in opds browser (#6942)

Fixes #6941.
This commit is contained in:
Galunid
2020-12-03 15:38:31 +01:00
committed by GitHub
parent 77314e48c4
commit 059ffc0040

View File

@@ -568,12 +568,11 @@ function OPDSBrowser:downloadFile(item, format, remote_url)
password = item.password
}
elseif parsed.scheme == "https" then
local auth = string.format("%s:%s", item.username, item.password)
local auth = (item.username and item.password) and string.format("%s:%s", item.username, item.password) or nil
local hostname = parsed.host
dummy, c = http.request {
url = remote_url,
headers = { Authorization = "Basic " .. mime.b64(auth), ["Host"] = hostname },
headers = auth and { Authorization = "Basic " .. mime.b64(auth), ["Host"] = hostname } or nil,
sink = ltn12.sink.file(io.open(local_path, "w")),
}
else