Returning a zip with an empty folder as Flask response never ends
Closed this issue · 1 comments
evil-shrike commented
Returning a zip with an empty folder as Flask response hangs indefinitely.
here's a demo:
import zipstream
from flask import Response
@app.route("/api/download", methods=["GET"])
def download():
zs = zipstream.ZipStream(compress_type=zipstream.ZIP_STORED, sized=True)
zs.add_path('folder_with_data')
zs.add_path('empty_folder')
return Response(
zs,
mimetype="application/zip",
headers={
"Content-Disposition": f"attachment; filename={zip_filename}",
"Content-Length": len(zs),
"Last-Modified": zs.last_modified,
})
without the empty dir, everything works as expected, client get data (as an attachment). With the empty dir the server responds with correct headers but no actual data sent.
The issue happens only when we stream to response, if creating a zip locally, then it works.
pR0Ps commented
Thanks for the detailed report! I've released a fix for it in v1.3.3