Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
11319:a4b299e37909 | 11320:817cadf6be92 |
---|---|
107 local stanza, origin = event.stanza, event.origin; | 107 local stanza, origin = event.stanza, event.origin; |
108 | 108 |
109 local request = st.clone(stanza.tags[1], true); | 109 local request = st.clone(stanza.tags[1], true); |
110 local filename = request.attr.filename; | 110 local filename = request.attr.filename; |
111 local filesize = tonumber(request.attr.size); | 111 local filesize = tonumber(request.attr.size); |
112 local filetype = request.attr["content-type"]; | 112 local filetype = request.attr["content-type"] or "application/octet-stream"; |
113 local uploader = jid.bare(stanza.attr.from); | 113 local uploader = jid.bare(stanza.attr.from); |
114 | 114 |
115 local may, why_not = may_upload(uploader, filename, filesize, filetype); | 115 local may, why_not = may_upload(uploader, filename, filesize, filetype); |
116 if not may then | 116 if not may then |
117 origin.send(st.error_reply(stanza, why_not)); | 117 origin.send(st.error_reply(stanza, why_not)); |
214 if not handle then | 214 if not handle then |
215 return ferr or 410; | 215 return ferr or 410; |
216 end | 216 end |
217 response.headers.last_modified = last_modified; | 217 response.headers.last_modified = last_modified; |
218 response.headers.content_length = slot.attr.size; | 218 response.headers.content_length = slot.attr.size; |
219 response.headers.content_type = slot.attr["content-type"]; | 219 response.headers.content_type = slot.attr["content-type"] or "application/octet-stream"; |
220 response.headers.content_disposition = string.format("attachment; filename=%q", slot.attr.filename); | 220 response.headers.content_disposition = string.format("attachment; filename=%q", slot.attr.filename); |
221 | 221 |
222 response.headers.cache_control = "max-age=31556952, immutable"; | 222 response.headers.cache_control = "max-age=31556952, immutable"; |
223 response.headers.content_security_policy = "default-src 'none'; frame-ancestors 'none';" | 223 response.headers.content_security_policy = "default-src 'none'; frame-ancestors 'none';" |
224 | 224 |