From: Ben Darnell Date: Thu, 4 Feb 2010 21:18:43 +0000 (-0800) Subject: Don't set content-length in StaticFileHandler unless we're actually X-Git-Tag: v1.0.0~76^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ffb44237fdd655a7650805dd51f126b5bfd8b8a;p=thirdparty%2Ftornado.git Don't set content-length in StaticFileHandler unless we're actually sending the content. Some browsers get confused by this (e.g. the version of webkit embedded in fluid, but not the version used in chrome). --- diff --git a/tornado/web.py b/tornado/web.py index c343cd0e3..403c25cb8 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -1110,7 +1110,6 @@ class StaticFileHandler(RequestHandler): modified = datetime.datetime.fromtimestamp(stat_result[stat.ST_MTIME]) self.set_header("Last-Modified", modified) - self.set_header("Content-Length", stat_result[stat.ST_SIZE]) if "v" in self.request.arguments: self.set_header("Expires", datetime.datetime.utcnow() + \ datetime.timedelta(days=365*10)) @@ -1133,6 +1132,7 @@ class StaticFileHandler(RequestHandler): if not include_body: return + self.set_header("Content-Length", stat_result[stat.ST_SIZE]) file = open(abspath, "r") try: self.write(file.read())