Merge pull request #22 from chaotix-/mime-content-disposition

Just send Content-disposition: attachment-Header if content is no image
This commit is contained in:
Daniel Gultsch 2015-07-27 13:16:54 +02:00
commit 2f0fec6c7f

View File

@ -8,16 +8,12 @@ import mimetypes
import os
import random
import shutil
import signal
import sleekxmpp
import ssl
import string
import sys
import yaml
from sleekxmpp.componentxmpp import ComponentXMPP
from threading import Lock
from threading import Thread
try:
# Python 3
@ -150,6 +146,7 @@ class HttpHandler(BaseHTTPRequestHandler):
if mime is None:
mime = 'application/octet-stream'
self.send_header("Content-Type", mime)
if mime[:6] != 'image/':
self.send_header("Content-Disposition", 'attachment; filename="{}"'.format(os.path.basename(filename)))
fs = os.fstat(f.fileno())
self.send_header("Content-Length", str(fs.st_size))