pub fn run_pre_request(
script: &Script,
request: &Request,
) -> (Result<Request, SendraError>, ScriptOutput)Expand description
Run a pre_request script and return the request it left behind, along
with anything it printed.
The script sees request as an object map — see [request_map] for the
exact shape — mutates it in place, and this reads it back out and validates
it. Errors are SendraError rather than a ScriptOutcome because
there is no response and never will be: whatever went wrong, this request is
not being sent, which is the same category of failure as a missing variable
or a refused connection.
The ScriptOutput comes back whether the script succeeded or not,
which is why it is beside the Result rather than inside its Ok: a script
that printed three lines and then threw printed three lines, and those are
usually the three lines that explain the throw. Losing them on the error
path would lose them exactly when they are worth the most.