unzip-http 0.8__tar.gz → 0.9__tar.gz
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.
- {unzip_http-0.8/unzip_http.egg-info → unzip_http-0.9}/PKG-INFO +1 -1
- {unzip_http-0.8 → unzip_http-0.9}/pyproject.toml +1 -1
- {unzip_http-0.8 → unzip_http-0.9/unzip_http.egg-info}/PKG-INFO +1 -1
- {unzip_http-0.8 → unzip_http-0.9}/unzip_http.py +14 -3
- {unzip_http-0.8 → unzip_http-0.9}/LICENSE-mit.txt +0 -0
- {unzip_http-0.8 → unzip_http-0.9}/MANIFEST.in +0 -0
- {unzip_http-0.8 → unzip_http-0.9}/README.md +0 -0
- {unzip_http-0.8 → unzip_http-0.9}/setup.cfg +0 -0
- {unzip_http-0.8 → unzip_http-0.9}/tests/test_unzip_http.py +0 -0
- {unzip_http-0.8 → unzip_http-0.9}/unzip_http.egg-info/SOURCES.txt +0 -0
- {unzip_http-0.8 → unzip_http-0.9}/unzip_http.egg-info/dependency_links.txt +0 -0
- {unzip_http-0.8 → unzip_http-0.9}/unzip_http.egg-info/entry_points.txt +0 -0
- {unzip_http-0.8 → unzip_http-0.9}/unzip_http.egg-info/requires.txt +0 -0
- {unzip_http-0.8 → unzip_http-0.9}/unzip_http.egg-info/top_level.txt +0 -0
|
@@ -56,7 +56,7 @@ import pathlib
|
|
|
56
56
|
import urllib.parse
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
__version__ = '0.
|
|
59
|
+
__version__ = '0.9'
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
def error(s):
|
|
@@ -137,6 +137,11 @@ class RemoteZipFile:
|
|
|
137
137
|
import urllib3
|
|
138
138
|
self.url = url
|
|
139
139
|
self.http = urllib3.PoolManager()
|
|
140
|
+
self.default_headers = {
|
|
141
|
+
'User-Agent': f'unzip-http/{__version__}',
|
|
142
|
+
'Accept': '*/*',
|
|
143
|
+
'Connection': 'keep-alive',
|
|
144
|
+
}
|
|
140
145
|
self.zip_size = 0
|
|
141
146
|
|
|
142
147
|
def __enter__(self):
|
|
@@ -158,7 +163,7 @@ class RemoteZipFile:
|
|
|
158
163
|
return list(r.filename for r in self.infoiter())
|
|
159
164
|
|
|
160
165
|
def infoiter(self):
|
|
161
|
-
resp = self.
|
|
166
|
+
resp = self._request('HEAD')
|
|
162
167
|
if not (200 <= resp.status <= 299):
|
|
163
168
|
error(f'cannot open URL: HTTP status {resp.status}')
|
|
164
169
|
|
|
@@ -245,8 +250,14 @@ class RemoteZipFile:
|
|
|
245
250
|
for fn in members or self.namelist():
|
|
246
251
|
self.extract(fn, path, pwd=pwd)
|
|
247
252
|
|
|
253
|
+
def _request(self, method, headers=None, preload_content=True):
|
|
254
|
+
h = dict(self.default_headers)
|
|
255
|
+
if headers:
|
|
256
|
+
h.update(headers)
|
|
257
|
+
return self.http.request(method, self.url, headers=h, preload_content=preload_content)
|
|
258
|
+
|
|
248
259
|
def get_range(self, start, n):
|
|
249
|
-
return self.
|
|
260
|
+
return self._request('GET', headers={'Range': f'bytes={start}-{start+n-1}'}, preload_content=False)
|
|
250
261
|
|
|
251
262
|
def matching_files(self, *globs):
|
|
252
263
|
for f in self.files.values():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|