Header field names are case-insensitive (RFC 9110 Sec. 5.1), so this code may break with some servers:
if line.startswith(b"Transfer-Encoding:"):
if b"chunked" in line:
chunked = True
elif line.startswith(b"Location:"):
url = line.rstrip().split(None, 1)[1].decode()
Header field names are case-insensitive (RFC 9110 Sec. 5.1), so this code may break with some servers: