v2026.5.3
All Bundles
Bundle Lightweight embedded web server. Handles inbound HTTP requests with typed access to method, path, headers, and body; Response supports content-type, compression, redirects, and cookies. Compile with -lib net_server.

Response

Web Response

Operations

ClearAll #

Clears the entire body response

method : public : ClearAll() ~ Nil

Example

response->WriteBody("draft content");
response->ClearAll();              # discard draft
response->WriteBody("final content");

Redirect #

Redirects a quary URL

method : public : Redirect(url:String) ~ Bool

Parameters

NameTypeDescription
urlStringURL redirect

Return

TypeDescription
Boolnumber of bytes sent

Example

# redirect to a new URL
response->Redirect("https://example.com/new-path");

RemoveHeader #

Removes a HTTP header

method : public : RemoveHeader(name:String) ~ Bool

Parameters

NameTypeDescription
nameStringheader name

Return

TypeDescription
Booltrue successful, false otherwise

Example

response->SetHeader("X-Debug", "1");
response->RemoveHeader("X-Debug");  # strip before sending
response->WriteBody("Done");

SetContentType #

Set the content type

method : public : SetContentType(type:String) ~ Nil

Parameters

NameTypeDescription
typeStringcontent type

Example

response->SetContentType("application/json");
response->WriteBody("{\"status\":\"ok\"}");

SetHeader #

Sets a HTTP header

method : public : SetHeader(name:String, value:String) ~ Bool

Parameters

NameTypeDescription
nameStringheader name
valueStringheader value

Return

TypeDescription
Booltrue successful, false otherwise

Example

response->SetHeader("Cache-Control", "no-cache");
response->SetHeader("X-Custom-Header", "my-value");
response->WriteBody("OK");

WriteBody #

Writes a string response to the message body

method : public : WriteBody(data:String) ~ Int

Parameters

NameTypeDescription
dataStringstring response

Return

TypeDescription
Intnumber of bytes sent

Example

response->SetContentType("text/html");
bytes_sent := response->WriteBody("<html><body>Hello</body></html>");
bytes_sent->PrintLine();  # number of bytes written

WriteBody #

Writes a byte array response to the message body

method : public : WriteBody(data:Byte[]) ~ Int

Parameters

NameTypeDescription
dataBytebyte array response

Return

TypeDescription
Intnumber of bytes sent

Example

img_bytes := System.IO.Filesystem.FileReader->ReadBinaryFile("logo.png");
response->SetContentType("image/png");
response->WriteBody(img_bytes);