use alloc::{string::String, vec::Vec};
use future_form::FutureForm;
#[cfg(feature = "reqwest")]
pub mod reqwest_client;
pub trait HttpClient<K: FutureForm>: Clone {
type Error: core::error::Error + 'static;
fn post(
&self,
url: &str,
headers: &[(&str, &str)],
body: Vec<u8>,
) -> K::Future<'_, Result<HttpResponse, Self::Error>>;
}
#[derive(Debug, Clone)]
pub struct HttpResponse {
pub status: u16,
pub body: Vec<u8>,
pub headers: Vec<(String, String)>,
}
impl HttpResponse {
#[must_use]
pub fn header(&self, name: &str) -> Option<&str> {
let lower = name.to_lowercase();
self.headers
.iter()
.find(|(k, _)| k == &lower)
.map(|(_, v)| v.as_str())
}
}