Skip to main content

pipa/http/
response.rs

1use crate::http::body_reader::BodyReader;
2use crate::http::headers::Headers;
3use crate::http::status::HttpStatus;
4
5#[derive(Debug)]
6pub struct HttpResponse {
7    pub status: HttpStatus,
8    pub status_text: String,
9    pub headers: Headers,
10    pub body_reader: BodyReader,
11    pub url: String,
12}
13
14impl HttpResponse {
15    pub fn new(
16        status: HttpStatus,
17        status_text: String,
18        headers: Headers,
19        body_reader: BodyReader,
20        url: String,
21    ) -> Self {
22        HttpResponse {
23            status,
24            status_text,
25            headers,
26            body_reader,
27            url,
28        }
29    }
30
31    pub fn ok(&self) -> bool {
32        self.status.is_success()
33    }
34
35    pub fn redirect_count(&self) -> u32 {
36        0
37    }
38}