From 7ffb44237fdd655a7650805dd51f126b5bfd8b8a Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Thu, 4 Feb 2010 13:18:43 -0800 Subject: [PATCH] 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). --- tornado/web.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tornado/web.py b/tornado/web.py index c343cd0e..403c25cb 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())