diff options
| author | Jannis Leidel <jannis@leidel.info> | 2011-03-02 10:40:48 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2011-03-02 10:40:48 +0000 |
| commit | 6b95aa6fb549b3834b7feefc6fbe92f8a50da411 (patch) | |
| tree | 3eb61bf9218f53eeb963f89ad10e3e1233a36d2c /django/core | |
| parent | ec193224d3580fbcfa78da96a6a7fc4343929dd8 (diff) | |
Fixed #15531 -- Partially reverted [15701] due to compatibility issues with middlewares that modify content of responses. Thanks for the report, schinckel. Refs #15281.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15703 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core')
| -rw-r--r-- | django/core/servers/basehttp.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py index 9e23688307..4e179dc7c0 100644 --- a/django/core/servers/basehttp.py +++ b/django/core/servers/basehttp.py @@ -19,7 +19,6 @@ from django.core.management.color import color_style from django.utils.http import http_date from django.utils._os import safe_join from django.views import static -from django.views.static import FileWrapper # for backwards compatibility, #15281 from django.contrib.staticfiles import handlers @@ -33,6 +32,30 @@ software_version = server_version + ' ' + sys_version class WSGIServerException(Exception): pass +class FileWrapper(object): + """Wrapper to convert file-like objects to iterables""" + + def __init__(self, filelike, blksize=8192): + self.filelike = filelike + self.blksize = blksize + if hasattr(filelike,'close'): + self.close = filelike.close + + def __getitem__(self,key): + data = self.filelike.read(self.blksize) + if data: + return data + raise IndexError + + def __iter__(self): + return self + + def next(self): + data = self.filelike.read(self.blksize) + if data: + return data + raise StopIteration + # Regular expression that matches `special' characters in parameters, the # existence of which force quoting of the parameter value. tspecials = re.compile(r'[ \(\)<>@,;:\\"/\[\]\?=]') |
