Commit d3ef404a authored by 's avatar

Fixes to Request.get_header

parent 81ecb603
......@@ -82,7 +82,7 @@
# file.
#
##############################################################################
__version__='$Revision: 1.3 $'[11:-2]
__version__='$Revision: 1.4 $'[11:-2]
import regex
from string import atoi, atol, join, upper, split, strip, rfind
......@@ -280,7 +280,18 @@ class Request:
return self.get(key, Request) is not Request
def get_header(self, name, default=None):
# Return the named HTTP header, or an optional default
# argument or None if the header is not found.
"""Return the named HTTP header, or an optional default
argument or None if the header is not found. Note that
both original and CGI-ified header names are recognized,
e.g. 'Content-Type', 'CONTENT_TYPE' and 'HTTP_CONTENT_TYPE'
should all return the Content-Type header, if available.
"""
environ=self.environ
name=upper(join(split(name,"-"),"_"))
return self.environ.get(name, default)
val=environ.get(name, None)
if val is not None:
return val
if name[:5] != 'HTTP_':
name='HTTP_%s' % name
return environ.get(name, default)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment