# HG changeset patch # User paulb # Date 1082838837 0 # Node ID 7fbe8eca11c33ee0986e224441a67ffb97fe4af2 # Parent 2e48b46491c72550c20ef2996722cec5dc2159af [project @ 2004-04-24 20:33:57 by paulb] Added a new helper module for CGI-style headers retrieval. diff -r 2e48b46491c7 -r 7fbe8eca11c3 WebStack/Helpers/Environment.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebStack/Helpers/Environment.py Sat Apr 24 20:33:57 2004 +0000 @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +""" +Environment helper functions. +""" + +def get_headers(env): + + """ + Get the headers from the given environment 'env', which should be a + dictionary-like object. + + Returns a dictionary-like object containing likely headers. + """ + + headers = {} + for cgi_key, value in env.items(): + if cgi_key.startswith("HTTP_"): + header_name = cgi_key[len("HTTP_"):].replace("_", "-").lower() + headers[header_name] = value + + return headers + +# vim: tabstop=4 expandtab shiftwidth=4