Revision 39974c71
b/snf-django-lib/snf_django/lib/api/proxy/__init__.py | ||
---|---|---|
68 | 68 |
|
69 | 69 |
# set X-Forwarded-For, if already set, pass it through, otherwise set it |
70 | 70 |
# to the current request remote address |
71 |
SOURCE_IP = request.META.get('REMOTE_ADDR', None)
|
|
72 |
if SOURCE_IP and not 'X-Forwarded-For' in headers:
|
|
73 |
headers['X-Forwarded-For'] = SOURCE_IP
|
|
71 |
source_ip = request.META.get('REMOTE_ADDR', None)
|
|
72 |
if source_ip and not 'X-Forwarded-For' in headers:
|
|
73 |
headers['X-Forwarded-For'] = source_ip
|
|
74 | 74 |
|
75 | 75 |
# request.META remains cleanup |
76 | 76 |
for k in headers.keys(): |
... | ... | |
84 | 84 |
kwargs['body'] = request.raw_post_data |
85 | 85 |
|
86 | 86 |
path = request.path.lstrip('/') |
87 |
if path.startswith(proxy_base): |
|
87 |
if not path.startswith(proxy_base):
|
|
88 | 88 |
m = "request path '{0}' does not start with proxy_base '{1}'" |
89 | 89 |
m = m.format(path, proxy_base) |
90 |
raise AssertionError(m) |
|
90 | 91 |
path = path.replace(proxy_base, '', 1) |
91 | 92 |
path = join_urls(target_base, path) |
92 | 93 |
with PooledHTTPConnection(parsed.netloc, parsed.scheme) as conn: |
Also available in: Unified diff