Skip to content
Merged
Changes from 2 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
24 changes: 7 additions & 17 deletions adafruit_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,13 @@ def request(method, url, data=None, json=None, headers=None, stream=False, timeo
reason = ""
if len(line) > 2:
reason = line[2].rstrip()
while True:
line = sock.readline()
if not line or line == b"\r\n":
break

# print("**line: ", line)
title, content = line.split(b": ", 1)
if title and content:
title = str(title.lower(), "utf-8")
content = str(content, "utf-8")
resp.headers[title] = content

if line.startswith(b"Transfer-Encoding:"):
if b"chunked" in line:
raise ValueError("Unsupported " + line)
elif line.startswith(b"Location:") and not 200 <= status <= 299:
raise NotImplementedError("Redirects not yet supported")
parse_headers(sock)

if line.startswith(b"Transfer-Encoding:"):
if b"chunked" in line:
raise ValueError("Unsupported " + line)
elif line.startswith(b"Location:") and not 200 <= status <= 299:
raise NotImplementedError("Redirects not yet supported")

except:
sock.close()
Expand Down