Hello great cherrypy community :)
In the past I ran into the problem that session handling and the
method serve_download() doesn't work well
together. The download of files bigger 100 MB results in an empty file
downloaded by the browser.
I got no error, neither in the cherrypy-log nor on the browser side.
Just this empty file saved on the harddisk.
This small test script should whow this behaviour: (note: you need a
big file to serve)
import os
import cherrypy
from cherrypy.lib.static import serve_download
THIS_DIR = os.path.abspath(os.path.dirname(__file__))
class HelloWorld(object):
_cp_config = {"tools.sessions.on": True}
#_cp_config = {} # uncomment this and download will work fine
def index(self):
try:
cherrypy.session["hello"] = "hello"
except:
pass
return serve_download(os.path.join(THIS_DIR, "bigfile.bin"))
index.exposed = True
cherrypy.config.update({'server.socket_host': '0.0.0.0',
'server.socket_port': 8080,
})
cherrypy.quickstart(HelloWorld())
Is this a known issue or a limitation we have to live with?
My workaround makes a HTTPRedirect to a download method which is not
part of an object with session handling activated. This seems to work
in general but some clients told me they still download files with a
size of zero bytes sometimes. After some retries the download will
work right but it seems to be some kind of unstable.
Do you have any experience with this unstable behaviours, too?
Best regards,
Zap