Class HttpClient
WiFiS3 library's WiFiClient. Requires @Board(ArduinoUnoR4WiFi.class)
(the default board) and an active Wifi.begin(String, String) connection.
host/path (and body for post(String, int, String, String, byte[], int, byte[], int, int[]), patch(String, int, String, String, byte[], int, byte[], int, int[]), and
query(String, int, String, String, byte[], int, byte[], int, int[])) must each be a compile-time
constant: either a string literal, or System.getenv("NAME") of a literal
environment-variable name, exactly like Wifi.begin(String, String)'s credentials. Juno has no heap, so
none of these can be a runtime-computed String — this also means these methods must be
called directly with the literal in hand, never forwarded through another method's own
String parameter.
The response body is written into bodyBuffer and the raw response headers into
headersBuffer (both caller-owned, fixed-size byte[]), each starting at index 0
and truncated to its own length if longer — pass each buffer's own array length explicitly,
since Juno has no runtime .length for an array method parameter. Each method returns the
number of body bytes written, or -1 if the connection failed. statusAndHeadersLength
(a caller-owned int[2], allocated once outside any loop like the buffers themselves) is
filled with the HTTP status code at index 0 (or 0 if the connection failed before a
status line was received) and the number of bytes written into headersBuffer at index 1.
A request that doesn't complete within a fixed 5-second timeout is abandoned and returns
whatever was captured so far.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intA reasonable default size for a caller's body/headers buffer, in bytes. -
Method Summary
Modifier and TypeMethodDescriptionstatic intdelete(String host, int port, String path, byte[] bodyBuffer, int bodyBufferLength, byte[] headersBuffer, int headersBufferLength, int[] statusAndHeadersLength) Sends a bodyless HTTP DELETE request.static intget(String host, int port, String path, byte[] bodyBuffer, int bodyBufferLength, byte[] headersBuffer, int headersBufferLength, int[] statusAndHeadersLength) static intpatch(String host, int port, String path, String body, byte[] bodyBuffer, int bodyBufferLength, byte[] headersBuffer, int headersBufferLength, int[] statusAndHeadersLength) Sends an HTTP PATCH request with a compile-time JSON body.static intpost(String host, int port, String path, String body, byte[] bodyBuffer, int bodyBufferLength, byte[] headersBuffer, int headersBufferLength, int[] statusAndHeadersLength) static intquery(String host, int port, String path, String body, byte[] bodyBuffer, int bodyBufferLength, byte[] headersBuffer, int headersBufferLength, int[] statusAndHeadersLength) Sends a safe, idempotent HTTP QUERY request with a compile-time JSON body, as defined by RFC 10008.
-
Field Details
-
DEFAULT_RESPONSE_BUFFER_SIZE
public static final int DEFAULT_RESPONSE_BUFFER_SIZEA reasonable default size for a caller's body/headers buffer, in bytes.- See Also:
-
-
Method Details
-
get
-
post
-
delete
-
patch
-
query
-