Software /
code /
prosody
Diff
plugins/mod_http_file_share.lua @ 11320:817cadf6be92
mod_http_file_share: Handle content-type being optional
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 27 Jan 2021 09:47:21 +0100 |
parent | 11319:a4b299e37909 |
child | 11321:15ab878a7d23 |
line wrap: on
line diff
--- a/plugins/mod_http_file_share.lua Wed Jan 27 00:36:49 2021 +0100 +++ b/plugins/mod_http_file_share.lua Wed Jan 27 09:47:21 2021 +0100 @@ -109,7 +109,7 @@ local request = st.clone(stanza.tags[1], true); local filename = request.attr.filename; local filesize = tonumber(request.attr.size); - local filetype = request.attr["content-type"]; + local filetype = request.attr["content-type"] or "application/octet-stream"; local uploader = jid.bare(stanza.attr.from); local may, why_not = may_upload(uploader, filename, filesize, filetype); @@ -216,7 +216,7 @@ end response.headers.last_modified = last_modified; response.headers.content_length = slot.attr.size; - response.headers.content_type = slot.attr["content-type"]; + response.headers.content_type = slot.attr["content-type"] or "application/octet-stream"; response.headers.content_disposition = string.format("attachment; filename=%q", slot.attr.filename); response.headers.cache_control = "max-age=31556952, immutable";