Package: python-requests-unixsocket
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu noble ubuntu-patch

Dear Maintainer,

When using python-requests-unixsocket 0.3.0-3 against requests 2.29+
(currently 2.31.0+dfsg-1 is in testing), the following code produces an
exception:

```python3
import requests_unixsocket

with requests_unixsocket.Session() as session:
    session.get('http+unix://%2Ftmp/')
```

  TypeError: HTTPConnection.request() got an unexpected keyword argument 
'chunked'

There is a bug upstream [1] for it. And I think the regression was
introduced by PR 6226 [2] in the underlying library (requests).

I applied a patch that was proposed upstream but not yet merged.

In Ubuntu, the attached patch was applied to achieve the following:

  * Fix incompatibility with requests 2.29 (LP: #2053016).
    - d/p/0001-Inherit-HTTPConnection-through-urllib3.connection-no.patch

Thanks for considering the patch.

[1] https://github.com/msabramo/requests-unixsocket/issues/70
[2] https://github.com/psf/requests/pull/6226

-- System Information:
Debian Release: trixie/sid
  APT prefers mantic-updates
  APT policy: (500, 'mantic-updates'), (500, 'mantic-security'), (500, 
'mantic'), (100, 'mantic-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.1.0-16-generic (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru 
python-requests-unixsocket-0.3.0/debian/patches/0001-Inherit-HTTPConnection-through-urllib3.connection-no.patch
 
python-requests-unixsocket-0.3.0/debian/patches/0001-Inherit-HTTPConnection-through-urllib3.connection-no.patch
--- 
python-requests-unixsocket-0.3.0/debian/patches/0001-Inherit-HTTPConnection-through-urllib3.connection-no.patch
     1970-01-01 01:00:00.000000000 +0100
+++ 
python-requests-unixsocket-0.3.0/debian/patches/0001-Inherit-HTTPConnection-through-urllib3.connection-no.patch
     2024-02-14 11:16:52.000000000 +0100
@@ -0,0 +1,47 @@
+Description: Inherit HTTPConnection through urllib3.connection, not httplib
+ By inheriting from `urllib3.connection.HTTPConnection` (that inherits
+ from `httplib.HTTPConnection` itself), we can adapt to the internal
+ changes in urllib3 2.0 that added a `request()` method that is
+ incompatible with httplib.HTTPConnection.request.
+ .
+ This fixes the incompatibility between urllib3 2.0 and requests 1.26+,
+ which was the first version that stopped vendoring urllib3.
+ .
+ Reference: 
https://github.com/docker/docker-py/issues/3113#issuecomment-1531570788
+ Fixes: #70
+Author: Martin Roukala <martin.rouk...@mupuf.org>
+Origin: upstream, https://github.com/msabramo/requests-unixsocket/pull/69
+Bug: https://github.com/msabramo/requests-unixsocket/issues/70
+Bug-Ubuntu: https://launchpad.net/bugs/2053016
+Applied-Upstream: no
+Last-Update: 2024-02-14
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+diff --git a/requests_unixsocket/adapters.py b/requests_unixsocket/adapters.py
+index 83e1400..513c243 100644
+--- a/requests_unixsocket/adapters.py
++++ b/requests_unixsocket/adapters.py
+@@ -3,11 +3,6 @@ import socket
+ from requests.adapters import HTTPAdapter
+ from requests.compat import urlparse, unquote
+ 
+-try:
+-    import http.client as httplib
+-except ImportError:
+-    import httplib
+-
+ try:
+     from requests.packages import urllib3
+ except ImportError:
+@@ -16,7 +11,7 @@ except ImportError:
+ 
+ # The following was adapted from some code from docker-py
+ # https://github.com/docker/docker-py/blob/master/docker/transport/unixconn.py
+-class UnixHTTPConnection(httplib.HTTPConnection, object):
++class UnixHTTPConnection(urllib3.connection.HTTPConnection, object):
+ 
+     def __init__(self, unix_socket_url, timeout=60):
+         """Create an HTTP connection to a unix domain socket
+-- 
+2.40.1
+
diff -Nru python-requests-unixsocket-0.3.0/debian/patches/series 
python-requests-unixsocket-0.3.0/debian/patches/series
--- python-requests-unixsocket-0.3.0/debian/patches/series      1970-01-01 
01:00:00.000000000 +0100
+++ python-requests-unixsocket-0.3.0/debian/patches/series      2024-02-14 
11:12:51.000000000 +0100
@@ -0,0 +1 @@
+0001-Inherit-HTTPConnection-through-urllib3.connection-no.patch

Reply via email to