class documentation

HTTPUART - Handle HTTP requests over UART.

Method __init__ Initialize the HTTP class.
Method close Close the UART connection.
Method ping Check for pong response
Method request Make an HTTP request.
Method request_async Handle async requests.
Instance Variable chunk_size Undocumented
Instance Variable error Undocumented
Instance Variable timeout_ms Undocumented
Instance Variable uart Undocumented
Property response Get the latest HTTP response received from the UART.
Method __send_and_wait Send a command to the UART and wait for a response.
Instance Variable _response Undocumented
def __init__(self, uart=None, chunk_size: int = 1024 * 4, timeout_ms: int = 5000):

Initialize the HTTP class.

Parameters
uart:UARTThe UART instance. Defaults to None.
chunk_size:intTransfer chunk size in bytes. Defaults to 4096.
timeout_ms:intThe timeout for UART receiving in milliseconds. Defaults to 5000.
def close(self):

Close the UART connection.

def ping(self) -> bool:

Check for pong response

def request(self, method, url, data=None, json_data=None, headers=None, auth=None, timeout=None, parse_headers=True, uart=None, save_to_file=None, storage=None, send_file=None) -> Response:

Make an HTTP request.

Parameters
method:strHTTP method (GET, POST, etc.).
url:strURL to request.
data:str or bytesRequest body data. Defaults to None.
json_data:dictJSON data to send (will be serialized). Defaults to None.
headers:dictHTTP headers dict. Defaults to None.
auth:tupleAuthentication tuple (username, password). Defaults to None.
timeout:floatRequest timeout in seconds. Defaults to None.
parse_headers:bool or callableWhether to parse response headers. Defaults to True.
uart:UARTUART object for streaming output. Defaults to None.
save_to_file:strFile path to save response data to (requires storage). Defaults to None.
storage:StorageStorage object for file operations. Defaults to None.
send_file:strFile path to send as request body (requires storage). Defaults to None.
Returns
ResponseThe HTTP response.
def request_async(self, method, url, payload=None, headers=None, timeout: float = 10.0, save_to_file=None, storage=None, send_file=None, stack_size: int = 8 * 1024) -> bool:

Handle async requests.

Parameters
method:strHTTP method (GET, POST, etc.).
url:strURL to request.
payload:str, bytes, or dictRequest payload. Defaults to None.
headers:dictHTTP headers dict. Defaults to None.
timeout:floatRequest timeout in seconds. Defaults to 10.0.
save_to_file:strFile path to save response data to (requires storage). Defaults to None.
storage:StorageStorage object for file operations. Defaults to None.
send_file:strFile path to send as request payload (requires storage). Defaults to None.
stack_size:intUndocumented
Returns
boolTrue if the request was started.
chunk_size =

Undocumented

error =

Undocumented

timeout_ms =

Undocumented

uart =

Undocumented

@property
response: Response =

Get the latest HTTP response received from the UART.

Returns
ResponseThe latest HTTP response received from the UART.
def __send_and_wait(self, command, add_newline: bool = True) -> str:

Send a command to the UART and wait for a response.

Parameters
command:str/bytesThe command to send.
add_newline:boolUndocumented
Returns
strThe response from the UART.
_response =

Undocumented