File: support-urllib3-2.x_2.patch

package info (click to toggle)
python-wsgi-intercept 1.13.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 560 kB
  • sloc: python: 1,390; makefile: 57; sh: 5
file content (88 lines) | stat: -rw-r--r-- 3,618 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
From 723a16aae0c2564036bd92f1f815eba8d9cc2611 Mon Sep 17 00:00:00 2001
From: Chris Dent <cdent@anticdent.org>
Date: Tue, 19 Mar 2024 19:20:29 +0000
Subject: [PATCH 2/6] for sharing testing

---
 setup.py                             |  2 +-
 wsgi_intercept/__init__.py           |  5 +++++
 wsgi_intercept/_urllib3.py           | 11 ++++++++---
 wsgi_intercept/tests/test_urllib3.py |  2 +-
 4 files changed, 15 insertions(+), 5 deletions(-)

Index: python-wsgi-intercept/setup.py
===================================================================
--- python-wsgi-intercept.orig/setup.py
+++ python-wsgi-intercept/setup.py
@@ -40,7 +40,7 @@ META = {
             'pytest>=2.4',
             'httplib2',
             'requests>=2.0.1',
-            'urllib3<2.0.0',
+            'urllib3>=2.0.0',
         ],
         'docs': [
             'sphinx',
Index: python-wsgi-intercept/wsgi_intercept/__init__.py
===================================================================
--- python-wsgi-intercept.orig/wsgi_intercept/__init__.py
+++ python-wsgi-intercept/wsgi_intercept/__init__.py
@@ -578,6 +578,11 @@ class WSGI_HTTPSConnection(HTTPSConnecti
     Intercept all traffic to certain hosts & redirect into a WSGI
     application object.
     """
+
+    def __init__(self, *args, **kwargs):
+        print("getting %s ::: %s" % (args, kwargs))
+        super().__init__(*args, **kwargs)
+
     def get_app(self, host, port):
         """
         Return the app object for the given (host, port).
Index: python-wsgi-intercept/wsgi_intercept/_urllib3.py
===================================================================
--- python-wsgi-intercept.orig/wsgi_intercept/_urllib3.py
+++ python-wsgi-intercept/wsgi_intercept/_urllib3.py
@@ -32,6 +32,7 @@ def make_urllib3_override(HTTPConnection
                           HTTPConnection, HTTPSConnection):
 
     class HTTP_WSGIInterceptor(WSGI_HTTPConnection, HTTPConnection):
+        print(f"http pre: {args} ::: {kwargs}")
         def __init__(self, *args, **kwargs):
             for kw in HTTP_KEYWORD_POPS:
                 kwargs.pop(kw, None)
@@ -42,14 +43,19 @@ def make_urllib3_override(HTTPConnection
         is_verified = True
 
         def __init__(self, *args, **kwargs):
-            print(f"pre: {args} ::: {kwargs}")
+            print(f"https pre: {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)
-            WSGI_HTTPSConnection.__init__(self, *args, **kwargs)
+            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")
             HTTPSConnection.__init__(self, *args, **kwargs)
+            print("after https")
 
     def install():
         if 'http_proxy' in os.environ or 'https_proxy' in os.environ:
Index: python-wsgi-intercept/wsgi_intercept/tests/test_urllib3.py
===================================================================
--- python-wsgi-intercept.orig/wsgi_intercept/tests/test_urllib3.py
+++ python-wsgi-intercept/wsgi_intercept/tests/test_urllib3.py
@@ -54,7 +54,7 @@ def test_proxy_handling():
     del os.environ['http_proxy']
 
 
-def test_https():
+def test_https_meo():
     with InstalledApp(wsgi_app.simple_app, host=HOST, port=443) as app:
         resp = http.request(
             'GET', 'https://some_hopefully_nonexistant_domain:443/')