pub struct HttpConnection<T> { /* private fields */ }
Expand description
A wrapper over a HTTP Connection.
Implementations§
Source§impl<T: Read + Write + ScmSocket> HttpConnection<T>
impl<T: Read + Write + ScmSocket> HttpConnection<T>
Sourcepub fn set_payload_max_size(&mut self, request_payload_max_size: usize)
pub fn set_payload_max_size(&mut self, request_payload_max_size: usize)
This function sets the limit for PUT/PATCH requests. It overwrites the default limit of 0.05MiB with the one allowed by server.
Sourcepub fn try_read(&mut self) -> Result<(), ConnectionError>
pub fn try_read(&mut self) -> Result<(), ConnectionError>
Tries to read new bytes from the stream and automatically update the request.
Meant to be used only with non-blocking streams and an EPOLL
structure.
Should be called whenever an EPOLLIN
event is signaled.
§Errors
StreamError
is returned when an IO operation fails.
ConnectionClosed
is returned when a client prematurely closes the connection.
ParseError
is returned when a parsing operation fails.
Sourcepub fn try_write(&mut self) -> Result<(), ConnectionError>
pub fn try_write(&mut self) -> Result<(), ConnectionError>
Tries to write the first available response to the provided stream.
Meant to be used only with non-blocking streams and an EPOLL
structure.
Should be called whenever an EPOLLOUT
event is signaled. If no bytes
were written to the stream or error occurred while trying to write to stream,
we will discard all responses from response_queue because there is no way
to deliver it to client.
§Errors
StreamError
is returned when an IO operation fails.
ConnectionClosed
is returned when trying to write on a closed connection.
InvalidWrite
is returned when trying to write on a connection with an
empty outgoing buffer.
Sourcepub fn clear_write_buffer(&mut self)
pub fn clear_write_buffer(&mut self)
Discards all pending writes from the connection.
Sourcepub fn enqueue_response(&mut self, response: Response)
pub fn enqueue_response(&mut self, response: Response)
Send a response back to the source of a request.
Sourcepub fn pop_parsed_request(&mut self) -> Option<Request>
pub fn pop_parsed_request(&mut self) -> Option<Request>
Returns the first parsed request in the queue or None
if the queue
is empty.
Sourcepub fn has_parsed_requests(&self) -> bool
pub fn has_parsed_requests(&self) -> bool
Returns if parsed_requests is not empty
Sourcepub fn pending_write(&self) -> bool
pub fn pending_write(&self) -> bool
Returns true
if there are bytes waiting to be written into the stream.