summaryrefslogtreecommitdiff
path: root/Ports
diff options
context:
space:
mode:
authorRodrigo Tobar <rtobarc@gmail.com>2021-09-30 10:40:04 +0800
committerLinus Groh <mail@linusgroh.de>2021-10-06 13:57:52 +0100
commitc38c93bff12ea1192c96db27d4115b1935f7a9b3 (patch)
tree31332357a7ca75b07eea1fa31e59d0e7023e23c4 /Ports
parente02c843af45c8005a208b22df785db21c1307210 (diff)
downloadserenity-c38c93bff12ea1192c96db27d4115b1935f7a9b3.zip
Ports: Patch Python's http.client due to unimplemented socket option
This problem has been reported on https://bugs.python.org/issue45328 and a fix has been provided, potential review and merge are pending.
Diffstat (limited to 'Ports')
-rw-r--r--Ports/python3/patches/ReadMe.md4
-rw-r--r--Ports/python3/patches/http-client.patch24
2 files changed, 28 insertions, 0 deletions
diff --git a/Ports/python3/patches/ReadMe.md b/Ports/python3/patches/ReadMe.md
index c068b1e753..c862a201e9 100644
--- a/Ports/python3/patches/ReadMe.md
+++ b/Ports/python3/patches/ReadMe.md
@@ -16,6 +16,10 @@ Enforce UTF-8 as encoding by defining `_Py_FORCE_UTF8_LOCALE`.
As usual, make the `configure` script recognize Serenity. Also set `MACHDEP` (which is used for `sys.platform`) to a version-less `serenityos`, even when not cross-compiling.
+## `http-client.patch`
+
+Allows HTTPConnection to work without the TCP_NODELAY socket option, as this is not supported by Serenity.
+
## `tweak-setup-py.patch`
Make some tweaks to Python's `setup.py` files:
diff --git a/Ports/python3/patches/http-client.patch b/Ports/python3/patches/http-client.patch
new file mode 100644
index 0000000000..baefdb8453
--- /dev/null
+++ b/Ports/python3/patches/http-client.patch
@@ -0,0 +1,24 @@
+--- Python-3.10/Lib/http/client.py 2021-09-07 21:18:28.000000000 +0800
++++ Python-3.10/Lib/http/client.py 2021-09-30 10:22:31.513921004 +0800
+@@ -70,6 +70,7 @@
+
+ import email.parser
+ import email.message
++import errno
+ import http
+ import io
+ import re
+@@ -939,7 +940,12 @@
+ sys.audit("http.client.connect", self, self.host, self.port)
+ self.sock = self._create_connection(
+ (self.host,self.port), self.timeout, self.source_address)
+- self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
++ # Might fail in OSs that don't implement TCP_NODELAY
++ try:
++ self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
++ except OSError as e:
++ if e.errno != errno.ENOPROTOOPT:
++ raise
+
+ if self._tunnel_host:
+ self._tunnel()