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 |
Handle async requests. |
| Instance Variable | chunk |
Undocumented |
| Instance Variable | error |
Undocumented |
| Instance Variable | timeout |
Undocumented |
| Instance Variable | uart |
Undocumented |
| Property | response |
Get the latest HTTP response received from the UART. |
| Method | __send |
Send a command to the UART and wait for a response. |
| Instance Variable | _response |
Undocumented |
Initialize the HTTP class.
| Parameters | |
uart:UART | The UART instance. Defaults to None. |
chunkint | Transfer chunk size in bytes. Defaults to 4096. |
timeoutint | The timeout for UART receiving in milliseconds. Defaults to 5000. |
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:str | HTTP method (GET, POST, etc.). |
url:str | URL to request. |
data:str or bytes | Request body data. Defaults to None. |
jsondict | JSON data to send (will be serialized). Defaults to None. |
headers:dict | HTTP headers dict. Defaults to None. |
auth:tuple | Authentication tuple (username, password). Defaults to None. |
timeout:float | Request timeout in seconds. Defaults to None. |
parsebool or callable | Whether to parse response headers. Defaults to True. |
uart:UART | UART object for streaming output. Defaults to None. |
savestr | File path to save response data to (requires storage). Defaults to None. |
storage:Storage | Storage object for file operations. Defaults to None. |
sendstr | File path to send as request body (requires storage). Defaults to None. |
| Returns | |
Response | The 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:str | HTTP method (GET, POST, etc.). |
url:str | URL to request. |
payload:str, bytes, or dict | Request payload. Defaults to None. |
headers:dict | HTTP headers dict. Defaults to None. |
timeout:float | Request timeout in seconds. Defaults to 10.0. |
savestr | File path to save response data to (requires storage). Defaults to None. |
storage:Storage | Storage object for file operations. Defaults to None. |
sendstr | File path to send as request payload (requires storage). Defaults to None. |
stackint | Undocumented |
| Returns | |
bool | True if the request was started. |
Get the latest HTTP response received from the UART.
| Returns | |
Response | The latest HTTP response received from the UART. |