Skip to content

Commit 220ca9d

Browse files
pablogventuradpgeorge
authored andcommitted
aiohttp: Match response header names case-insensitively.
Response header field names are case-insensitive (RFC 9110 Sec. 5.1), but ClientSession._request matched Transfer-Encoding and Location with fixed capitalization via startswith. Servers that send transfer-encoding: or location: would skip chunked detection or redirects. Fixes issue #1126. Signed-off-by: Pablo Ventura <pablogventura@gmail.com>
1 parent d8a719f commit 220ca9d

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

python-ecosys/aiohttp/aiohttp/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,11 @@ async def _request(self, method, url, data=None, json=None, ssl=None, params=Non
125125
if not line or line == b"\r\n":
126126
break
127127
_headers.append(line)
128-
if line.startswith(b"Transfer-Encoding:"):
128+
lowerl = line.lower()
129+
if lowerl.startswith(b"transfer-encoding:"):
129130
if b"chunked" in line:
130131
chunked = True
131-
elif line.startswith(b"Location:"):
132+
elif lowerl.startswith(b"location:"):
132133
url = line.rstrip().split(None, 1)[1].decode()
133134

134135
if 301 <= status <= 303:

python-ecosys/aiohttp/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
metadata(
22
description="HTTP client module for MicroPython asyncio module",
3-
version="0.0.7",
3+
version="0.0.8",
44
pypi="aiohttp",
55
)
66

0 commit comments

Comments
 (0)