Skip to content

Commit fb83623

Browse files
authored
Merge pull request #87 from makermelissa/content-headers
Added content-length header check
2 parents 161a881 + b018e95 commit fb83623

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

adafruit_pyportal.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,11 @@ def wget(self, url, filename, *, chunk_size=12000):
732732

733733
if self._debug:
734734
print(r.headers)
735-
content_length = int(r.headers["content-length"])
736-
remaining = content_length
735+
if "content-length" in r.headers:
736+
content_length = int(r.headers["content-length"])
737+
remaining = content_length
738+
else:
739+
raise RuntimeError("Content-length missing from headers")
737740
print("Saving data to ", filename)
738741
stamp = time.monotonic()
739742
file = open(filename, "wb")

0 commit comments

Comments
 (0)