Origin-scoped Digest authentication for gaato/mttp.
moon add gaato/http gaato/mttp gaato/mttp_digest///|
test {
let inner = @client.from_fn((_, _) => @http.Response::new(200))
let backend = @mttp_digest.DigestScheme::new(
inner,
"user",
"password",
origin="https://api.example.test",
random=() => 0.5, // deterministic test source; inject secure randomness in production
)
@driver.run_sync(() => {
let response = backend.send(
@http.Request::get("https://api.example.test/"),
@http.SendOptions::default(),
)
assert_eq(response.status, 200)
response.close()
})
backend.close()
}pub struct DigestScheme {
// private fields
}impl Backend for DigestSchemeasync fn send(self : DigestScheme, request : Request, options : SendOptions) -> Response raise TransportErrorfn DigestScheme::new(inner : &Backend, username : String, password : String, origin~ : String, random~ : () -> Double) -> DigestScheme raise TransportErrorasync fn DigestScheme::send(self : DigestScheme, request : Request, options : SendOptions) -> Response raise TransportError