Skip to content

Commit

Permalink
play around with arg manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
cdent committed Mar 19, 2024
1 parent 723a16a commit 02694bd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
20 changes: 17 additions & 3 deletions wsgi_intercept/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,23 @@ class WSGI_HTTPConnection(HTTPConnection):
Intercept all traffic to certain hosts & redirect into a WSGI
application object.
"""

def __init__(self, *args, **kwargs):
print(f"args1 is {args}, kwargs is {kwargs}")
if 'host' in kwargs:
host = kwargs.pop('host')
if 'port' in kwargs:
port = kwargs.pop('port')
else:
port = None
print(f"args2 is {args}, kwargs is {kwargs}")
super().__init__(host, port, *args, **kwargs)
else:
if len(args) > 2:
args = args[0:2]
super().__init__(*args, **kwargs)


def get_app(self, host, port):
"""
Return the app object for the given (host, port).
Expand Down Expand Up @@ -579,9 +596,6 @@ class WSGI_HTTPSConnection(HTTPSConnection, WSGI_HTTPConnection):
application object.
"""

def __init__(self, *args, **kwargs):
print("getting %s ::: %s" % (args, kwargs))
super().__init__(*args, **kwargs)

def get_app(self, host, port):
"""
Expand Down
10 changes: 2 additions & 8 deletions wsgi_intercept/_urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def make_urllib3_override(HTTPConnectionPool, HTTPSConnectionPool,

class HTTP_WSGIInterceptor(WSGI_HTTPConnection, HTTPConnection):
def __init__(self, *args, **kwargs):
print(f"http pre: {args} ::: {kwargs}")
for kw in HTTP_KEYWORD_POPS:
kwargs.pop(kw, None)
WSGI_HTTPConnection.__init__(self, *args, **kwargs)
Expand All @@ -42,19 +41,14 @@ class HTTPS_WSGIInterceptor(WSGI_HTTPSConnection, HTTPSConnection):
is_verified = True

def __init__(self, *args, **kwargs):
print(f"https pre: {args} ::: {kwargs}")
print(f"{args}:::{kwargs}")
for kw in HTTPS_KEYWORD_POPS:
kwargs.pop(kw, None)
if sys.version_info > (3, 12):
kwargs.pop('key_file', None)
kwargs.pop('cert_file', None)
print(f"https post: {args} ::: {kwargs}")
host = kwargs.pop('host')
port = kwargs.pop('port')
WSGI_HTTPSConnection.__init__(self, host, port, *args, **kwargs)
print("after wsgi")
WSGI_HTTPSConnection.__init__(self, *args, **kwargs)
HTTPSConnection.__init__(self, *args, **kwargs)
print("after https")

def install():
if 'http_proxy' in os.environ or 'https_proxy' in os.environ:
Expand Down

0 comments on commit 02694bd

Please sign in to comment.