-
-
Notifications
You must be signed in to change notification settings - Fork 2
Tuku
Tuku is a command-line HTTP/HTTPS client for Tiri workflows. It provides a curl-like feature set using Origo-style name=value arguments, built on the Kotuku HTTP class. Tuku is designed for scripting, automation, and quick manual requests from the terminal.
origo apps/tuku.tiri url=https://example.com
Defaults and Implicit Behaviour
Tuku is executed through Origo like any Tiri application. The minimal invocation fetches a URL and prints the response body to standard output:
origo apps/tuku.tiri url=https://example.com
To save the response body to a file:
origo apps/tuku.tiri url=https://example.com output=page.html
To send a POST request with a JSON body:
origo apps/tuku.tiri url=https://api.example.com/items method=post json='{"name":"Ada"}'
To check only the HTTP status code:
origo apps/tuku.tiri url=https://example.com status
Run origo apps/tuku.tiri help to see the full option table with descriptions.
| Option | Type | Description |
|---|---|---|
url |
string | Target HTTP or HTTPS URL. Required unless version or help is used. |
method |
enum | HTTP method: get, head, delete, options, post, put, or patch. Default: get. |
version |
flag | Print the Tuku version and exit. |
help |
flag | Print usage information and exit. |
| Option | Type | Description |
|---|---|---|
output |
file | Save the response body to a file instead of standard output. |
status |
flag | Print the numeric HTTP status code to standard output. |
headers |
flag | Print all response headers as tuku: header key=value lines. |
include |
flag | Print response headers before the response body. Alias: with-headers. |
silent |
flag | Suppress non-body output. |
verbose |
flag | Print a structured transfer summary after the request completes. |
fail |
flag | Treat HTTP 4xx and 5xx statuses as failures, raising ERR_Failed. |
Only one body option may be used per request. Providing any body option implies method=post unless method is set explicitly.
| Option | Type | Description |
|---|---|---|
data |
string | Send a string as the request body. |
datafile |
file | Read the request body from a file. |
json |
string | Send a JSON string as the request body. Implies contenttype=application/json. |
form |
array | Send form fields as name=value entries. Implies contenttype=application/x-www-form-urlencoded. |
multipart |
array | Send multipart form fields as name=value or file fields as name=@path. Implies a multipart/form-data content type with a generated boundary. |
contenttype |
string | Explicitly set the Content-Type request header, overriding implicit defaults. |
| Option | Type | Description |
|---|---|---|
header |
array | Custom request headers in Name: Value form. |
useragent |
string | User-Agent request header. Default: Tuku/1.0 Kotuku. |
user |
string | Authentication credentials as username:password. |
| Option | Type | Default | Description |
|---|---|---|---|
timeout |
number | 30 | Overall transfer timeout in seconds. |
connect-timeout |
number | 10 | Initial connection timeout in seconds. |
data-timeout |
number | 30 | Send/receive data timeout in seconds. |
proxy |
string | Proxy server as host:port. |
|
insecure |
flag | Disable SSL server certificate verification. |
| Option | Type | Description |
|---|---|---|
resume |
flag | Resume a partial download. Requires output and method=get. |
raw |
flag | Disable HTTP chunk handling. |
no-head |
flag | Do not send a HEAD probe before upload methods. |
follow |
flag | Follow HTTP redirects. |
max-redirects |
integer | Maximum redirects to follow when follow is set. Default: 10. |
debug-socket |
flag | Log request socket headers and data. |
Tuku applies the following defaults when options are not explicitly set:
-
methoddefaults toget. - When any body option (
data,datafile,json,form, ormultipart) is present,methoddefaults topost. -
jsonsetscontenttypetoapplication/jsonunlesscontenttypeis provided. -
formsetscontenttypetoapplication/x-www-form-urlencodedunlesscontenttypeis provided. -
multipartsetscontenttypetomultipart/form-datawith a generated boundary unlesscontenttypeis provided. -
useragentdefaults toTuku/1.0 Kotuku. -
timeoutdefaults to 30,connect-timeoutto 10, anddata-timeoutto 30. -
max-redirectsdefaults to 10 and must be at least 1. - All timeout values must be greater than zero.
Tuku follows curl-like conventions for exit status:
- Success: Tuku exits with code 0 when the HTTP transfer completes, regardless of the HTTP status code.
-
Transport errors (DNS failure, connection refused, timeouts): Tuku prints a structured error line and raises
ERR_Failed. -
HTTP 4xx/5xx: By default these do not cause a failure. Use
failto map HTTP error statuses toERR_Failed. - Argument errors: Invalid or incompatible options are reported with a structured error line and a non-zero exit code.
When status is set, the numeric HTTP status code is always printed to standard output, even when fail causes a non-zero exit.
Print the response body of a URL to standard output:
origo apps/tuku.tiri url=https://example.com
Download the response body to a local file:
origo apps/tuku.tiri url=https://example.com/report.pdf output=report.pdf
Send a plain text body with an explicit content type:
origo apps/tuku.tiri url=https://httpbin.org/post data="hello world" contenttype=text/plain
Post a JSON payload. The content type is set automatically:
origo apps/tuku.tiri url=https://api.example.com/items json='{"name":"Ada","role":"Engineer"}'
Submit URL-encoded form fields:
origo apps/tuku.tiri url=https://example.com/login form={username=ada,password=secret}
Multiple values use Origo array syntax:
origo apps/tuku.tiri url=https://example.com/login form={"username=ada","password=secret"}
Send multipart text fields:
origo apps/tuku.tiri url=https://example.com/profile multipart={name=Ada,role=Engineer}
Upload a file by prefixing the field value with @:
origo apps/tuku.tiri url=https://example.com/upload multipart={doc=@report.pdf}
Set one or more custom request headers:
origo apps/tuku.tiri url=https://api.example.com header={"Accept: application/json","X-Token: my-secret"}
Print only the HTTP status code:
origo apps/tuku.tiri url=https://example.com status
This prints a single line to standard output, e.g. 200.
Print a structured summary after the transfer:
origo apps/tuku.tiri url=https://example.com output=page.html verbose
See Verbose Summary Format for the output structure.
Print all response headers without verbose mode:
origo apps/tuku.tiri url=https://example.com headers status
Each header is printed as tuku: header key=value, one per line. When combined with verbose, response headers are included in the verbose summary instead.
Print response headers before the response body:
origo apps/tuku.tiri url=https://example.com include
When output is set, include prints headers to standard output and writes the response body to the file.
Follow HTTP redirects:
origo apps/tuku.tiri url=https://example.com/old-path follow
Tuku follows 301, 302, 303, 307, and 308 redirects when follow is set. 301, 302, and 303
redirects switch the next request to GET; 307 and 308 preserve the current method and body. Use
max-redirects=N to limit redirect chains.
Resume a partially downloaded file. Tuku reads the existing file size and issues a Range header:
origo apps/tuku.tiri url=https://example.com/large.zip output=large.zip resume
Resume requires output to be set and method to be get (the default).
Route the request through an HTTP proxy:
origo apps/tuku.tiri url=https://example.com proxy=proxy.local:8080
The proxy value must be in host:port format with a port between 1 and 65535.
Provide HTTP credentials:
origo apps/tuku.tiri url=https://api.example.com user=admin:password123
In scripts, use fail to treat HTTP error statuses as non-zero exits:
origo apps/tuku.tiri url=https://api.example.com/health fail
If the server returns a 4xx or 5xx status, Tuku prints a structured error line and exits with a non-zero code. Without fail, the same request would exit successfully.
Tuku emits machine-readable error lines to standard output in the format:
tuku: error: type=TYPE [status=NNN] [code=NNN] message=DESCRIPTION
| Field | Description |
|---|---|
type |
Error category: argument, transport, http, redirect, or runtime. |
status |
HTTP status code, present for http errors. |
code |
Internal error code, present for transport and runtime errors. |
message |
Human-readable description of the error. |
Examples:
tuku: error: type=argument message=Required parameter 'url' is missing.
tuku: error: type=http status=404 code=7 message=HTTP status 404
tuku: error: type=transport status=0 code=32 message=Connection refused
When verbose is set, Tuku prints a line-oriented transfer summary after the request completes. Each line is prefixed with tuku: for easy parsing:
tuku: method=GET
tuku: url=https://example.com
tuku: status=200
tuku: bytes=1256
tuku: output=page.html
tuku: transport=Okay
tuku: header content-type=text/html; charset=UTF-8
tuku: header content-length=1256
| Line | Description |
|---|---|
method |
HTTP method used (upper-case). |
url |
Request URL. |
status |
HTTP status code. |
bytes |
Number of bytes received. |
output |
Output target: a file path or stdout. |
transport |
Transport result: Okay on success, or an error description. |
header |
One line per response header, in key=value format. |
When output is not set and the response body is streamed to standard output, output shows stdout.