curl

package
v1.0.0-rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	toolargs.Base
}

Command is a pure-Go, evidence-first reimplementation of curl. It exposes a curl-shaped flag surface so the agent uses it exactly as it would use system curl (this command shadows the system binary), while every request routes through the runner's MITM hub — attributed by tool-call id and captured as http.exchange evidence — and carries a browser-shaped header set by default instead of announcing itself as a scanner.

func New

func New() *Command

func (*Command) Name

func (c *Command) Name() string

func (*Command) QuickReference

func (c *Command) QuickReference() string

func (*Command) Run

func (c *Command) Run(ctx context.Context, execution *commands.Execution) (_ any, err error)

Run parses the curl-shaped argument vector and performs one exchange. The proxy and CA that route/trust the MITM hub arrive in execution.Env (the builtin runs in-process and does not inherit them from os.Environ).

func (*Command) Usage

func (c *Command) Usage() string

func (*Command) WithEvents

func (c *Command) WithEvents(events aop.EventEmitter) *Command

func (*Command) WithLogger

func (c *Command) WithLogger(logger telemetry.Logger) *Command

func (*Command) WithProxy

func (c *Command) WithProxy(proxy string) *Command

type DataPart

type DataPart struct {
	Value     string
	File      bool
	Binary    bool
	Raw       bool
	URLEncode bool
}

DataPart is one -d/--data family value. File means the value is a path to read (@file); Binary keeps the bytes verbatim (--data-binary) while the default -d strips CR/LF from file contents; Raw disables @file handling (--data-raw); URLEncode percent-encodes the content (--data-urlencode).

type FormPart

type FormPart struct {
	Name    string
	Value   string
	File    bool
	Content bool
	Type    string
}

FormPart is one -F/--form value. File means Value is a path whose bytes become a file part (name=@path, optional ;type= MIME override); Content means Value is a path whose text becomes the field value (name=<path).

type Header struct {
	Name   string
	Value  string
	Remove bool
}

Header is one -H value. Value is empty for a "Name;" send-empty form; Remove is set for a "Name:" form that suppresses a default header.

type Request

type Request struct {
	URL            string
	Method         string
	MethodExplicit bool // -X/--request was supplied; prevents -I changing it
	Headers        []Header
	Data           []DataPart
	Form           []FormPart
	Get            bool // -G: send data as query string
	Follow         bool // -L
	MaxRedirs      int  // --max-redirs (default 50 when following)

	UserAgent string // -A
	Referer   string // -e
	User      string // -u user[:password]
	CookieIn  string // -b: cookie string or @file
	CookieJar string // -c: write jar here after the exchange

	Output     string         // -o
	DumpHeader string         // -D: write response headers to a file (or - for stdout)
	TraceASCII string         // --trace-ascii: write an ASCII wire trace to a file
	Include    bool           // -i
	Head       bool           // -I/--head: issue a HEAD request and include headers
	Silent     bool           // -s
	ShowError  bool           // -S
	Fail       bool           // -f/--fail: fail on HTTP 4xx/5xx
	WriteOut   string         // -w
	Verbose    bool           // -v
	NoBuffer   bool           // -N/--no-buffer: stream response writes without buffering
	Insecure   bool           // -k
	Proxy      string         // -x: override the egress proxy for this invocation
	HTTP2      bool           // --http2: prefer/require HTTP/2 where available
	HTTP11     bool           // --http1.1: disable HTTP/2 negotiation
	PathAsIs   bool           // --path-as-is: preserve dot segments in the URL path
	Version    bool           // --version/-V: print the curl compatibility version
	Resolve    []ResolveEntry // --resolve host:port:address, repeatable

	ConnectTimeout time.Duration // --connect-timeout
	MaxTime        time.Duration // --max-time
}

Request is the parsed, transport-agnostic shape of one curl invocation.

func Parse

func Parse(args []string) (*Request, error)

Parse turns a curl argument vector into a Request, rejecting any flag outside the supported set so the caller fails loudly rather than silently dropping an unsupported option.

type ResolveEntry

type ResolveEntry struct {
	Host      string
	Port      string
	Addresses []string
	Temporary bool // --resolve +host:... uses curl's temporary DNS lifetime
}

ResolveEntry describes one --resolve mapping. Addresses are tried in order when a target is dialed; the URL host (and therefore the HTTP Host and TLS SNI name) remains unchanged.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL