Revision 0f66865f snf-django-lib/snf_django/lib/api/proxy/utils.py

b/snf-django-lib/snf_django/lib/api/proxy/utils.py
31 31
# interpreted as representing official policies, either expressed
32 32
# or implied, of GRNET S.A.
33 33

  
34
from django.core.servers.basehttp import is_hop_by_hop
34
try:
35
    from django.core.servers.basehttp import is_hop_by_hop
36
except ImportError:
37
    # Removed in Django 1.4
38
    _hop_headers = {
39
        'connection': 1, 'keep-alive': 1, 'proxy-authenticate': 1,
40
        'proxy-authorization': 1, 'te': 1, 'trailers': 1,
41
        'transfer-encoding': 1, 'upgrade': 1
42
    }
43

  
44
    def is_hop_by_hop(header_name):
45
        """Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header"""
46
        return header_name.lower() in _hop_headers
35 47

  
36 48

  
37 49
def fix_header(k, v):
......
43 55

  
44 56
def forward_header(k):
45 57
    return k.upper() not in ['HOST', 'CONTENT_LENGTH', 'CONTENT_TYPE'] and \
46
           not is_hop_by_hop(k) and not '.' in k
58
        not is_hop_by_hop(k) and not '.' in k

Also available in: Unified diff