Modules · Connectivity · Network
Network
HTTP and WebSocket clients. Network lets your program reach the web reactively: a request such as
Network.Web.Client.Get returns a
Network.Web.Response held in a STATE LOCKED
cell — pending until the reply arrives, then flowing through the rest of your program like any other
value. It covers the full range of HTTP methods, form posts, header and cookie handling, URL encoding, and
live WebSocket connections. Because every call is reactive, a response re-fetches whenever the URL or inputs
it reads change.
Contents
Types
Functions
- Network.Web.Client.Delete
- Network.Web.Client.Get
- Network.Web.Client.GetPolling
- Network.Web.Client.Head
- Network.Web.Client.Options
- Network.Web.Client.Patch
- Network.Web.Client.Post
- Network.Web.Client.PostForm
- Network.Web.Client.Put
- Network.Web.Cookie.FromHeaderString
- Network.Web.Cookie.OptionalValueByName
- Network.Web.Cookie.ToHeaderString
- Network.Web.Header.Emit
- Network.Web.Header.GatherArray
- Network.Web.Header.ValuesByName
- Network.Web.Response.Zero
- Network.Web.Url.EncodeString
- Network.Websocket.Client.Connection
Types
Network.Web.Cookie
A cookie as a name–value pair, parsed from or written to a Set-Cookie header.
Fields
| Field | Type | Description |
|---|---|---|
name | Text | The cookie's name. |
value | Text | The cookie's value. |
Definition
TYPE Network.Web.Cookie
FIELD Text name
FIELD Text valueExample
LET Network.Web.Cookie session = Network.Web.Cookie "session" tokenNetwork.Web.Header
A single HTTP header as a name–value pair.
Fields
| Field | Type | Description |
|---|---|---|
name | Text | The header field name. |
value | Text | The header field value. |
Definition
TYPE Network.Web.Header
FIELD Text name
FIELD Text valueExample
LET Network.Web.Header accept = Network.Web.Header "Accept" "application/json"Network.Web.Request
A prepared HTTP request: its URL, method, optional headers and body, and reactive reload state.
Fields
| Field | Type | Description |
|---|---|---|
url | Text | The target URL. |
method | Text | The HTTP method, such as GET or POST. |
optionalHeaders | Collection.Optional(Collection.Array(Network.Web.Header)) | Headers to send, if any. |
optionalBody | Collection.Optional(Text) | The request body, if any. |
reloadCount | Maths.Integer | How many times the request has reloaded. |
isPolling | Logic.Maybe | Yes when the request re-fetches on a timer. |
Definition
TYPE Network.Web.Request
FIELD Text url
FIELD Text method
FIELD Collection.Optional(Collection.Array(Network.Web.Header)) optionalHeaders
FIELD Collection.Optional(Text) optionalBody
FIELD Maths.Integer reloadCount
FIELD Logic.Maybe isPollingExample
LET Text target = request.urlNetwork.Web.Response
The result of an HTTP request: its status code, headers, and body. It is pending until the reply arrives, so it is usually held in a STATE LOCKED cell.
Fields
| Field | Type | Description |
|---|---|---|
statusCode | Maths.Integer | The HTTP status code, such as 200 or 404. |
headers | Collection.Array(Network.Web.Header) | The response headers. |
responseBody | Text | The response body text. |
Definition
TYPE Network.Web.Response
FIELD Maths.Integer statusCode
FIELD Collection.Array(Network.Web.Header) headers
FIELD Text responseBodyExample
STATE LOCKED Network.Web.Response response = Network.Web.Client.Get "https://api.example.com/data"Network.Web.Url
A parsed URL broken into its protocol, domain, port, path, and optional query and anchor.
Fields
| Field | Type | Description |
|---|---|---|
protocol | Text | The scheme, such as https. |
domain | Text | The host name. |
port | Maths.Integer | The port number. |
path | Text | The path portion of the URL. |
optionalQuery | Collection.Optional(Collection.Map(Text)) | The query parameters, if any. |
optionalAnchor | Collection.Optional(Text) | The fragment after #, if any. |
Definition
TYPE Network.Web.Url
FIELD Text protocol
FIELD Text domain
FIELD Maths.Integer port
FIELD Text path
FIELD Collection.Optional(Collection.Map(Text)) optionalQuery
FIELD Collection.Optional(Text) optionalAnchorExample
LET Text host = url.domainNetwork.Websocket.Message
A single message sent or received over a WebSocket connection.
Fields
| Field | Type | Description |
|---|---|---|
content | Text | The message text. |
Definition
TYPE Network.Websocket.Message
FIELD Text contentExample
LET Text text = message.contentFunctions
Network.Web.Client.Delete
Sends an HTTP DELETE request.
Parameters
| Name | Type | Description |
|---|---|---|
url | Text | The URL to delete. |
optionalHeaders | Collection.Optional(Collection.Array(Network.Web.Header)) | Extra request headers, if any. |
Returns
Returns Network.Web.Response — the pending response, locked until the reply arrives.
Network.Web.Client.Get
Fetches a URL with an HTTP GET request.
Parameters
| Name | Type | Description |
|---|---|---|
url | Text | The URL to fetch. |
optionalHeaders | Collection.Optional(Collection.Array(Network.Web.Header)) | Extra request headers, if any. |
Returns
Returns Network.Web.Response — the pending response, locked until the reply arrives.
Example
STATE LOCKED Network.Web.Response response = Network.Web.Client.Get "https://api.example.com/users"Network.Web.Client.GetPolling
Repeatedly fetches a URL on a fixed interval.
Parameters
| Name | Type | Description |
|---|---|---|
url | Text | The URL to poll. |
intervalMs | Maths.Integer | Milliseconds between fetches. |
optionalHeaders | Collection.Optional(Collection.Array(Network.Web.Header)) | Extra request headers, if any. |
Returns
Returns Network.Web.Response — the latest response, refreshed each interval.
Example
STATE LOCKED Network.Web.Response feed = Network.Web.Client.GetPolling "https://api.example.com/feed" 5000Network.Web.Client.Head
Sends an HTTP HEAD request, retrieving only the headers.
Parameters
| Name | Type | Description |
|---|---|---|
url | Text | The URL to query. |
optionalHeaders | Collection.Optional(Collection.Array(Network.Web.Header)) | Extra request headers, if any. |
Returns
Returns Network.Web.Response — the pending response, whose body is empty for a HEAD request.
Network.Web.Client.Options
Sends an HTTP OPTIONS request.
Parameters
| Name | Type | Description |
|---|---|---|
url | Text | The URL to query. |
optionalHeaders | Collection.Optional(Collection.Array(Network.Web.Header)) | Extra request headers, if any. |
Returns
Returns Network.Web.Response — the pending response describing the server's supported methods.
Network.Web.Client.Patch
Sends an HTTP PATCH request with an optional body.
Parameters
| Name | Type | Description |
|---|---|---|
url | Text | The URL to send to. |
optionalBody | Collection.Optional(Text) | The request body, if any. |
optionalHeaders | Collection.Optional(Collection.Array(Network.Web.Header)) | Extra request headers, if any. |
Returns
Returns Network.Web.Response — the pending response, locked until the reply arrives.
Network.Web.Client.Post
Sends an HTTP POST request with an optional body.
Parameters
| Name | Type | Description |
|---|---|---|
url | Text | The URL to post to. |
optionalBody | Collection.Optional(Text) | The request body, if any. |
optionalHeaders | Collection.Optional(Collection.Array(Network.Web.Header)) | Extra request headers, if any. |
Returns
Returns Network.Web.Response — the pending response, locked until the reply arrives.
Example
STATE LOCKED Network.Web.Response result = Network.Web.Client.Post "https://api.example.com/users" bodybody and holds the pending response.Network.Web.Client.PostForm
Posts URL-encoded form fields as an HTTP POST.
Parameters
| Name | Type | Description |
|---|---|---|
url | Text | The URL to post to. |
formFields | Collection.Map(Text) | The form field names and values. |
Returns
Returns Network.Web.Response — the pending response; the fields are sent as application/x-www-form-urlencoded.
Example
STATE LOCKED Network.Web.Response result = Network.Web.Client.PostForm "https://example.com/login" fieldsfields as a URL-encoded form.Network.Web.Client.Put
Sends an HTTP PUT request with an optional body.
Parameters
| Name | Type | Description |
|---|---|---|
url | Text | The URL to send to. |
optionalBody | Collection.Optional(Text) | The request body, if any. |
optionalHeaders | Collection.Optional(Collection.Array(Network.Web.Header)) | Extra request headers, if any. |
Returns
Returns Network.Web.Response — the pending response, locked until the reply arrives.
Network.Web.Cookie.FromHeaderString
Parses a Set-Cookie header value into a cookie.
Parameters
| Name | Type | Description |
|---|---|---|
headerString | Text | The raw Set-Cookie header value. |
Returns
Returns Network.Web.Cookie — the name and value parsed from the header.
Example
LET Network.Web.Cookie session = Network.Web.Cookie.FromHeaderString rawNetwork.Web.Cookie.OptionalValueByName
Finds the value of a named cookie among Set-Cookie header values.
Parameters
| Name | Type | Description |
|---|---|---|
setCookieValues | Collection.Array(Text) | The raw Set-Cookie header values. |
cookieName | Text | The cookie name to look up. |
Returns
Returns Collection.Optional(Text) — the matching cookie's value, or nothing when it is absent.
Network.Web.Cookie.ToHeaderString
Renders a cookie as a name=value header string.
Parameters
| Name | Type | Description |
|---|---|---|
cookie | Network.Web.Cookie | The cookie to render. |
Returns
Returns Text — the cookie as name=value.
Network.Web.Header.Emit
Emits one header into the enclosing GatherArray block.
Parameters
| Name | Type | Description |
|---|---|---|
name | Text | The header name. |
value | Text | The header value. |
Returns
Returns nothing — it adds one header to the surrounding Network.Web.Header.GatherArray.
Example
Network.Web.Header.Emit "Authorization" tokenNetwork.Web.Header.GatherArray
Collects the headers emitted in its block into an array.
Block
An indented block that calls Network.Web.Header.Emit once for each header to include.
Returns
Returns Collection.Array(Network.Web.Header) — every header emitted inside the block.
Example
LET Collection.Array(Network.Web.Header) headers = Network.Web.Header.GatherArray
Network.Web.Header.Emit "Content-Type" "application/json"
Network.Web.Header.Emit "Accept" "application/json"Network.Web.Header.ValuesByName
All values of headers matching a name, case-insensitively.
Parameters
| Name | Type | Description |
|---|---|---|
headers | Collection.Array(Network.Web.Header) | The headers to search. |
headerName | Text | The header name to match. |
Returns
Returns Collection.Array(Text) — every value whose header name matches, ignoring case.
Network.Web.Response.Zero
An empty response with status code zero and no body.
Returns
Returns Network.Web.Response — a blank response, useful as the initial value of a locked cell.
Example
LET Network.Web.Response empty = Network.Web.Response.ZeroNetwork.Web.Url.EncodeString
Percent-encodes text for safe use in a URL.
Parameters
| Name | Type | Description |
|---|---|---|
unencodedString | Text | The text to encode. |
Returns
Returns Text — the percent-encoded text.
Example
LET Text safe = Network.Web.Url.EncodeString queryquery for use in a URL.Network.Websocket.Client.Connection
Opens a live WebSocket connection over its scope.
Parameters
| Name | Type | Description |
|---|---|---|
receivedMessages | Collection.Array(Network.Websocket.Message) | A state cell filled with incoming messages. |
sendMessages | Collection.Array(Network.Websocket.Message) | Messages to send over the connection. |
address | Text | The WebSocket URL, such as wss://… |
Returns
Returns nothing — it keeps the connection open while in scope, publishing incoming messages into receivedMessages.
Example
Network.Websocket.Client.Connection received outgoing "wss://chat.example.com"received with incoming messages.