Skip to content

Commit 02694bd

Browse files
committed
play around with arg manipulation
1 parent 723a16a commit 02694bd

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

wsgi_intercept/__init__.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,23 @@ class WSGI_HTTPConnection(HTTPConnection):
526526
Intercept all traffic to certain hosts & redirect into a WSGI
527527
application object.
528528
"""
529+
530+
def __init__(self, *args, **kwargs):
531+
print(f"args1 is {args}, kwargs is {kwargs}")
532+
if 'host' in kwargs:
533+
host = kwargs.pop('host')
534+
if 'port' in kwargs:
535+
port = kwargs.pop('port')
536+
else:
537+
port = None
538+
print(f"args2 is {args}, kwargs is {kwargs}")
539+
super().__init__(host, port, *args, **kwargs)
540+
else:
541+
if len(args) > 2:
542+
args = args[0:2]
543+
super().__init__(*args, **kwargs)
544+
545+
529546
def get_app(self, host, port):
530547
"""
531548
Return the app object for the given (host, port).
@@ -579,9 +596,6 @@ class WSGI_HTTPSConnection(HTTPSConnection, WSGI_HTTPConnection):
579596
application object.
580597
"""
581598

582-
def __init__(self, *args, **kwargs):
583-
print("getting %s ::: %s" % (args, kwargs))
584-
super().__init__(*args, **kwargs)
585599

586600
def get_app(self, host, port):
587601
"""

wsgi_intercept/_urllib3.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def make_urllib3_override(HTTPConnectionPool, HTTPSConnectionPool,
3232

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

4443
def __init__(self, *args, **kwargs):
45-
print(f"https pre: {args} ::: {kwargs}")
44+
print(f"{args}:::{kwargs}")
4645
for kw in HTTPS_KEYWORD_POPS:
4746
kwargs.pop(kw, None)
4847
if sys.version_info > (3, 12):
4948
kwargs.pop('key_file', None)
5049
kwargs.pop('cert_file', None)
51-
print(f"https post: {args} ::: {kwargs}")
52-
host = kwargs.pop('host')
53-
port = kwargs.pop('port')
54-
WSGI_HTTPSConnection.__init__(self, host, port, *args, **kwargs)
55-
print("after wsgi")
50+
WSGI_HTTPSConnection.__init__(self, *args, **kwargs)
5651
HTTPSConnection.__init__(self, *args, **kwargs)
57-
print("after https")
5852

5953
def install():
6054
if 'http_proxy' in os.environ or 'https_proxy' in os.environ:

0 commit comments

Comments
 (0)