requests-unixsocket
requests-unixsocket copied to clipboard
Error when using urllib3 2.x.x release
I am trying to run a requests with a UNIX socket but it fails using the latest versions in PyPI. I guess it is related to the change in major version of urllib3 2.0.0 that happened in PyPI roughly 1 month ago
$ python3 -m venv my_venv
(my_venv) $ . ./my_venv/bin/activate
(my_venv) $ pip install requests-unixsocket
Collecting requests-unixsocket
Using cached requests_unixsocket-0.3.0-py2.py3-none-any.whl (11 kB)
Collecting requests>=1.1
Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Collecting charset-normalizer<4,>=2
Using cached charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (197 kB)
Collecting idna<4,>=2.5
Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting urllib3<3,>=1.21.1
Using cached urllib3-2.0.2-py3-none-any.whl (123 kB)
Collecting certifi>=2017.4.17
Downloading certifi-2023.5.7-py3-none-any.whl (156 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 157.0/157.0 kB 1.5 MB/s eta 0:00:00
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests, requests-unixsocket
Successfully installed certifi-2023.5.7 charset-normalizer-3.1.0 idna-3.4 requests-2.31.0 requests-unixsocket-0.3.0 urllib3-2.0.2
[notice] A new release of pip available: 22.3.1 -> 23.1.2
[notice] To update, run: pip install --upgrade pip
(my_venv) $ cat test.py
import requests
import requests_unixsocket
requests_unixsocket.monkeypatch()
requests.get('http+unix://%2Frun%2Fuser%2F4876%2Fadari_server_834977.socket')
(my_venv) $ python3 test.py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/var/tmp/my_venv/lib64/python3.11/site-packages/requests_unixsocket/__init__.py", line 51, in get
return request('get', url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/tmp/my_venv/lib64/python3.11/site-packages/requests_unixsocket/__init__.py", line 46, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/tmp/my_venv/lib64/python3.11/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/tmp/my_venv/lib64/python3.11/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/tmp/my_venv/lib64/python3.11/site-packages/requests/adapters.py", line 486, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/var/tmp/my_venv/lib64/python3.11/site-packages/urllib3/connectionpool.py", line 790, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/var/tmp/my_venv/lib64/python3.11/site-packages/urllib3/connectionpool.py", line 496, in _make_request
conn.request(
TypeError: HTTPConnection.request() got an unexpected keyword argument 'chunked'
If urllib3 is downgraded to 1.26.16 then the problem disappears.
We also get the same error: https://github.com/cherrypy/cheroot/actions/runs/5107356552/jobs/9190603385#step:19:941 — I suppose this project needs to be adapted to make use of the new API.
Oh, it looks like https://github.com/msabramo/requests-unixsocket/pull/69 might address this problem.
@msabramo could you help to get the fix for this released? It's affecting many project CIs now due to the underlying urllib3 update to v2.
FYI to all: since this project seems to be abandoned, but its longevity is important to my team, we've forked the project as requests-unixsocket2. It should be a drop in replacement for this package.
- PyPI: https://pypi.org/project/requests-unixsocket2/0.4.0/
- Repository: https://gitlab.com/thelabnyc/requests-unixsocket2
We've migrated the fix for this issue there, merged it, and released to PyPI as part of v0.4.0.
@crgwbr : do you plan to eventually take over the requests-unixsocket pypi place now that the original requests-unixsocket is abandoneware? I have no idea whether that's possible, I don't know the policiess for pypi.
@crgwbr : do you plan to eventually take over the requests-unixsocket pypi place now that the original requests-unixsocket is abandoneware? I have no idea whether that's possible, I don't know the policiess for pypi.
Oh sorry, I realize this has already been asked in https://github.com/msabramo/requests-unixsocket/pull/69. In any case I just wanted to thank you @crgwbr for moving this forward!