Skip to content

Commit 8a87e1b

Browse files
author
brentru
committed
refactor per mcosti review
1 parent 18d5293 commit 8a87e1b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

adafruit_requests.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,11 @@ def request(method, url, data=None, json=None, headers=None, stream=False, timeo
224224
reason = ""
225225
if len(line) > 2:
226226
reason = line[2].rstrip()
227-
parse_headers(sock)
228-
229-
if line.startswith(b"Transfer-Encoding:"):
230-
if b"chunked" in line:
231-
raise ValueError("Unsupported " + line)
232-
elif line.startswith(b"Location:") and not 200 <= status <= 299:
227+
resp.headers = parse_headers(sock)
228+
if resp.headers.get("transfer-encoding"):
229+
if "chunked" in resp.headers.get("transfer-encoding"):
230+
raise ValueError("Unsupported " + str(line[0]))
231+
elif resp.headers.get("location") and not 200 <= status <= 299:
233232
raise NotImplementedError("Redirects not yet supported")
234233

235234
except:

0 commit comments

Comments
 (0)