use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct Response {
pub url: String,
pub status: u16,
pub headers: HashMap<String, String>,
pub body: String,
}
impl Response {
pub fn is_success(&self) -> bool {
(200..300).contains(&self.status)
}
pub fn content_type(&self) -> Option<&str> {
self.headers.get("content-type").map(String::as_str)
}
pub fn is_html(&self) -> bool {
self.content_type()
.is_some_and(|ct| ct.to_ascii_lowercase().contains("text/html"))
}
}