pub struct Cli {Show 38 fields
pub method: Option<String>,
pub url: Option<String>,
pub header: Vec<String>,
pub body: Option<String>,
pub body_base64: Option<String>,
pub body_file: Option<String>,
pub body_multipart: Vec<String>,
pub body_urlencoded: Vec<String>,
pub response_save_dir: Option<String>,
pub response_save_above_bytes: Option<u64>,
pub request_concurrency_limit: Option<u64>,
pub timeout_connect_s: Option<u64>,
pub timeout_idle_s: Option<u64>,
pub retry: Option<u32>,
pub retry_base_delay_ms: Option<u64>,
pub retry_on_status: Option<String>,
pub response_redirect: Option<u32>,
pub response_parse_json: Option<bool>,
pub response_decompress: Option<bool>,
pub response_save_file: Option<String>,
pub response_save_resume: bool,
pub response_max_bytes: Option<u64>,
pub chunked: bool,
pub chunked_delimiter: Option<String>,
pub chunked_delimiter_raw: bool,
pub progress_ms: Option<u64>,
pub progress_bytes: Option<u64>,
pub tls_insecure: bool,
pub tls_cacert_file: Option<String>,
pub tls_cert_file: Option<String>,
pub tls_key_file: Option<String>,
pub proxy: Option<String>,
pub upgrade: Option<String>,
pub output: String,
pub log: Option<String>,
pub verbose: bool,
pub dry_run: bool,
pub mode: CliMode,
}Expand description
Agent-First HTTP — persistent HTTP client for AI agents.
§Modes
--mode cli(default): one request, one structured response, then exit--mode pipe: long-lived JSONL stdin/stdout session for agents--mode curl: parse a focused subset of curl flags, then execute through the same runtime
§Output and Exit Codes
- default output is one JSON object on stdout
--output yamland--output plainonly reformat the envelope; server response bodies are not rewritten- exit code
0: HTTP response received - exit code
1: transport/runtime error - exit code
2: invalid arguments
§Request Body Rules
--bodywith a JSON object or array auto-setsContent-Type: application/json- string bodies are sent as raw bytes; set
--header "Content-Type: ..."yourself when needed --body,--body-base64,--body-file,--body-multipart, and--body-urlencodedare mutually exclusive
§Streaming and Files
--chunkedemitschunk_start, repeatedchunk_data, thenchunk_end- use
--chunked-delimiter '\n\n'for SSE and--chunked-delimiter-rawfor binary frames --response-save-filewrites the body to disk;--response-save-resumeresumes partial downloads- progress logs are opt-in via
--log progress
§Examples
afhttp GET https://api.example.com/users
afhttp POST https://api.example.com/users --body '{"name":"Alice"}'
afhttp POST https://api.openai.com/v1/files \
--header "Authorization: Bearer sk-xxx" \
--body-multipart purpose=assistants \
--body-multipart file=@/tmp/data.jsonl;filename=data.jsonl;type=application/jsonl
afhttp GET https://api.example.com/stream --chunked-delimiter '\n\n'
afhttp GET https://example.com/large.tar.gz \
--response-save-file /tmp/large.tar.gz \
--log progress
afhttp --mode pipeFields§
§method: Option<String>HTTP method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
url: Option<String>URL to request
header: Vec<String>Request header (repeatable). Format: “Name: Value”. Empty value removes default.
body: Option<String>Request body. Valid JSON object/array auto-detected and sets Content-Type: application/json. @path reads from file.
body_base64: Option<String>Base64-encoded binary request body
body_file: Option<String>Read request body from file
body_multipart: Vec<String>Multipart form part (repeatable). Format: name=value or name=@path[;filename=x][;type=mime]
body_urlencoded: Vec<String>URL-encoded form field (repeatable). Format: name=value. Sets Content-Type: application/x-www-form-urlencoded.
response_save_dir: Option<String>Directory for auto-saved large response bodies
response_save_above_bytes: Option<u64>Auto-save response body to response-save-dir when larger than this (default: 10485760)
request_concurrency_limit: Option<u64>Max concurrent in-flight requests (0 = unlimited)
timeout_connect_s: Option<u64>TCP+TLS handshake timeout in seconds (default: 10)
timeout_idle_s: Option<u64>No-data timeout in seconds (default: 30)
retry: Option<u32>Retry count (default: 0, no retry)
retry_base_delay_ms: Option<u64>Base delay for first retry in ms (default: 100). Subsequent: base * 2^(attempt-1)
retry_on_status: Option<String>Comma-separated status codes to retry (e.g. 429,503)
response_redirect: Option<u32>Redirect limit (default: 10, 0=disable)
response_parse_json: Option<bool>Parse JSON response body (default: true)
response_decompress: Option<bool>Auto-decompress response (default: true)
response_save_file: Option<String>Save response body to file
response_save_resume: boolResume download if response-save-file exists
response_max_bytes: Option<u64>Hard limit on response body size in bytes
chunked: boolStream response in chunks
chunked_delimiter: Option<String>Chunk delimiter (default: \n). Use \n\n for SSE. Implies –chunked
chunked_delimiter_raw: boolRaw binary chunks (null delimiter). Implies –chunked
progress_ms: Option<u64>Time-based progress interval in ms (default: 10000, 0=disable). Works with –progress-bytes
progress_bytes: Option<u64>Byte-based progress interval (default: 0=disable). Works with –progress-ms
tls_insecure: boolSkip certificate verification
tls_cacert_file: Option<String>CA certificate file path
tls_cert_file: Option<String>Client certificate file path
tls_key_file: Option<String>Client private key file path
proxy: Option<String>Proxy URL
upgrade: Option<String>Protocol upgrade (e.g. “websocket”)
output: StringOutput format: json (default), yaml (human-readable), plain (logfmt)
log: Option<String>Log categories (comma-separated). Categories: startup, request, progress, retry, redirect
verbose: boolEnable all log categories (equivalent to –log startup,request,progress,retry,redirect)
dry_run: boolPreview the request without executing it
mode: CliModeRuntime mode: cli (default), pipe, or curl
Trait Implementations§
Source§impl Args for Cli
impl Args for Cli
Source§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
Source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
Command so it can instantiate self via
FromArgMatches::update_from_arg_matches_mut Read moreSource§impl CommandFactory for Cli
impl CommandFactory for Cli
Source§impl FromArgMatches for Cli
impl FromArgMatches for Cli
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches to self.