diff options
Diffstat (limited to 'main/utils.py')
-rw-r--r-- | main/utils.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/main/utils.py b/main/utils.py index 0b6849a4..d12e5e1a 100644 --- a/main/utils.py +++ b/main/utils.py @@ -53,6 +53,16 @@ def clear_cache_function(func, args, kwargs): key = cache_function_key(func, args, kwargs) cache.delete(key) + +def format_http_headers(request): + headers = sorted((k, v) for k, v in request.META.items() + if k.startswith('HTTP_')) + data = [] + for k, v in headers: + data.extend([k[5:].replace('_', '-').title(), ': ', v, '\n']) + return ''.join(data) + + # utility to make a pair of django choices make_choice = lambda l: [(str(m), str(m)) for m in l] |