1.1 --- a/MoinSupport.py Sun Jul 15 19:55:33 2012 +0200
1.2 +++ b/MoinSupport.py Tue Jul 17 00:01:30 2012 +0200
1.3 @@ -225,12 +225,21 @@
1.4 return request.path
1.5
1.6 def getHeader(request, header_name, prefix=None):
1.7 +
1.8 + """
1.9 + Using the 'request', return the value of the header with the given
1.10 + 'header_name', using the optional 'prefix' to obtain protocol-specific
1.11 + headers if necessary.
1.12 +
1.13 + If no value is found for the given 'header_name', None is returned.
1.14 + """
1.15 +
1.16 if hasattr(request, "getHeader"):
1.17 return request.getHeader(header_name)
1.18 elif hasattr(request, "headers"):
1.19 - return request.headers[header_name]
1.20 + return request.headers.get(header_name)
1.21 else:
1.22 - return request.env[(prefix and prefix + "_" or "") + header_name.upper()]
1.23 + return request.env.get((prefix and prefix + "_" or "") + header_name.upper())
1.24
1.25 # Content/media type and preferences support.
1.26