From 12e4318de7087b41c811fc8589ef789ab9250c6e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 28 Dec 2017 17:15:34 +0200 Subject: [PATCH] Don't follow redirects when checking internet connection --- platformio/util.py | 3 ++- tests/test_misc.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/platformio/util.py b/platformio/util.py index 410bcff7..a040380f 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -669,7 +669,8 @@ def _internet_on(): for ip in PING_INTERNET_IPS: try: if os.getenv("HTTP_PROXY", os.getenv("HTTPS_PROXY")): - requests.get("http://%s" % ip, timeout=timeout) + requests.get( + "http://%s" % ip, allow_redirects=False, timeout=timeout) else: socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((ip, 80)) diff --git a/tests/test_misc.py b/tests/test_misc.py index 5d569b5b..e8121c99 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -19,4 +19,4 @@ from platformio import util def test_ping_internet_ips(): for ip in util.PING_INTERNET_IPS: - requests.get("http://%s" % ip, timeout=2) + requests.get("http://%s" % ip, allow_redirects=False, timeout=2)