|
|
@@ -1,18 +1,13 @@
|
|
|
-# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
|
|
+# SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
#
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
import socket
|
|
|
+from http.client import HTTPConnection, HTTPSConnection
|
|
|
|
|
|
-from future.utils import tobytes
|
|
|
-
|
|
|
-try:
|
|
|
- from http.client import HTTPConnection, HTTPSConnection
|
|
|
-except ImportError:
|
|
|
- # Python 2 fallback
|
|
|
- from httplib import HTTPConnection, HTTPSConnection # type: ignore
|
|
|
+from utils import str_to_bytes
|
|
|
|
|
|
from .transport import Transport
|
|
|
|
|
|
@@ -36,8 +31,9 @@ class Transport_HTTP(Transport):
|
|
|
self.headers = {'Content-type': 'application/x-www-form-urlencoded','Accept': 'text/plain'}
|
|
|
|
|
|
def _send_post_request(self, path, data):
|
|
|
+ data = str_to_bytes(data) if isinstance(data, str) else data
|
|
|
try:
|
|
|
- self.conn.request('POST', path, tobytes(data), self.headers)
|
|
|
+ self.conn.request('POST', path, data, self.headers)
|
|
|
response = self.conn.getresponse()
|
|
|
# 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.
|