Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added content length to xsendfile #447

Closed
wants to merge 1 commit into from

3 participants

Ib Lundgren Kenneth Reitz Armin Ronacher
Ib Lundgren

Attempting to download large files using send_file with X-Sendfile headers did not work with Python 2.7.2, Apache 2.2.20 on Ubuntu 11.10, only an empty file was downloaded. Setting the "Content-Length" header solved the issue. I can't see why it would hurt to always have it there since response content is discarded when using X-Sendfile anyway.

Armin Ronacher
Owner

I guess probably reasonable to do that. If it breaks something we can revert it.

Armin Ronacher mitsuhiko closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 18, 2012
  1. Ib Lundgren
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 0 deletions.
  1. +1 −0  flask/helpers.py
1  flask/helpers.py
View
@@ -428,6 +428,7 @@ def send_file(filename_or_fp, mimetype=None, as_attachment=False,
if file is not None:
file.close()
headers['X-Sendfile'] = filename
+ headers['Content-Length'] = os.path.getsize(filename)
data = None
else:
if file is None:
Something went wrong with that request. Please try again.