1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/WebStack/Helpers/Environment.py Sat Apr 24 20:33:57 2004 +0000
1.3 @@ -0,0 +1,24 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"""
1.7 +Environment helper functions.
1.8 +"""
1.9 +
1.10 +def get_headers(env):
1.11 +
1.12 + """
1.13 + Get the headers from the given environment 'env', which should be a
1.14 + dictionary-like object.
1.15 +
1.16 + Returns a dictionary-like object containing likely headers.
1.17 + """
1.18 +
1.19 + headers = {}
1.20 + for cgi_key, value in env.items():
1.21 + if cgi_key.startswith("HTTP_"):
1.22 + header_name = cgi_key[len("HTTP_"):].replace("_", "-").lower()
1.23 + headers[header_name] = value
1.24 +
1.25 + return headers
1.26 +
1.27 +# vim: tabstop=4 expandtab shiftwidth=4