Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

COURIERFORGE.png
HTTP client for Corros.

courierforge 🔥

A requests-style HTTP client for Corros — GET, POST, PUT, DELETE, HEAD, binary downloads, query strings, and a full JSON parser/serializer, written entirely in Corros, the from-scratch scripting language. No Python, no requests, no dependencies — just Corros.

Python package courierforge
requests.get(url) courier_get(url, headers)
requests.post(url, json=...) courier_post(url, body, headers)
r.status_code r["status"]
r.headers[...] courier_header(r, "name")
r.text r["body"]
r.json() courier_json(r["body"])
requests.get(url, params=...) courier_get(courier_url(base, params), nil)
requests.get(...).content / streaming courier_download(url, path)

Install (one line)

curl -fsSL https://raw.githubusercontent.com/CocoCopi/courierforge/main/install.sh | sh
courierforge get https://example.com

Or from source:

git clone https://github.com/CocoCopi/courierforge
cd courierforge
corros src/cli.cro get https://example.com

Use it in your own Corros programs

adopt "/path/to/courierforge/src/courier.cro"   // or wherever you installed it

forge r = courier_get("https://example.com", nil)
speak("status:", r["status"])                        // 200
speak("type:", courier_header(r, "content-type"))    // text/html

forge j = courier_json(courier_get("https://jsonplaceholder.typicode.com/todos/1", nil)["body"])
speak(j["title"])                                    // parsed JSON

forge r2 = courier_post("https://httpbin.org/post", courier_json_dump({ "name": "corros" }),
                        { "content-type": "application/json" })

courier_download("https://example.com/page", "/tmp/page.html")   // binary-safe

API

function does
courier_get(url, headers) GET → {status, headers, body, error}
courier_post(url, body, headers) POST raw body
courier_put(url, body, headers) PUT raw body
courier_delete(url, headers) DELETE
courier_head(url, headers) HEAD
courier_download(url, path) binary-safe streaming download → status
courier_header(resp, name) header value (case-insensitive) or ""
courier_params(map) {"a":1,"msg":"hi there"}a=1&msg=hi%20there
courier_url(base, params) base + ?query (handles existing ?)
courier_json(text) parse JSON → Corros values (maps, lists, nums, strings, bools, nil)
courier_json_dump(value) Corros values → JSON text

How it works

Requests shell out to curl (present everywhere Corros runs): redirects followed (up to 5), 15s connect / 90s total timeouts, headers parsed into a map, bodies returned verbatim. Binary downloads use the Corros language's own http_download builtin (streams raw bytes, never through a string). The JSON parser and serializer are a hand-written recursive-descent implementation in Corros itself — no third-party code anywhere.

Tests

bash tests/run.sh     # boots a local echo server, runs the offline suite

The suite covers GET/POST/PUT, custom headers, JSON parse + dump round-trips, and query-string building — fully offline (plus examples/demo.cro for a live https check).

License

MIT — see LICENSE. Built with Corros; see the Corros repo for the language.

About

courierforge — a requests-style HTTP client for Corros (requests equivalent, written in Corros)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages