diff options
| author | Claude Paroz <claude@2xlibre.net> | 2016-06-18 10:51:38 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2016-06-27 10:44:57 +0200 |
| commit | 9588718cd404d73b2be09241b424b539d8d8c66e (patch) | |
| tree | 3ad0f2054fb540fd92ce9ae0125ed70e19eee2e8 /django/middleware/common.py | |
| parent | ca77b509059831b055a3b735ff77e042f8e1c0eb (diff) | |
Fixed #5897 -- Added the Content-Length response header in CommonMiddleware
Thanks Tim Graham for the review.
Diffstat (limited to 'django/middleware/common.py')
| -rw-r--r-- | django/middleware/common.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/django/middleware/common.py b/django/middleware/common.py index 8cb00ff250..b705f72b81 100644 --- a/django/middleware/common.py +++ b/django/middleware/common.py @@ -123,6 +123,10 @@ class CommonMiddleware(MiddlewareMixin): etag=unquote_etag(response['ETag']), response=response, ) + # Add the Content-Length header to non-streaming responses if not + # already set. + if not response.streaming and not response.has_header('Content-Length'): + response['Content-Length'] = str(len(response.content)) return response |
