diff options
author | Marc Abramowitz <marc@marc-abramowitz.com> | 2015-04-28 10:01:48 -0700 |
---|---|---|
committer | Marc Abramowitz <marc@marc-abramowitz.com> | 2015-04-28 10:01:48 -0700 |
commit | e123234948e8fac18f21d69da3b3b7f49969106c (patch) | |
tree | 3d02ca105f3933740281c0dd93f24bc5035abf05 /paste | |
parent | d8dbfc52a9f63178a7e31154971fd325a9b553da (diff) | |
download | paste-git-e123234948e8fac18f21d69da3b3b7f49969106c.tar.gz |
Make get all values of a header work on both Python 2 and 3
Diffstat (limited to 'paste')
-rwxr-xr-x | paste/httpserver.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/paste/httpserver.py b/paste/httpserver.py index c53fe01..6172251 100755 --- a/paste/httpserver.py +++ b/paste/httpserver.py @@ -42,6 +42,14 @@ except ImportError: __all__ = ['WSGIHandlerMixin', 'WSGIServer', 'WSGIHandler', 'serve'] __version__ = "0.5" + +def get_headers(headers, k): + if hasattr(headers, 'getheaders'): # Python 2 + return headers.getheaders(k) + if hasattr(headers, 'get_all'): # Python 3 + return headers.get_all(k) + + class ContinueHook(object): """ When a client request includes a 'Expect: 100-continue' header, then @@ -256,7 +264,7 @@ class WSGIHandlerMixin: key = 'HTTP_' + k.replace("-","_").upper() if key in ('HTTP_CONTENT_TYPE','HTTP_CONTENT_LENGTH'): continue - self.wsgi_environ[key] = ','.join(self.headers.getheaders(k)) + self.wsgi_environ[key] = ','.join(get_headers(self.headers, k)) if hasattr(self.connection,'get_context'): self.wsgi_environ['wsgi.url_scheme'] = 'https' |