Skip to content

Commit

Permalink
Merge branch 'fix/esp_prov_ipv6_resolve_v5_4' into 'release/v5.4'
Browse files Browse the repository at this point in the history
fix(tools/esp_prov): Fix hostname resolving for IPv6-only host(v5.4)

See merge request espressif/esp-idf!34679
  • Loading branch information
chshu committed Nov 7, 2024
2 parents 367059b + 2980c7f commit 343bb81
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tools/esp_prov/transport/transport_http.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
import socket
from http.client import HTTPConnection, HTTPSConnection
from http.client import HTTPConnection
from http.client import HTTPSConnection

from utils import str_to_bytes

Expand All @@ -12,7 +13,7 @@
class Transport_HTTP(Transport):
def __init__(self, hostname, ssl_context=None):
try:
socket.gethostbyname(hostname.split(':')[0])
socket.getaddrinfo(hostname.split(':')[0], None)
except socket.gaierror:
raise RuntimeError(f'Unable to resolve hostname: {hostname}')

Expand All @@ -35,7 +36,7 @@ def _send_post_request(self, path, data):
# While establishing a session, the device sends the Set-Cookie header
# with value 'session=cookie_session_id' in its first response of the session to the tool.
# To maintain the same session, successive requests from the tool should include
# an additional 'Cookie' header with the above recieved value.
# an additional 'Cookie' header with the above received value.
for hdr_key, hdr_val in response.getheaders():
if hdr_key == 'Set-Cookie':
self.headers['Cookie'] = hdr_val
Expand Down

0 comments on commit 343bb81

Please sign in to comment.