crawlkit_core/
response.rs1use std::collections::HashMap;
4
5#[derive(Debug, Clone)]
9pub struct Response {
10 pub url: String,
12 pub status: u16,
14 pub headers: HashMap<String, String>,
16 pub body: String,
18}
19
20impl Response {
21 pub fn is_success(&self) -> bool {
23 (200..300).contains(&self.status)
24 }
25
26 pub fn content_type(&self) -> Option<&str> {
28 self.headers.get("content-type").map(String::as_str)
29 }
30
31 pub fn is_html(&self) -> bool {
33 self.content_type()
34 .is_some_and(|ct| ct.to_ascii_lowercase().contains("text/html"))
35 }
36}