Fix bad authentication handling in opds browser (#6942)

Fixes #6941.
reviewable/pr6881/r1
Galunid 4 years ago committed by GitHub
parent 77314e48c4
commit 059ffc0040
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

Loading…
Cancel
Save