1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
From: Julien Legras from Synacktiv SAS <contact@synacktiv.com>
Subject: Fix broken Python 3 support
Origin: upstream, https://github.com/hypn0s/AJPy/commit/d374b722bae6007745a0e4425a6c72ca33622cf9
--- a/ajpy/ajp.py 2018-03-24 04:13:11.824023951 -0400
+++ b/ajpy/ajp.py 2018-04-14 11:51:05.664905895 -0400
@@ -37,7 +37,7 @@
return struct.pack(">h", -1)
l = len(s)
- return struct.pack(">H%dsb" % l, l, s, 0)
+ return struct.pack(">H%dsb" % l, l, s.encode('utf8'), 0)
def unpack(stream, fmt):
size = struct.calcsize(fmt)
@@ -71,8 +71,7 @@
if len(data) == 0:
return struct.pack(">bbH", 0x12, 0x34, 0x00)
else:
- res = ""
- res += struct.pack(">H", len(data))
+ res = struct.pack(">H", len(data))
res += data
if self.data_direction == AjpBodyRequest.SERVER_TO_CONTAINER:
@@ -172,7 +171,7 @@
self.num_headers = len(self.request_headers)
res = ""
- res += struct.pack(">h", self.num_headers)
+ res = struct.pack(">h", self.num_headers)
for h_name in self.request_headers:
if h_name.startswith("SC_REQ"):
code = AjpForwardRequest.COMMON_HEADERS.index(h_name) + 1
@@ -203,7 +202,7 @@
are_done 0xFF request_terminator
"""
- res = ""
+ res = b""
for attr in self.attributes:
a_name = attr['name']
@@ -222,7 +221,7 @@
def serialize(self):
res = ""
- res += struct.pack("bb", self.prefix_code, self.method)
+ res = struct.pack("bb", self.prefix_code, self.method)
res += pack_string(self.protocol)
res += pack_string(self.req_uri)
res += pack_string(self.remote_addr)
|