diff options
| author | Gael Pasgrimaud <gael@gawel.org> | 2011-07-12 01:00:34 +0200 |
|---|---|---|
| committer | Gael Pasgrimaud <gael@gawel.org> | 2011-07-12 01:00:34 +0200 |
| commit | c8890ef161cc9b3b57eeee5feca6c39c29156058 (patch) | |
| tree | 6aceb09e161fc7855392e06416fa8ac7b7b8c96b /webtest/debugapp.py | |
| parent | 6b54dd74153b1a61573b88b1640bf1fa78acdeb9 (diff) | |
| download | webtest-c8890ef161cc9b3b57eeee5feca6c39c29156058.tar.gz | |
only warn if a content-type is returned by 204/304 with no content-length
Diffstat (limited to 'webtest/debugapp.py')
| -rw-r--r-- | webtest/debugapp.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/webtest/debugapp.py b/webtest/debugapp.py index 9d141f3..a3c6552 100644 --- a/webtest/debugapp.py +++ b/webtest/debugapp.py @@ -11,23 +11,31 @@ def debug_app(environ, start_response): if 'error' in req.GET: raise Exception('Exception requested') status = str(req.GET.get('status', '200 OK')) + parts = [] for name, value in sorted(environ.items()): if name.upper() != name: value = repr(value) parts.append('%s: %s\n' % (name, value)) + req_body = req.body if req_body: parts.append('-- Body ----------\n') parts.append(req_body) body = ''.join(parts) + + if status[:3] in ('204', '304') and not req_body: + body = '' + headers = [ ('Content-Type', 'text/plain'), ('Content-Length', str(len(body)))] + for name, value in req.GET.items(): if name.startswith('header-'): header_name = name[len('header-'):] headers.append((header_name, value)) + start_response(status, headers) if req.method == 'HEAD': return [''] |
