pub struct HttpResponse {
pub version: HttpVersion,
pub status_code: ResponseStatusCode,
pub reason_phrase: String,
pub headers: HttpResponseHeaders,
pub body: ResponseBody,
}Expand description
Parsed HTTP response.
Value type with all fields public — no Arc<RwLock> wrapping, no
associated-type / boxed-trait indirection. Use the field accessors
directly (response.status_code, response.body, …) or the
convenience helpers (response.text(), response.is_success()).
HttpResponse is Clone and Debug. Decoding is a method
(HttpResponse::decode) that returns a fresh HttpResponse with
the body expanded — original is untouched.
Fields§
§version: HttpVersionHTTP version (HTTP/1.1, HTTP/2, …).
status_code: ResponseStatusCode3-digit numeric status code (200, 404, …).
reason_phrase: StringReason phrase ("OK", "Not Found", …).
headers: HttpResponseHeadersResponse headers (single-value, lowercase keys).
body: ResponseBodyRaw response body bytes.
Implementations§
Source§impl HttpResponse
impl HttpResponse
pub fn get_version(&self) -> &HttpVersion
pub fn get_status_code(&self) -> ResponseStatusCode
pub fn get_reason_phrase(&self) -> &String
pub fn get_headers(&self) -> &HttpResponseHeaders
pub fn get_body(&self) -> &ResponseBody
Source§impl HttpResponse
impl HttpResponse
pub fn set_version(&mut self, val: HttpVersion) -> &mut Self
pub fn set_status_code(&mut self, val: ResponseStatusCode) -> &mut Self
pub fn set_reason_phrase(&mut self, val: impl AsRef<str>) -> &mut Self
pub fn set_headers(&mut self, val: HttpResponseHeaders) -> &mut Self
pub fn set_body(&mut self, val: impl AsRef<[u8]>) -> &mut Self
Source§impl HttpResponse
impl HttpResponse
Sourcepub fn from_bytes(response: &[u8]) -> Self
pub fn from_bytes(response: &[u8]) -> Self
Construct from raw response bytes (status line + headers + body).
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Was the response a 2xx success?
Sourcepub fn is_redirect(&self) -> bool
pub fn is_redirect(&self) -> bool
Was the response a 3xx redirect?
Sourcepub fn get_header<K: AsRef<str>>(&self, key: K) -> Option<&str>
pub fn get_header<K: AsRef<str>>(&self, key: K) -> Option<&str>
Look up a single header value (case-insensitive).
Sourcepub fn decode(&self, buffer_size: usize) -> HttpResponse
pub fn decode(&self, buffer_size: usize) -> HttpResponse
Decode the body using the headers’ Content-Encoding (gzip / deflate /
br). Returns a fresh response with the decoded body — the original is
untouched. buffer_size controls the chunk size for streaming decoders.