Skip to content

Commit 1bd91aa

Browse files
committed
Fix Issue corpetty#5
Added a check for a http response that has a status code of 200 but is completely empty. This will prevent the function json.loads() from being excuted with an empty string. Issue source: corpetty#5
1 parent 1901a47 commit 1bd91aa

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

etherscan/client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ def connect(self):
4747
except requests.exceptions.ConnectionError:
4848
return "Connection refused"
4949
if req.status_code == 200:
50-
return json.loads(req.text)
50+
# Check for empty response
51+
if req.text:
52+
return json.loads(req.text)
53+
else:
54+
print("Invalid Request")
55+
exit()
5156
else:
5257
print("problem with connection, status code: ", req.status_code)
5358
exit()

0 commit comments

Comments
 (0)