Current Path: > > opt > cloudlinux > venv > lib64 > python3.11 > site-packages > raven > utils
Operation : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 Software : Apache Server IP : 162.0.232.56 | Your IP: 216.73.216.111 Domains : 1034 Domain(s) Permission : [ 0755 ]
Name | Type | Size | Last Modified | Actions |
---|---|---|---|---|
__pycache__ | Directory | - | - | |
serializer | Directory | - | - | |
__init__.py | File | 3218 bytes | April 17 2025 13:10:58. | |
basic.py | File | 2443 bytes | April 17 2025 13:10:58. | |
compat.py | File | 5676 bytes | April 17 2025 13:10:58. | |
conf.py | File | 2343 bytes | April 17 2025 13:10:58. | |
encoding.py | File | 3303 bytes | April 17 2025 13:10:58. | |
http.py | File | 2000 bytes | April 17 2025 13:10:58. | |
imports.py | File | 404 bytes | April 17 2025 13:10:58. | |
json.py | File | 2977 bytes | April 17 2025 13:10:58. | |
ssl_match_hostname.py | File | 3598 bytes | April 17 2025 13:10:58. | |
stacks.py | File | 10036 bytes | April 17 2025 13:10:58. | |
testutils.py | File | 697 bytes | April 17 2025 13:10:58. | |
transaction.py | File | 1088 bytes | April 17 2025 13:10:58. | |
urlparse.py | File | 476 bytes | April 17 2025 13:10:58. | |
wsgi.py | File | 3731 bytes | April 17 2025 13:10:58. |
""" This module implements WSGI related helpers adapted from ``werkzeug.wsgi`` :copyright: (c) 2010 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ from __future__ import absolute_import from raven.utils.compat import iteritems, urllib_quote # `get_headers` comes from `werkzeug.datastructures.EnvironHeaders` def get_headers(environ): """ Returns only proper HTTP headers. """ for key, value in iteritems(environ): key = str(key) if key.startswith('HTTP_') and key not in \ ('HTTP_CONTENT_TYPE', 'HTTP_CONTENT_LENGTH'): yield key[5:].replace('_', '-').title(), value elif key in ('CONTENT_TYPE', 'CONTENT_LENGTH'): yield key.replace('_', '-').title(), value def get_environ(environ): """ Returns our whitelisted environment variables. """ for key in ('REMOTE_ADDR', 'SERVER_NAME', 'SERVER_PORT'): if key in environ: yield key, environ[key] # `get_host` comes from `werkzeug.wsgi` def get_host(environ): """Return the real host for the given WSGI environment. This takes care of the `X-Forwarded-Host` header. :param environ: the WSGI environment to get the host of. """ scheme = environ.get('wsgi.url_scheme') if 'HTTP_X_FORWARDED_HOST' in environ: result = environ['HTTP_X_FORWARDED_HOST'] elif 'HTTP_HOST' in environ: result = environ['HTTP_HOST'] else: result = environ['SERVER_NAME'] if (scheme, str(environ['SERVER_PORT'])) not \ in (('https', '443'), ('http', '80')): result += ':' + environ['SERVER_PORT'] if result.endswith(':80') and scheme == 'http': result = result[:-3] elif result.endswith(':443') and scheme == 'https': result = result[:-4] return result # `get_current_url` comes from `werkzeug.wsgi` def get_current_url(environ, root_only=False, strip_querystring=False, host_only=False): """A handy helper function that recreates the full URL for the current request or parts of it. Here an example: >>> from werkzeug import create_environ >>> env = create_environ("/?param=foo", "http://localhost/script") >>> get_current_url(env) 'http://localhost/script/?param=foo' >>> get_current_url(env, root_only=True) 'http://localhost/script/' >>> get_current_url(env, host_only=True) 'http://localhost/' >>> get_current_url(env, strip_querystring=True) 'http://localhost/script/' :param environ: the WSGI environment to get the current URL from. :param root_only: set `True` if you only want the root URL. :param strip_querystring: set to `True` if you don't want the querystring. :param host_only: set to `True` if the host URL should be returned. """ tmp = [environ['wsgi.url_scheme'], '://', get_host(environ)] cat = tmp.append if host_only: return ''.join(tmp) + '/' cat(urllib_quote(environ.get('SCRIPT_NAME', '').rstrip('/'))) if root_only: cat('/') else: cat(urllib_quote('/' + environ.get('PATH_INFO', '').lstrip('/'))) if not strip_querystring: qs = environ.get('QUERY_STRING') if qs: cat('?' + qs) return ''.join(tmp) def get_client_ip(environ): """ Naively yank the first IP address in an X-Forwarded-For header and assume this is correct. Note: Don't use this in security sensitive situations since this value may be forged from a client. """ try: return environ['HTTP_X_FORWARDED_FOR'].split(',')[0].strip() except (KeyError, IndexError): return environ.get('REMOTE_ADDR')
SILENT KILLER Tool