summaryrefslogtreecommitdiff
path: root/paste
diff options
context:
space:
mode:
authorMarc Abramowitz <marc@marc-abramowitz.com>2015-04-28 10:01:48 -0700
committerMarc Abramowitz <marc@marc-abramowitz.com>2015-04-28 10:01:48 -0700
commit1976ddda0db68e75bd4cf1bdd3f3eb0b3b99eee7 (patch)
tree3d02ca105f3933740281c0dd93f24bc5035abf05 /paste
parenta3cba0d0ae06ef33c002d1d424564c16aef8ab61 (diff)
downloadpaste-1976ddda0db68e75bd4cf1bdd3f3eb0b3b99eee7.tar.gz
Make get all values of a header work on both Python 2 and 3
Diffstat (limited to 'paste')
-rwxr-xr-xpaste/httpserver.py10
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'