Expand description
rsurl — a pure-Rust implementation of curl.
Top-level entry points:
- HTTP/HTTPS —
get,request, orRequest/Responsedirectly. - Any supported scheme —
transfer, which dispatches to the right protocol backend and returns the payload as raw bytes.
§wasm32 (browser) builds
On wasm32-unknown-unknown there are no sockets, no threads, and no blocking
— the browser owns DNS, TLS, and the HTTP/WebSocket wire. rsurl’s own
net/proto/tls stack, every socket-bound protocol backend (FTP, SSH,
HTTP/2, HTTP/3, BitTorrent, mail, …), and the entire blocking API therefore
do not exist on that target — they are #[cfg(not(target_arch = "wasm32"))].
What remains is the unified async API in aio, which compiles on both
targets: on native it drives the sans-IO core over real sockets; on wasm it
routes HTTP through the Fetch API and WebSockets through the browser’s native
WebSocket. Its types (aio::Request, aio::Response,
aio::WsMessage) and every method on them are identical across targets;
only naming the runtime differs, since natively you supply one and in the
browser the event loop is the runtime. See the aio module docs for that
seam and for the browser-imposed limits (forbidden headers, CORS, no custom
WebSocket handshake headers, …).
Re-exports§
pub use crate::download::download;pub use crate::download::fetch_to_file;pub use crate::download::DownloadOptions;pub use crate::download::DownloadOutcome;pub use crate::multi::EasyId;pub use crate::multi::Multi;pub use crate::net::Client;pub use crate::websocket::WebSocket;pub use crate::websocket::WsClose;pub use crate::websocket::WsEvent;pub use crate::websocket::WsFrame;pub use crate::websocket::WsMessage;pub use crate::websocket::WsOpcode;pub use crate::websocket::WsReader;pub use crate::websocket::WsShutdown;pub use crate::websocket::WsWriter;
Modules§
- aio
- Experimental async HTTP + WebSocket client that compiles for both native targets and the browser.
- bittorrent
- BitTorrent support: load metadata from a
.torrentfile ormagnet:link, discover peers (HTTP/UDP trackers, DHT), exchange pieces over the peer wire protocol, verify and write data, and optionally seed. - dict
- DICT protocol (RFC 2229).
- download
- Resumable, retrying HTTP downloads.
- file
file://URL support (RFC 8089, formerly RFC 1738).- ftp
- FTP and FTPS support.
- gopher
- Gopher and Gopher-over-TLS support (RFC 1436 + the TLS extension).
- http2
- HTTP/2 support (RFC 9113), with HPACK header compression (RFC 7541).
- http3
- HTTP/3 support (RFC 9114), with QPACK (RFC 9204) over QUIC (RFC 9000).
- imap
- IMAP and IMAPS support.
- ldap
- LDAP and LDAPS support.
- mqtt
- MQTT and MQTTS support.
- multi
- Concurrent multi-transfer driver — a thread-backed analogue of curl’s “multi” interface.
- net
- Pluggable network transport.
- pool
- Process-wide idle-connection pool for the sans-IO HTTP/1.1 core path.
- pop3
- POP3 and POP3S support.
- resume
- Shared partial-download format for resumable transfers.
- rtsp
- RTSP support (RFC 7826, also RFC 2326 for RTSP/1.0).
- ssh
- SSH transports: SFTP (
sftp://) and SCP (scp://), download and upload. - tftp
- TFTP support (RFC 1350, plus RFC 2347 option extension, RFC 2348 blksize, RFC 2349 timeout/tsize).
- tls
- TLS support, with a pluggable backend.
- websocket
- WebSocket support (RFC 6455).
Structs§
- Body
Reader - A streaming reader over an HTTP response body, returned by
Request::send_reader. Implementsstd::io::Read; the head (status + headers) is available up front viaBodyReader::headand the accessor methods. - Cancel
Token - A clonable cancellation handle. Clones share one underlying state, so cancelling any clone cancels them all.
- Cookie
- One parsed cookie.
expiresis a Unix epoch second;Nonemeans a session cookie (lives only for this rsurl invocation, never persisted). - Cookie
Jar - Bag of cookies. Cheap to clone in tests; threaded by
&mutthrough the redirect chain incrate::Request::send_with_jar. - Proxy
Config - Where to route HTTP(S) traffic through. Parsed from a curl-style proxy
URL — typically
http://user:pass@host:port. Onlyhttp://proxies are supported in this milestone; TLS-to-proxy (https://) and SOCKS are rejected withError::UnsupportedScheme. - Request
- An HTTP request being constructed.
- Response
- A complete HTTP response.
- Response
Head - The status line + headers of a response, delivered before the body in the
streaming API (
Request::send_streaming). A browser uses this to apply policy and choose a parser before any body byte arrives. - Timing
- Per-phase wall-clock timings for
--write-out(%{time_connect}etc.), each measured from the start of the (final) request attempt. - TlsInfo
- Negotiated TLS parameters for an HTTPS response — what
argus-securityneeds for the security indicator and headless CDPSecurityDetails. - Url
- Minimal parsed URL. Only the fields we need for the protocols we speak.
Enums§
- Error
- Errors that can occur during a rsurl request.
- Http
Version Pref - Preference for which HTTP version to use over HTTPS. The HTTPS dispatcher
picks this up. HTTP/2 is selected via ALPN at TLS-handshake time; if the
server doesn’t agree (Auto) we transparently fall back to HTTP/1.1.
HTTP/3 runs over a wholly separate QUIC/UDP path (see
crate::http3). - Priority
- A request priority hint (à la
fetch’spriority). Currently applied as the issuance order withinsend_multiplexed— higher-priority requests get their HEADERS on the wire first. HTTP/2 PRIORITY-frame weights and preconnect/pool-sizing controls are not yet wired. - Same
Site - The
SameSiteattribute of a cookie (RFC 6265bis §5.2). rsurl parses and exposes it but does not enforce it — same-site is a browser policy the caller (e.g. Argus) applies, not a CLI transfer concern.
Functions§
- get
- Perform an HTTP GET against
urland return the full response. - request
- Perform an arbitrary HTTP request. Convenience wrapper over
Request. - send_
multiplexed - Issue several HTTP/2 requests concurrently over a single connection using true stream multiplexing, returning one result per request in input order.
- send_
multiplexed_ traced - As
send_multiplexed, but writes the protocol trace (the-v* > <lines, interleaved per stream) totrace. Pass&mut std::io::sink()for no trace — or just callsend_multiplexed. - transfer
- Run the default operation for the URL’s scheme and return its payload.
- transfer_
url - Same as
transferbut starts from an already-parsed URL.
Type Aliases§
- Result
- Crate-wide result alias.