pylookyloo 1.27.1__py3-none-any.whl → 1.28.0__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.
Potentially problematic release.
This version of pylookyloo might be problematic. Click here for more details.
- pylookyloo/api.py +24 -1
- {pylookyloo-1.27.1.dist-info → pylookyloo-1.28.0.dist-info}/METADATA +1 -1
- pylookyloo-1.28.0.dist-info/RECORD +8 -0
- {pylookyloo-1.27.1.dist-info → pylookyloo-1.28.0.dist-info}/WHEEL +1 -1
- pylookyloo-1.27.1.dist-info/RECORD +0 -8
- {pylookyloo-1.27.1.dist-info → pylookyloo-1.28.0.dist-info}/LICENSE +0 -0
- {pylookyloo-1.27.1.dist-info → pylookyloo-1.28.0.dist-info}/entry_points.txt +0 -0
pylookyloo/api.py
CHANGED
|
@@ -17,6 +17,29 @@ import requests
|
|
|
17
17
|
|
|
18
18
|
from urllib3.util import Retry
|
|
19
19
|
from requests.adapters import HTTPAdapter
|
|
20
|
+
from requests.sessions import Session
|
|
21
|
+
from requests.status_codes import codes
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class SafeRedirectRePOSTSession(Session):
|
|
25
|
+
|
|
26
|
+
def rebuild_method(self, prepared_request: requests.PreparedRequest, response: requests.Response) -> None:
|
|
27
|
+
# This method will resubmit a POST when we have a http -> https redirect
|
|
28
|
+
if response.status_code == codes.moved and prepared_request.method == 'POST':
|
|
29
|
+
# make sure it is just a redirect http->https and we're not going to a different host
|
|
30
|
+
prec_url = urlparse(response.url)
|
|
31
|
+
next_url = urlparse(prepared_request.url)
|
|
32
|
+
|
|
33
|
+
if (prec_url.netloc != next_url.netloc or prec_url.scheme != 'http'
|
|
34
|
+
or next_url.scheme != 'https'):
|
|
35
|
+
super().rebuild_method(prepared_request, response)
|
|
36
|
+
else:
|
|
37
|
+
# For surely good reasons, requests force-remove the body of the redirected requests unless the statuscode is either 307 or 308
|
|
38
|
+
# https://github.com/psf/requests/issues/1084
|
|
39
|
+
# Doing that makes sure we keep it
|
|
40
|
+
response.status_code = 307
|
|
41
|
+
else:
|
|
42
|
+
super().rebuild_method(prepared_request, response)
|
|
20
43
|
|
|
21
44
|
|
|
22
45
|
class PyLookylooError(Exception):
|
|
@@ -78,7 +101,7 @@ class Lookyloo():
|
|
|
78
101
|
self.root_url = 'http://' + self.root_url
|
|
79
102
|
if not self.root_url.endswith('/'):
|
|
80
103
|
self.root_url += '/'
|
|
81
|
-
self.session =
|
|
104
|
+
self.session = SafeRedirectRePOSTSession()
|
|
82
105
|
self.session.headers['user-agent'] = useragent if useragent else f'PyLookyloo / {version("pylookyloo")}'
|
|
83
106
|
if proxies:
|
|
84
107
|
self.session.proxies.update(proxies)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
pylookyloo/__init__.py,sha256=_JYXwXHL7ShZkeruvGd8qDTpxNRfuDjvV65SOMMU6yc,1922
|
|
2
|
+
pylookyloo/api.py,sha256=h6v4hf4HtxUD-pf4uEKSurMw_QYnpcgYUBk3dv7v1Nc,30733
|
|
3
|
+
pylookyloo/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
pylookyloo-1.28.0.dist-info/LICENSE,sha256=4C4hLYrIkUD96Ggk-y_Go1Qf7PBZrEm9PSeTGe2nd4s,1516
|
|
5
|
+
pylookyloo-1.28.0.dist-info/METADATA,sha256=mG1xvmCC10QP-yBYZ4PkfI8NVLiZe9f8HOAHLeydKrY,2347
|
|
6
|
+
pylookyloo-1.28.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
7
|
+
pylookyloo-1.28.0.dist-info/entry_points.txt,sha256=y2c0Ujg8co6Xyf7MoxStVU-fLQMZBSGAg-KFidmsha4,44
|
|
8
|
+
pylookyloo-1.28.0.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
pylookyloo/__init__.py,sha256=_JYXwXHL7ShZkeruvGd8qDTpxNRfuDjvV65SOMMU6yc,1922
|
|
2
|
-
pylookyloo/api.py,sha256=JrHJr4IJ8NpJI8otMS83f4uUTifFOxqwDO2UIFNW2QE,29530
|
|
3
|
-
pylookyloo/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
pylookyloo-1.27.1.dist-info/LICENSE,sha256=4C4hLYrIkUD96Ggk-y_Go1Qf7PBZrEm9PSeTGe2nd4s,1516
|
|
5
|
-
pylookyloo-1.27.1.dist-info/METADATA,sha256=6AwRog0u2bcT5lAcIOT7Y_OxZe-4g8RFOpegYiT9XVE,2347
|
|
6
|
-
pylookyloo-1.27.1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
7
|
-
pylookyloo-1.27.1.dist-info/entry_points.txt,sha256=y2c0Ujg8co6Xyf7MoxStVU-fLQMZBSGAg-KFidmsha4,44
|
|
8
|
-
pylookyloo-1.27.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|