pub struct HTTPResponse {
pub httptag: Box<[u8]>,
pub httpversion: (i32, i32),
pub statuscode: HttpStatusCodes,
pub reason: Box<[u8]>,
pub headers: HashMap<String, String>,
pub content: Vec<u8>,
}Expand description
A response to an HTTPRequest
Fields§
§httptag: Box<[u8]>Always HTTP
httpversion: (i32, i32)What HTTP version is in use?
statuscode: HttpStatusCodesThe status of the response
reason: Box<[u8]>The human readable response reason, i.e., “OK” for 200
headers: HashMap<String, String>Any headers the response has
content: Vec<u8>The content
Implementations§
Source§impl HTTPResponse
impl HTTPResponse
Sourcepub fn new() -> HTTPResponse
pub fn new() -> HTTPResponse
Creates a new, blank HTTP response
Sourcepub fn read_http_response(stream: &mut impl Read) -> Result<HTTPResponse, Error>
pub fn read_http_response(stream: &mut impl Read) -> Result<HTTPResponse, Error>
Reads an HTTP response from stream into an HTTPResponse
Sourcepub fn with_statuscode(
self,
statuscode: HttpStatusCodes,
reason: Box<[u8]>,
) -> HTTPResponse
pub fn with_statuscode( self, statuscode: HttpStatusCodes, reason: Box<[u8]>, ) -> HTTPResponse
Changes the status code of this request
Sourcepub fn with_header(self, header: String, value: String) -> HTTPResponse
pub fn with_header(self, header: String, value: String) -> HTTPResponse
Adds a header to this request
Sourcepub fn with_content(self, content: Vec<u8>) -> HTTPResponse
pub fn with_content(self, content: Vec<u8>) -> HTTPResponse
Changes the content of this request
Trait Implementations§
Source§impl Clone for HTTPResponse
impl Clone for HTTPResponse
Source§fn clone(&self) -> HTTPResponse
fn clone(&self) -> HTTPResponse
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HTTPResponse
impl Debug for HTTPResponse
Source§impl Default for HTTPResponse
impl Default for HTTPResponse
Source§impl From<&str> for HTTPResponse
impl From<&str> for HTTPResponse
Auto Trait Implementations§
impl Freeze for HTTPResponse
impl RefUnwindSafe for HTTPResponse
impl Send for HTTPResponse
impl Sync for HTTPResponse
impl Unpin for HTTPResponse
impl UnwindSafe for HTTPResponse
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