Curl
A tracked curl wrapper: every HTTP request records exactly what went out and what came back — headers, cookies, body, redirects and timing — with secrets masked, and a persistent cookie jar that carries a session across requests. WHAT IT DOES
Wraps the curl binary in a swamp model, so an HTTP call leaves evidence
instead of vanishing into a terminal. Each request records the method,
URL, the headers the wrapper applied, the cookies sent and received, every
response header block (including the redirect chain), the body (capped, and
optionally saved in full), timing, the exact curl argv, the exit code and
stderr. Authorization, cookie, API-key and Set-Cookie values are masked by
default, so the record is safe to keep in swamp data. Prefer it over
ad-hoc curl: a per-instance Netscape cookie jar (reuseCookies) makes a
login followed by authenticated calls a matter of running methods in
sequence, and the whole exchange is queryable later with swamp data.
INSTALL
swamp extension pull @svendowideit/curlDEPENDENCIES
The curl binary, which must be on PATH (or set the curlPath global
argument). No other swamp extension is required, and nothing is installed
on the host.
RUN
# Send a request and keep the full in/out record. The instance is
# auto-created on first use.
swamp model @svendowideit/curl method run request http \
--input url="https://api.github.com/repos/denoland/deno"
# POST JSON and fail the run on a 4xx/5xx — the record is written first,
# so the evidence survives the failure.
swamp model @svendowideit/curl method run post http \
--input url="https://httpbin.org/post" \
--input 'dataJson:json={"hello":"world"}' \
--input failOnHttpError=true
# Inspect the persistent cookie jar to see what a login-style request
# stored, and whether it will be reused.
swamp model @svendowideit/curl method run cookie-jar httpCONFIGURE
Optional global arguments (set at model creation with
--global-arg key=value): cookieJar, reuseCookies, userAgent,
defaultHeaders, followRedirects, maxRedirects, insecure, timeoutMs,
connectTimeoutMs, maxBodyBytes, redactHeaders, redactCookieValues, stateDir
and curlPath. Per call: url, method, headers, query, data, dataJson,
dataFile, form, multipart, files, cookies, user, bearerToken, label,
saveBody, outputFile and the reuseCookies/followRedirects/insecure/timeoutMs/
failOn* overrides. See the README for the full tables.
UPGRADE
This extension installs nothing on the host, so an upgrade has nothing to rebuild or reconcile. Refresh the pulled model type and its bundled files with one idempotent command:
swamp extension update Model definitions record the version they were created with; the model's
bundled upgrades entry migrates them automatically on the next method
run, and neither swamp data nor the cookie jar is touched.
WHAT IT INSTALLS
Nothing on the host — no services, cron triggers, daemons or webhooks. It
runs the curl binary, reads and writes the cookie jar under stateDir, and
writes swamp resources (and a body file when saveBody is set).
Global Arguments
| Argument | Type | Description |
|---|---|---|
| name? | string | Model instance name (supplied by swamp; used to derive the cookie jar). |
| cookieJar? | string | Path to a persistent cookie jar file. Empty derives |
| reuseCookies? | boolean | Send cookies already stored in the jar on each request. |
| defaultHeaders? | array | Headers applied to every request, each as "Name: Value". |
| followRedirects? | boolean | Follow HTTP redirects (curl --location). |
| maxRedirects? | number | Maximum redirects to follow. |
| insecure? | boolean | Skip TLS certificate verification (curl --insecure). |
| timeoutMs? | number | Total request timeout in milliseconds. |
| connectTimeoutMs? | number | Connection timeout in milliseconds. |
| maxBodyBytes? | number | Maximum bytes of a body recorded in a resource (0 records none). |
| redactHeaders? | array | Header names whose values are masked in the recorded request/response. |
| redactCookieValues? | boolean | Mask cookie values in the recorded output. |
| Argument | Type | Description |
|---|---|---|
| url | string | URL to request. |
| method? | string | HTTP method. Empty = auto (POST when a body is supplied, otherwise GET). |
| headers? | array | Extra request headers, each as "Name: Value". Override globals. |
| query? | record | Query parameters appended to the URL. |
| data? | string | Raw request body, sent byte-for-byte and recorded (truncated). |
| dataJson? | unknown | Body serialized as JSON; sets Content-Type: application/json. |
| dataFile? | string | Path of a file to send as the body (curl --data-binary @file). The |
| form? | record | Form fields sent as application/x-www-form-urlencoded. |
| multipart? | record | Multipart form fields (curl --form name=value). Use for APIs that take |
| files? | record | Files attached as multipart fields (curl --form name=@path). Combine with |
| cookies? | array | Cookies to send for this request, each as "name=value". |
| user? | string | user:password for HTTP basic auth (curl --user). |
| bearerToken? | string | Bearer token added as an Authorization header. |
| label? | string | Name for the request record (empty = a generated name). Also names a |
| saveBody? | boolean | Store the full response body as a `body` file resource. |
| outputFile? | string | Also write the response body to this path. |
| maxBodyBytes? | number | Override the global recorded-body cap for this request. |
| reuseCookies? | boolean | Override the global reuseCookies for this request. |
| followRedirects? | boolean | Override the global followRedirects for this request. |
| insecure? | boolean | Override the global insecure for this request. |
| timeoutMs? | number | Override the global timeoutMs for this request. |
| failOnHttpError? | boolean | Fail the run when the final status is 400+. The record is still written |
| failOnCurlError? | boolean | Fail the run when curl exits non-zero. The record is still written |
| Argument | Type | Description |
|---|---|---|
| url | string | URL to request. |
| method? | string | HTTP method. Empty = auto (POST when a body is supplied, otherwise GET). |
| headers? | array | Extra request headers, each as "Name: Value". Override globals. |
| query? | record | Query parameters appended to the URL. |
| data? | string | Raw request body, sent byte-for-byte and recorded (truncated). |
| dataJson? | unknown | Body serialized as JSON; sets Content-Type: application/json. |
| dataFile? | string | Path of a file to send as the body (curl --data-binary @file). The |
| form? | record | Form fields sent as application/x-www-form-urlencoded. |
| multipart? | record | Multipart form fields (curl --form name=value). Use for APIs that take |
| files? | record | Files attached as multipart fields (curl --form name=@path). Combine with |
| cookies? | array | Cookies to send for this request, each as "name=value". |
| user? | string | user:password for HTTP basic auth (curl --user). |
| bearerToken? | string | Bearer token added as an Authorization header. |
| label? | string | Name for the request record (empty = a generated name). Also names a |
| saveBody? | boolean | Store the full response body as a `body` file resource. |
| outputFile? | string | Also write the response body to this path. |
| maxBodyBytes? | number | Override the global recorded-body cap for this request. |
| reuseCookies? | boolean | Override the global reuseCookies for this request. |
| followRedirects? | boolean | Override the global followRedirects for this request. |
| insecure? | boolean | Override the global insecure for this request. |
| timeoutMs? | number | Override the global timeoutMs for this request. |
| failOnHttpError? | boolean | Fail the run when the final status is 400+. The record is still written |
| failOnCurlError? | boolean | Fail the run when curl exits non-zero. The record is still written |
| Argument | Type | Description |
|---|---|---|
| url | string | URL to request. |
| method? | string | HTTP method. Empty = auto (POST when a body is supplied, otherwise GET). |
| headers? | array | Extra request headers, each as "Name: Value". Override globals. |
| query? | record | Query parameters appended to the URL. |
| data? | string | Raw request body, sent byte-for-byte and recorded (truncated). |
| dataJson? | unknown | Body serialized as JSON; sets Content-Type: application/json. |
| dataFile? | string | Path of a file to send as the body (curl --data-binary @file). The |
| form? | record | Form fields sent as application/x-www-form-urlencoded. |
| multipart? | record | Multipart form fields (curl --form name=value). Use for APIs that take |
| files? | record | Files attached as multipart fields (curl --form name=@path). Combine with |
| cookies? | array | Cookies to send for this request, each as "name=value". |
| user? | string | user:password for HTTP basic auth (curl --user). |
| bearerToken? | string | Bearer token added as an Authorization header. |
| label? | string | Name for the request record (empty = a generated name). Also names a |
| saveBody? | boolean | Store the full response body as a `body` file resource. |
| outputFile? | string | Also write the response body to this path. |
| maxBodyBytes? | number | Override the global recorded-body cap for this request. |
| reuseCookies? | boolean | Override the global reuseCookies for this request. |
| followRedirects? | boolean | Override the global followRedirects for this request. |
| insecure? | boolean | Override the global insecure for this request. |
| timeoutMs? | number | Override the global timeoutMs for this request. |
| failOnHttpError? | boolean | Fail the run when the final status is 400+. The record is still written |
| failOnCurlError? | boolean | Fail the run when curl exits non-zero. The record is still written |
| Argument | Type | Description |
|---|---|---|
| clear? | boolean | Delete the cookie jar file after reporting its contents. |
| raw? | boolean | Include the raw cookie jar text in the record. |
Resources
Files
- Has README or module doc2/2earned
- README has a code example1/1earned
- README is substantive1/1earned
- Most symbols documented1/1earned
- No slow types (deprecated)1/1earned
- Dependencies pass trust audit1/2partial
- @std/assert--jsr:@std/assert@1 is a range; audited 1.0.19, the version the registry resolved
1 dependency found
- jsr:@std/assert@1 -- audited 1.0.19
- Has description1/1earned
- Platform support declared (or universal)2/2earned
- License2/2earned
- Verified public repository2/2earned
Spawns a subprocess with Deno.Command().
- models/curl.ts:748 — this extension is a curl wrapper — spawning curl is its purpose. Every argument is built by buildCurlArgs, not taken raw from the caller.