pub struct ConfigFile {
pub headers: BTreeMap<String, String>,
pub timeout_seconds: Option<u64>,
pub follow_redirects: Option<FollowRedirects>,
pub insecure: Option<bool>,
pub proxy: Option<String>,
pub client_cert: Option<ClientCertFile>,
pub cookie_jar: Option<bool>,
}Expand description
One config file, exactly as it appears on disk.
Every field is optional, and stays optional after parsing, because that
optionality is the merge information: None means “this file said
nothing about it”, which is what lets a project file override one key
without silently resetting the others. The all-decided resolved form is
Config.
headers: # merged into every request; the request wins ties
User-Agent: sendra
Accept: application/json
timeout_seconds: 10 # whole-request timeout, connect through body readUnknown keys are rejected, matching Request and
Collection: a typo in a config key would otherwise be
a setting that silently never applies, which is worse here than in a request
file — there is no response in which to notice it.
Fields§
§headers: BTreeMap<String, String>Headers merged into every request. A header set by the request itself wins.
timeout_seconds: Option<u64>Whole-request timeout in seconds.
Seconds as an integer, with the unit in the key name, rather than a
duration string like "30s": there is then nothing to parse, no way to
read the unit wrong, and no syntax to stay compatible with if a richer
duration format is wanted later.
follow_redirects: Option<FollowRedirects>Whether to follow redirects, and how many hops to allow. See
FollowRedirects.
insecure: Option<bool>Skip TLS certificate verification for every request this run sends —
the config-file form of --insecure.
A real security-relevant setting, not a convenience default: it exists
for a self-signed or otherwise untrusted endpoint (an internal
staging host, say) where there is no CA chain to verify against, and
it disables the one thing standing between a request and a
man-in-the-middle. See build_client for where
it is applied, and the CLI’s --insecure doc comment for the warning
printed whenever this resolves to true, from either source.
proxy: Option<String>Route every request through this HTTP proxy — the config-file form of
--proxy.
proxy: http://proxy.example.com:8080
proxy: http://user:pass@proxy.example.com:8080 # credentials in the URLA plain URL string rather than a structured {host, port, user, pass}
object: reqwest, which actually builds the proxying connector, already
reads user/pass credentials straight out of the URL’s userinfo, so a
second, Sendra-specific way to spell the same thing would be a second
thing to keep in sync with reqwest’s own parsing rather than a real
capability. Not validated here — an unparsable URL surfaces as a
SendraError::Client when build_client
tries to build the client, the same place every other
client-construction failure is reported.
Setting this — from either the config file or --proxy — takes over
proxying for the run entirely: the standard HTTP_PROXY/
HTTPS_PROXY/NO_PROXY environment variables Sendra otherwise
respects by default (matching curl, and every other common HTTP tool)
are not consulted once an explicit proxy is configured. None — no
proxy: key and no --proxy — is the plain “follow the environment,
same as everyone else” default.
client_cert: Option<ClientCertFile>Present a client certificate for mutual TLS — the config-file form of
--client-cert/--client-key.
client_cert:
cert: ./client.pem
key: ./client-key.pemPEM only, not PKCS#12: Sendra’s reqwest is built against rustls-tls
alone (no native-tls), and reqwest::Identity’s PKCS#12 and
split-PEM constructors both require native-tls — pulling that in
would mean shipping a second TLS backend just to accept one more input
format. Identity::from_pem (the one constructor rustls-tls does
expose) wants a single buffer containing both the certificate and its
private key, so build_client reads both files
and concatenates them in memory before handing that buffer to reqwest.
cert/key are resolved relative to this config file’s own
directory, not the current working directory — the same rule
body_file: uses for the request file that names it, and for the same
reason: a project config checked into version control should mean the
same file on every machine it runs on, not whichever directory the
command happened to be typed from. See
[resolve_client_cert_paths]. --client-cert/--client-key, by
contrast, resolve relative to the working directory, matching how
every other CLI-supplied path (--junit, say) is read.
Both halves are required together — a cert with no key, or a key with
no cert, is refused as SendraError::ClientCertIncomplete when
build_client tries to use it, the same place
every other client-construction failure is reported. That check runs
after CLI overrides are folded in, so a config cert: paired with a
--client-key override (or vice versa) is a valid combination, not an
error — only ending up with just one side, from any mix of sources, is
refused.
Persist cookies received via Set-Cookie and send them back
automatically on later requests to the same host — the config-file
form of --cookie-jar.
Opt-in, off by default, deliberately matching curl: curl does
not carry cookies between requests unless you pass -c/-b
yourself, and Sendra follows the same convention rather than
defaulting to “on” because it would be convenient for the
login-flow case this exists for. See
build_client for where it is applied.
In-memory only, for the duration of one invocation — nothing is
written to disk, and nothing survives between separate sendra run/
sendra test invocations, the same “no persistence across
invocations” rule crate::capture already follows.
Implementations§
Source§impl ConfigFile
impl ConfigFile
Sourcepub fn from_yaml_str(yaml: &str) -> Result<Self, SendraError>
pub fn from_yaml_str(yaml: &str) -> Result<Self, SendraError>
Parse a config file from a YAML string.
Trait Implementations§
Source§impl Clone for ConfigFile
impl Clone for ConfigFile
Source§fn clone(&self) -> ConfigFile
fn clone(&self) -> ConfigFile
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConfigFile
impl Debug for ConfigFile
Source§impl Default for ConfigFile
impl Default for ConfigFile
Source§fn default() -> ConfigFile
fn default() -> ConfigFile
Source§impl<'de> Deserialize<'de> for ConfigFile
impl<'de> Deserialize<'de> for ConfigFile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ConfigFile
Source§impl PartialEq for ConfigFile
impl PartialEq for ConfigFile
Source§impl Serialize for ConfigFile
impl Serialize for ConfigFile
impl StructuralPartialEq for ConfigFile
Auto Trait Implementations§
impl Freeze for ConfigFile
impl RefUnwindSafe for ConfigFile
impl Send for ConfigFile
impl Sync for ConfigFile
impl Unpin for ConfigFile
impl UnsafeUnpin for ConfigFile
impl UnwindSafe for ConfigFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.