Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python-ecosys/aiohttp: fix header - case-insensitivity #972

Merged
merged 1 commit into from
Apr 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions python-ecosys/aiohttp/aiohttp/__init__.py
Original file line number Diff line number Diff line change
@@ -18,8 +18,14 @@ class ClientResponse:
def __init__(self, reader):
self.content = reader

def _get_header(self, keyname, default):
for k in self.headers:
if k.lower() == keyname:
return self.headers[k]
return default

def _decode(self, data):
c_encoding = self.headers.get("Content-Encoding")
c_encoding = self._get_header("content-encoding", None)
if c_encoding in ("gzip", "deflate", "gzip,deflate"):
try:
import deflate
@@ -39,10 +45,10 @@ async def read(self, sz=-1):
return self._decode(await self.content.read(sz))

async def text(self, encoding="utf-8"):
return (await self.read(int(self.headers.get("Content-Length", -1)))).decode(encoding)
return (await self.read(int(self._get_header("content-length", -1)))).decode(encoding)

async def json(self):
return _json.loads(await self.read(int(self.headers.get("Content-Length", -1))))
return _json.loads(await self.read(int(self._get_header("content-length", -1))))

def __repr__(self):
return "<ClientResponse %d %s>" % (self.status, self.headers)
2 changes: 1 addition & 1 deletion python-ecosys/aiohttp/manifest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
metadata(
description="HTTP client module for MicroPython asyncio module",
version="0.0.3",
version="0.0.4",
pypi="aiohttp",
)

Loading