feat(urllib.request): add compression support for PkgHandler

This commit is contained in:
Tiara Rodney 2025-06-21 20:26:36 +02:00
parent 981985e51a
commit 2d9fe8b625
No known key found for this signature in database
GPG key ID: 5F43FAB4FBE5B5EB

View file

@ -22,7 +22,10 @@ class PkgHandler(urllib.request.BaseHandler):
size = fh.tell();
fh.seek(0);
mtype, _ = mimetypes.guess_type(req.selector)
mtype, compression = mimetypes.guess_type(req.selector)
if compression and mtype:
mtype = f"{mtype}+{compression}"
headers = email.message_from_string(
'Content-Type: %s\nContent-Length: %d\n' %