0x02 - Fetch 🧪
Do an HTTPS request to specified URL.
SSE is expected to be implemented as an abstraction over this API (rather than be provided as its own portal).
Connection
Host device channel is opened upon readiness (allocated only if successful).
The channel allocation should happen immediately upon return of ar(), and must
follow in the order of the ready list.
Readiness
Becomes ready once either
- The resource host can't be reached (network error),
capacityset to 0. - The resource host hung up,
capacityset to 0. - The resource host has sent back a chunk of the resource (a new device
channel has been opened)
- Buffer is not big enough,
bufferoverwritten up tocapacitybytes, andcapacitymodified how many more bytes are required - Buffer is big enough,
bufferoverwritten,capacityunchanged.
- Buffer is not big enough,
Command: Fetch
Fields
url: Text- URL to do an HTTPS request to (does not includehttps://protocol)headers: Text- Extra headers to send (separated by\n)body: opt[List[byte]]- Optional payload/content body to sendmethod: int- 0: GET, 1: HEAD, 2: POST, 3: PUT, 4: DELETE.capacity: ptr[int]- (In/Out) Pointer to capacity ofbuffer.buffer: ptr[List[byte]]- (In/Out) Pointer to buffer for receiving parts of the HTTP response.
Traps
- If
urldoes not start with one of- Domain name lowercase (ranged a~z or 0~9,
-and.allowed after first character, but not consecutively, and not last character before termination character - one of:/?) - IPv4 Address - 4 integers ranged 0:255 each separated by
.) - Ipv6 Address -
[, then 8 lowercase hexaxecimal numbers from 1 to 4 digits separated by:, and]. A grouping of consecutive zero numbers can be replaced with::, rather than requiring all 8 numbers.
- Domain name lowercase (ranged a~z or 0~9,
- If
urlafter domain/IP doesn't either start with one of:/?or end - If
urlsections:/?are out of order - If
urlport after:is not in range 0~65535 - If
urlpath after/is nota~z,A~Z,-,_,%,.,~,+, or/ - If
urlquery after?is nota~z,A~Z,0~9,-,_.,~,+,=,;, or& - If
headersbegins with\nor ends with\n - If
headersline does not matchTitle-Kebab-Case: expected-type(no\rallowed) - If
headersline contains an invalid (LikeNot-A-Header), redudant (LikeContent-Length), or insecure (Also likeContent-Length)header - If input
capacityis less thanbuffer.size - If address at (input)
buffer.addr + body.capacityhas no page - If address at
body.addr + body.sizehas no page - If address at
url.addr + url.sizehas no page - If address at
headers.addr + headers.sizehas no page - If address at
body + 3has no page - If address at
capacity + 3has no page - If address at
buffer + 3has no page