HTTP Client Classes
SIMPLE_WEB_CLIENT
Primary HTTP client for making web requests.
| Feature | Signature | Description |
|---|---|---|
make |
|
Initialize HTTP client. |
get |
(a_url: STRING): SIMPLE_WEB_RESPONSE |
Execute GET request. |
post |
(a_url, a_body: STRING): SIMPLE_WEB_RESPONSE |
Execute POST with body. |
post_json |
(a_url, a_json: STRING): SIMPLE_WEB_RESPONSE |
Execute POST with JSON body (sets Content-Type). |
put |
(a_url, a_body: STRING): SIMPLE_WEB_RESPONSE |
Execute PUT request. |
delete |
(a_url: STRING): SIMPLE_WEB_RESPONSE |
Execute DELETE request. |
execute |
(a_request: SIMPLE_WEB_REQUEST): SIMPLE_WEB_RESPONSE |
Execute custom request. |
SIMPLE_WEB_HYBRID_CLIENT
HTTP client that uses curl.exe process for localhost POST requests (workaround for libcurl issue).
Same API as SIMPLE_WEB_CLIENT.
SIMPLE_WEB_REQUEST
Fluent request builder.
| Feature | Signature | Description |
|---|---|---|
make_get |
(a_url: STRING) |
Create GET request. |
make_post |
(a_url: STRING) |
Create POST request. |
make_put |
(a_url: STRING) |
Create PUT request. |
make_delete |
(a_url: STRING) |
Create DELETE request. |
with_body |
(a_body: STRING): like Current |
Set request body. |
with_json_body |
(a_json: STRING): like Current |
Set JSON body (sets Content-Type). |
with_header |
(a_name, a_value: STRING): like Current |
Add custom header. |
with_bearer_token |
(a_token: STRING): like Current |
Add Bearer authorization. |
with_basic_auth |
(a_user, a_pass: STRING): like Current |
Add Basic authorization. |
with_api_key |
(a_key: STRING): like Current |
Add X-API-Key header. |
with_timeout |
(a_ms: INTEGER): like Current |
Set timeout in milliseconds. |
SIMPLE_WEB_RESPONSE
HTTP response wrapper.
| Feature | Signature | Description |
|---|---|---|
status_code |
: INTEGER |
HTTP status code. |
body |
: STRING |
Response body. |
is_success |
: BOOLEAN |
Is status 2xx? |
is_client_error |
: BOOLEAN |
Is status 4xx? |
is_server_error |
: BOOLEAN |
Is status 5xx? |
header |
(a_name: STRING): detachable STRING |
Get response header. |
has_header |
(a_name: STRING): BOOLEAN |
Check if header exists. |
AI Client Classes
SIMPLE_WEB_OLLAMA_CLIENT
Client for local Ollama API.
| Feature | Signature | Description |
|---|---|---|
make |
|
Create client (localhost:11434). |
make_with_host |
(a_host: STRING) |
Create client with custom host. |
generate |
(a_model, a_prompt: STRING): SIMPLE_WEB_RESPONSE |
Generate completion. |
chat |
(a_model: STRING; a_messages: ARRAY [TUPLE [role, content: STRING]]): SIMPLE_WEB_RESPONSE |
Chat conversation. |
list_models |
: SIMPLE_WEB_RESPONSE |
List available models. |
pull |
(a_model: STRING): SIMPLE_WEB_RESPONSE |
Pull/download model. |
embeddings |
(a_model, a_prompt: STRING): SIMPLE_WEB_RESPONSE |
Generate embeddings. |
SIMPLE_WEB_CLAUDE_CLIENT
Client for Anthropic Claude API.
| Feature | Signature | Description |
|---|---|---|
make |
(a_api_key: STRING) |
Create client with API key. |
message |
(a_model, a_prompt: STRING): SIMPLE_WEB_RESPONSE |
Send message. |
message_with_system |
(a_model, a_system, a_prompt: STRING): SIMPLE_WEB_RESPONSE |
Send message with system prompt. |
SIMPLE_WEB_OPENAI_CLIENT
Client for OpenAI API.
| Feature | Signature | Description |
|---|---|---|
make |
(a_api_key: STRING) |
Create client with API key. |
chat |
(a_model: STRING; a_messages: ARRAY [TUPLE [role, content: STRING]]): SIMPLE_WEB_RESPONSE |
Chat completion. |
completion |
(a_model, a_prompt: STRING): SIMPLE_WEB_RESPONSE |
Text completion. |
SIMPLE_WEB_GROK_CLIENT
Client for xAI Grok API.
| Feature | Signature | Description |
|---|---|---|
make |
(a_api_key: STRING) |
Create client with API key. |
chat |
(a_model: STRING; a_messages: ARRAY [TUPLE [role, content: STRING]]): SIMPLE_WEB_RESPONSE |
Chat completion. |
HTTP Server Classes
SIMPLE_WEB_SERVER
HTTP server with clean routing API.
| Feature | Signature | Description |
|---|---|---|
make |
(a_port: INTEGER) |
Create server on port. |
on_get |
(a_pattern: STRING; a_handler: PROCEDURE [...]) |
Register GET handler. |
on_post |
(a_pattern: STRING; a_handler: PROCEDURE [...]) |
Register POST handler. |
on_put |
(a_pattern: STRING; a_handler: PROCEDURE [...]) |
Register PUT handler. |
on_delete |
(a_pattern: STRING; a_handler: PROCEDURE [...]) |
Register DELETE handler. |
on_patch |
(a_pattern: STRING; a_handler: PROCEDURE [...]) |
Register PATCH handler. |
use |
(a_middleware: SIMPLE_WEB_MIDDLEWARE) |
Add middleware. |
start |
|
Start server (blocking). |
port |
: INTEGER |
Server port. |
SIMPLE_WEB_SERVER_REQUEST
Server request wrapper.
| Feature | Signature | Description |
|---|---|---|
method |
: STRING |
HTTP method (GET, POST, etc). |
path |
: STRING |
Request path. |
body |
: STRING |
Request body. |
path_parameter |
(a_name: STRING): detachable STRING |
Get path parameter ({id}). |
query_parameter |
(a_name: STRING): detachable STRING |
Get query parameter (?name=value). |
header |
(a_name: STRING): detachable STRING |
Get request header. |
has_header |
(a_name: STRING): BOOLEAN |
Check if header exists. |
SIMPLE_WEB_SERVER_RESPONSE
Server response builder.
| Feature | Signature | Description |
|---|---|---|
set_status |
(a_code: INTEGER) |
Set HTTP status code. |
set_header |
(a_name, a_value: STRING) |
Set response header. |
send_text |
(a_text: STRING) |
Send plain text response. |
send_json |
(a_json: STRING) |
Send JSON response. |
send_json_object |
(a_obj: SIMPLE_JSON_OBJECT) |
Send JSON object. |
send_html |
(a_html: STRING) |
Send HTML response. |
send_file |
(a_path: STRING) |
Send file contents. |
redirect |
(a_url: STRING) |
Redirect to URL (302). |
Middleware Classes
SIMPLE_WEB_MIDDLEWARE (deferred)
Base class for middleware.
| Feature | Signature | Description |
|---|---|---|
process |
(req: ...; res: ...): BOOLEAN |
Process request. Return True to continue. |
SIMPLE_WEB_LOGGING_MIDDLEWARE
Logs all requests.
SIMPLE_WEB_CORS_MIDDLEWARE
CORS header handling.
| Feature | Signature | Description |
|---|---|---|
make |
|
Allow all origins (*). |
make_with_origins |
(a_origins: ARRAY [STRING]) |
Allow specific origins. |
SIMPLE_WEB_AUTH_MIDDLEWARE
Authentication middleware.
| Feature | Signature | Description |
|---|---|---|
make_bearer |
(a_secret: STRING) |
Bearer token auth. |
make_basic |
(a_user, a_pass: STRING) |
Basic auth. |
make_api_key |
(a_key: STRING) |
API key auth (X-API-Key header). |
Security Classes
SIMPLE_WEB_INPUT_SANITIZER
Input sanitization utilities.
| Feature | Signature | Description |
|---|---|---|
escape_html |
(a_input: STRING): STRING |
Escape HTML special characters. |
is_safe_path |
(a_path: STRING): BOOLEAN |
Check for path traversal. |
sanitize_path |
(a_path: STRING): STRING |
Remove dangerous path elements. |
sanitize_header |
(a_value: STRING): STRING |
Remove header injection chars. |
escape_sql |
(a_value: STRING): STRING |
Basic SQL escaping (prefer parameterized queries). |
Constants
HTTP Status Codes
From SIMPLE_WEB_CONSTANTS:
| Constant | Value |
|---|---|
Http_ok | 200 |
Http_created | 201 |
Http_no_content | 204 |
Http_bad_request | 400 |
Http_unauthorized | 401 |
Http_forbidden | 403 |
Http_not_found | 404 |
Http_internal_error | 500 |
Content Types
| Constant | Value |
|---|---|
Content_type_json | "application/json" |
Content_type_html | "text/html" |
Content_type_text | "text/plain" |
Content_type_form | "application/x-www-form-urlencoded" |