pub struct FetchResponse {
pub final_url: Url,
pub status: StatusCode,
pub headers: HeaderMap,
pub body: Bytes,
pub redirect_chain: Vec<RedirectHop>,
pub timings: RequestTimings,
pub compressed_size: Option<u64>,
pub not_modified: bool,
}Expand description
HTTP response with metadata
Fields§
§final_url: UrlFinal URL after redirects
status: StatusCodeHTTP status code
headers: HeaderMapResponse headers
body: BytesResponse body (raw bytes)
redirect_chain: Vec<RedirectHop>Redirect chain
timings: RequestTimingsRequest timings
compressed_size: Option<u64>Size before decompression
not_modified: boolIs this a 304 Not Modified response?
Implementations§
Source§impl FetchResponse
impl FetchResponse
Sourcepub fn new(
final_url: Url,
status: StatusCode,
headers: HeaderMap,
body: Bytes,
) -> Self
pub fn new( final_url: Url, status: StatusCode, headers: HeaderMap, body: Bytes, ) -> Self
Creates a new response
Sourcepub fn content_type(&self) -> Option<String>
pub fn content_type(&self) -> Option<String>
Response Content-Type
Sourcepub fn last_modified(&self) -> Option<String>
pub fn last_modified(&self) -> Option<String>
Response Last-Modified
Sourcepub fn cache_control(&self) -> Option<String>
pub fn cache_control(&self) -> Option<String>
Response Cache-Control
Sourcepub fn x_robots_tag(&self) -> Option<String>
pub fn x_robots_tag(&self) -> Option<String>
X-Robots-Tag header
Sourcepub fn headers_map(&self) -> HashMap<String, String>
pub fn headers_map(&self) -> HashMap<String, String>
Headers as HashMap
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Is this a success (2xx)?
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Is this a client error (4xx)?
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Is this a server error (5xx)?
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
Is this a rate limit (429)?
Sourcepub fn is_forbidden(&self) -> bool
pub fn is_forbidden(&self) -> bool
Is this forbidden (403)?
Sourcepub fn text(&self) -> Result<String, FromUtf8Error>
pub fn text(&self) -> Result<String, FromUtf8Error>
Body as UTF-8 string
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FetchResponse
impl RefUnwindSafe for FetchResponse
impl Send for FetchResponse
impl Sync for FetchResponse
impl Unpin for FetchResponse
impl UnwindSafe for FetchResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more