Skip to content

net (Network)

Status: Planned for 0.9. The net module is not yet available in the current release. This page describes the planned API.

The net module will provide HTTP client functionality and basic socket communication. It will require --allow net at runtime.

Sends an HTTP GET request and returns the response body as a string.

import { httpGet } from net;
int main() {
string body = httpGet("https://example.com");
print(body);
return 0;
}

Sends an HTTP POST request with a body and returns the response.

import { httpPost } from net;
int main() {
string resp = httpPost("https://example.com/api", "{\"key\":\"value\"}");
print(resp);
return 0;
}

All net functions require --allow net:

Terminal window
saqut run --allow net program.sqt

The net capability is separate from fs and sys. A program that only reads files and makes HTTP requests would run with:

Terminal window
saqut run --allow fs,net program.sqt

The net module is planned for version 0.9. Track progress on GitHub Issues.