diff --git a/werkzeug/serving.py b/werkzeug/serving.py index 45a6aa8f5..219609e82 100644 --- a/werkzeug/serving.py +++ b/werkzeug/serving.py @@ -68,12 +68,16 @@ def _get_openssl_crypto_module(): from werkzeug.exceptions import InternalServerError -def _iter_headers(lineiter): +def _iter_headers(message): """Super crappy way to iterate over lines that might look like HTTP headers. This must only be used with preparsed HTTP messages. This would be nice if it was not necessary but unfortunately the rfc822 Message in the stdlib is not very good. """ + if PY2: + lineiter = message.headers + else: + lineiter = message._headers rv = [] for line in lineiter: if not line[:1].isspace(): @@ -123,7 +127,7 @@ def shutdown_server(): 'SERVER_PROTOCOL': self.request_version } - for key, value in _iter_headers(self.headers.headers): + for key, value in _iter_headers(self.headers): key = 'HTTP_' + key.upper().replace('-', '_') if key not in ('HTTP_CONTENT_TYPE', 'HTTP_CONTENT_LENGTH'): if key in environ: