Struct HttpConn

Source
pub struct HttpConn {
    pub remote_addr: SocketAddr,
    pub buf: FixedBuf<8192>,
    pub stream: TcpStream,
    pub read_state: ReadState,
    pub write_state: WriteState,
}

Fields§

§remote_addr: SocketAddr§buf: FixedBuf<8192>§stream: TcpStream§read_state: ReadState§write_state: WriteState

Implementations§

Source§

impl HttpConn

Source

pub fn new(remote_addr: SocketAddr, stream: TcpStream) -> Self

Source

pub fn is_ready(&self) -> bool

Source

pub fn shutdown_write(&mut self)

Source

pub fn shutdown_write_on_err<T, E>( &mut self, result: Result<T, E>, ) -> Result<T, E>

Source

pub async fn read_request(&mut self) -> Result<Request, HttpError>

§Errors

Returns an error when:

  • we did not send a response to the previous request
  • the connection is closed
  • we did not read the response body of the previous request
  • we fail to read the request
  • we fail to parse the request
Source

pub async fn write_http_continue(&mut self) -> Result<(), HttpError>

§Errors

Returns an error when:

  • the connection is closed
  • a response was already sent
  • we fail to send the response
Source

pub async fn read_body_to_vec(&mut self) -> Result<RequestBody, HttpError>

§Errors

Returns an error when:

  • the client did not send a request body
  • the request body was already read from the client
  • the client used an unsupported transfer encoding
  • we fail to read the request body
Source

pub async fn read_body_to_file( &mut self, dir: &Path, max_len: u64, ) -> Result<RequestBody, HttpError>

§Errors

Returns an error when:

  • the client did not send a request body
  • the request body was already read from the client
  • the client used an unsupported transfer encoding
  • the client sends a request body that is larger than max_len
  • we fail to read the request body
  • we fail to create or write the temporary file
Source

pub async fn write_response( &mut self, response: &Response, ) -> Result<(), HttpError>

§Errors

Returns an error when a response was already sent, the connection is closed, or it fails to send the response bytes over the network connection.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,