jupyterlite-simple-cors-proxy 0.1.14__py3-none-any.whl → 0.1.15__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jupyterlite_simple_cors_proxy/__init__.py +1 -1
- jupyterlite_simple_cors_proxy/cacheproxy.py +8 -5
- jupyterlite_simple_cors_proxy/proxy.py +10 -7
- {jupyterlite_simple_cors_proxy-0.1.14.dist-info → jupyterlite_simple_cors_proxy-0.1.15.dist-info}/METADATA +3 -2
- jupyterlite_simple_cors_proxy-0.1.15.dist-info/RECORD +9 -0
- {jupyterlite_simple_cors_proxy-0.1.14.dist-info → jupyterlite_simple_cors_proxy-0.1.15.dist-info}/WHEEL +1 -1
- jupyterlite_simple_cors_proxy-0.1.14.dist-info/RECORD +0 -9
- {jupyterlite_simple_cors_proxy-0.1.14.dist-info → jupyterlite_simple_cors_proxy-0.1.15.dist-info/licenses}/LICENSE +0 -0
- {jupyterlite_simple_cors_proxy-0.1.14.dist-info → jupyterlite_simple_cors_proxy-0.1.15.dist-info}/top_level.txt +0 -0
@@ -13,6 +13,7 @@ CORS_PROXIES = {
|
|
13
13
|
"none": {"url": "{}", "quote": False},
|
14
14
|
}
|
15
15
|
|
16
|
+
cache_bust_headers = {"Cache-Control": "no-cache", "Pragma": "no-cache"}
|
16
17
|
|
17
18
|
class CorsProxy:
|
18
19
|
"""CORS Proxy with optional caching support."""
|
@@ -90,7 +91,7 @@ class CorsProxy:
|
|
90
91
|
# https://simonwillison.net/2025/Jan/31/save-memory-with-bytesio/
|
91
92
|
return io.BytesIO(r.content)
|
92
93
|
|
93
|
-
def cors_proxy_get(self, url: str, params: Optional[dict] = None, force: bool = False, proxy: str = "corsproxyio") -> requests.Response:
|
94
|
+
def cors_proxy_get(self, url: str, params: Optional[dict] = None, force: bool = False, proxy: str = "corsproxyio", cache_bust: bool=True) -> requests.Response:
|
94
95
|
"""
|
95
96
|
CORS proxy for GET resources with requests-like response.
|
96
97
|
|
@@ -103,18 +104,20 @@ class CorsProxy:
|
|
103
104
|
A requests response object.
|
104
105
|
"""
|
105
106
|
proxy_url = self.xurl(url, params, force)
|
106
|
-
|
107
|
+
headers = cache_bust_headers if cache_bust else None
|
108
|
+
return self.session.get(proxy_url, headers=headers)
|
107
109
|
|
108
110
|
def robust_get_request(
|
109
|
-
self, url: str, params: Optional[dict] = None, proxy: str = ""
|
111
|
+
self, url: str, params: Optional[dict] = None, proxy: str = "", cache_bust :bool = True
|
110
112
|
) -> requests.Response:
|
111
113
|
"""
|
112
114
|
Try to make a simple request else fall back to a proxy.
|
113
115
|
"""
|
116
|
+
headers = cache_bust_headers if cache_bust else None
|
114
117
|
try:
|
115
|
-
r = self.session.get(url, params=params)
|
118
|
+
r = self.session.get(url, params=params, headers=headers)
|
116
119
|
except:
|
117
|
-
r = self.cors_proxy_get(url, params=params, proxy=proxy)
|
120
|
+
r = self.cors_proxy_get(url, params=params, proxy=proxy, headers=headers)
|
118
121
|
return r
|
119
122
|
|
120
123
|
|
@@ -12,6 +12,7 @@ CORS_PROXIES = {
|
|
12
12
|
"none": {"url": "{}", "quote": False},
|
13
13
|
}
|
14
14
|
|
15
|
+
cache_bust_headers = {"Cache-Control": "no-cache","Pragma": "no-cache"}
|
15
16
|
|
16
17
|
def apply_cors_proxy(url, proxy="corsproxyio"):
|
17
18
|
"""
|
@@ -50,9 +51,9 @@ def xurl(url, params=None, force=False, proxy="corsproxyio"):
|
|
50
51
|
return url
|
51
52
|
|
52
53
|
|
53
|
-
def furl(url, params=None, force=False, proxy="corsproxyio"):
|
54
|
+
def furl(url, params=None, force=False, proxy="corsproxyio", cache_bust=True):
|
54
55
|
"""Return file like object after calling the proxied URL."""
|
55
|
-
r = cors_proxy_get(url, params, force, proxy=proxy)
|
56
|
+
r = cors_proxy_get(url, params, force, proxy=proxy, cache_bust=cache_bust)
|
56
57
|
|
57
58
|
# Return a file-like object from the JSON string
|
58
59
|
# TO DO - something to consider?
|
@@ -60,7 +61,7 @@ def furl(url, params=None, force=False, proxy="corsproxyio"):
|
|
60
61
|
return io.BytesIO(r.content)
|
61
62
|
|
62
63
|
|
63
|
-
def cors_proxy_get(url, params=None, force=False, proxy="corsproxyio"):
|
64
|
+
def cors_proxy_get(url, params=None, force=False, proxy="corsproxyio", cache_bust=True):
|
64
65
|
"""
|
65
66
|
CORS proxy for GET resources with requests-like response.
|
66
67
|
|
@@ -75,15 +76,17 @@ def cors_proxy_get(url, params=None, force=False, proxy="corsproxyio"):
|
|
75
76
|
|
76
77
|
# Do a simple requests get and
|
77
78
|
# just pass through the entire response object
|
78
|
-
|
79
|
+
headers = cache_bust_headers if cache_bust else None
|
80
|
+
return requests.get(proxy_url, headers=headers)
|
79
81
|
|
80
82
|
|
81
|
-
def robust_get_request(url, params=None, proxy="corsproxyio"):
|
83
|
+
def robust_get_request(url, params=None, proxy="corsproxyio", cache_bust=True):
|
82
84
|
"""
|
83
85
|
Try to make a simple request else fall back to a proxy.
|
84
86
|
"""
|
87
|
+
headers = cache_bust_headers if cache_bust else None
|
85
88
|
try:
|
86
|
-
r = requests.get(url, params=params)
|
89
|
+
r = requests.get(url, params=params, headers=headers)
|
87
90
|
except:
|
88
|
-
r = cors_proxy_get(url, params=params, proxy=proxy)
|
91
|
+
r = cors_proxy_get(url, params=params, proxy=proxy, cache_bust=cache_bust)
|
89
92
|
return r
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: jupyterlite-simple-cors-proxy
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.15
|
4
4
|
Summary: A simple CORS proxy utility with requests-like response
|
5
5
|
Home-page: https://github.com/innovationOUtside/jupyterlite-simple-cors-proxy
|
6
6
|
Author: Tony Hirst
|
@@ -18,6 +18,7 @@ Dynamic: classifier
|
|
18
18
|
Dynamic: description
|
19
19
|
Dynamic: description-content-type
|
20
20
|
Dynamic: home-page
|
21
|
+
Dynamic: license-file
|
21
22
|
Dynamic: requires-dist
|
22
23
|
Dynamic: requires-python
|
23
24
|
Dynamic: summary
|
@@ -0,0 +1,9 @@
|
|
1
|
+
jupyterlite_simple_cors_proxy/__init__.py,sha256=b0mRQUorFy9-0CFElhhyI0UMVKf_tYuToyiXDlXyaSw,280
|
2
|
+
jupyterlite_simple_cors_proxy/cacheproxy.py,sha256=_Dx-eI4ZDqdCgJuRPsahFqqUW3DVNx9keo9C11U905A,4758
|
3
|
+
jupyterlite_simple_cors_proxy/fastf1_proxy.py,sha256=FglRogTIlSJvHOu6lFS3S-EHDb37M93aYjQpoKc1QYs,7614
|
4
|
+
jupyterlite_simple_cors_proxy/proxy.py,sha256=pDvN_ZUmVfN6yjYcAzo5k16uJQ6wv-fJsl1ycBXywwQ,2795
|
5
|
+
jupyterlite_simple_cors_proxy-0.1.15.dist-info/licenses/LICENSE,sha256=Ogw7GUmeZIxmDNiKWsu_N07svNoGnPB7lWyiXHX_rMY,1074
|
6
|
+
jupyterlite_simple_cors_proxy-0.1.15.dist-info/METADATA,sha256=MswZgGHD5q5YG-EUApBXsyl1TsS2dUaZ9mRju92vm-8,3166
|
7
|
+
jupyterlite_simple_cors_proxy-0.1.15.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
8
|
+
jupyterlite_simple_cors_proxy-0.1.15.dist-info/top_level.txt,sha256=Oh0oQrSmRnBq5u675coiKMbkb2ASg8AGF8ZiZTzUS5Q,30
|
9
|
+
jupyterlite_simple_cors_proxy-0.1.15.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
jupyterlite_simple_cors_proxy/__init__.py,sha256=vE2WKSaR1d-lu1EoKN3obCHFUB-oowD7I1jwEl5qvok,280
|
2
|
-
jupyterlite_simple_cors_proxy/cacheproxy.py,sha256=svCmdb6j06PcU2zmG0ppe6S1-f0GPwGmkxIemwkeYJc,4464
|
3
|
-
jupyterlite_simple_cors_proxy/fastf1_proxy.py,sha256=FglRogTIlSJvHOu6lFS3S-EHDb37M93aYjQpoKc1QYs,7614
|
4
|
-
jupyterlite_simple_cors_proxy/proxy.py,sha256=jJgoawJxXFCSazwkV3jb6R1uMc7lrkpHgOCrcwAY06w,2477
|
5
|
-
jupyterlite_simple_cors_proxy-0.1.14.dist-info/LICENSE,sha256=Ogw7GUmeZIxmDNiKWsu_N07svNoGnPB7lWyiXHX_rMY,1074
|
6
|
-
jupyterlite_simple_cors_proxy-0.1.14.dist-info/METADATA,sha256=ABX3wMk5WEcG7_Fc2SphBs_wRhjskTn6L8rzSnP5Jqw,3144
|
7
|
-
jupyterlite_simple_cors_proxy-0.1.14.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
|
8
|
-
jupyterlite_simple_cors_proxy-0.1.14.dist-info/top_level.txt,sha256=Oh0oQrSmRnBq5u675coiKMbkb2ASg8AGF8ZiZTzUS5Q,30
|
9
|
-
jupyterlite_simple_cors_proxy-0.1.14.dist-info/RECORD,,
|
File without changes
|
File without changes
|