Skip to content

Commit e6ae18a

Browse files
committed
Enhanced internet connection checks by falling back to HTTPS protocol when HTTP (port 80) fails // Resolve platformio#4980
1 parent 4230b22 commit e6ae18a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ test-driven methodologies, and modern toolchains for unrivaled success.
2222
~~~~~~~~~~~~~~~~~~~
2323

2424
* Introduced the `PLATFORMIO_SYSTEM_TYPE <https://docs.platformio.org/en/latest/envvars.html#envvar-PLATFORMIO_SYSTEM_TYPE>`__ environment variable, enabling manual override of the detected system type for greater flexibility and control in custom build environments
25+
* Enhanced internet connection checks by falling back to HTTPS protocol when HTTP (port 80) fails (`issue #4980 <https://github.com/platformio/platformio-core/issues/4980>`_)
2526
* Upgraded the build engine to the latest version of SCons (4.8.1) to improve build performance, reliability, and compatibility with other tools and systems (`release notes <https://github.com/SCons/scons/releases/tag/4.8.1>`__)
2627
* Upgraded the `Doctest <https://docs.platformio.org/en/latest/advanced/unit-testing/frameworks/doctest.html>`__ testing framework to version 2.4.11, the `GoogleTest <https://docs.platformio.org/en/latest/advanced/unit-testing/frameworks/doctest.html>`__ to version 1.15.2, and the `Unity <https://docs.platformio.org/en/latest/advanced/unit-testing/frameworks/unity.html>`__ to version 2.6.0, incorporating the latest features and improvements for enhanced testing capabilities
2728
* Corrected an issue where the incorrect public class was imported for the ``DoctestTestRunner`` (`issue #4949 <https://github.com/platformio/platformio-core/issues/4949>`_)

platformio/http.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ def _parse_json_response(response, expected_codes=(200, 201, 202)):
190190
@util.memoized(expire="10s")
191191
def _internet_on():
192192
timeout = 2
193+
use_proxy = is_proxy_set()
193194
socket.setdefaulttimeout(timeout)
194195
for host in __check_internet_hosts__:
195196
try:
196-
if is_proxy_set():
197+
if use_proxy:
197198
requests.get("http://%s" % host, allow_redirects=False, timeout=timeout)
198199
return True
199200
# try to resolve `host` for both AF_INET and AF_INET6, and then try to connect
@@ -203,6 +204,15 @@ def _internet_on():
203204
return True
204205
except: # pylint: disable=bare-except
205206
pass
207+
208+
# falling back to HTTPs, issue #4980
209+
for host in __check_internet_hosts__:
210+
try:
211+
requests.get("https://%s" % host, allow_redirects=False, timeout=timeout)
212+
except requests.exceptions.RequestException:
213+
pass
214+
return True
215+
206216
return False
207217

208218

0 commit comments

Comments
 (0)