Struct unit_rs::UnitRequest
source · [−]pub struct UnitRequest<'a> { /* private fields */ }Expand description
A request received by the Nginx Unit server.
This object can be used to inspect the properties and headers of the request, and send a response back to the client.
Implementations
sourceimpl<'a> UnitRequest<'a>
impl<'a> UnitRequest<'a>
sourcepub fn create_response(
self,
headers: &[(impl AsRef<[u8]>, impl AsRef<[u8]>)],
body: impl AsRef<[u8]>
) -> UnitResult<UnitResponse<'a>>
pub fn create_response(
self,
headers: &[(impl AsRef<[u8]>, impl AsRef<[u8]>)],
body: impl AsRef<[u8]>
) -> UnitResult<UnitResponse<'a>>
Send an initial response to the client, and return a
UnitResponse object that allows sending additional
data chunks to the client.
This method will consume the request object and wrap it in a response object. The returned object will still deref to a reference of a request object, allowing inspection of the request but no longer allowing the initiation of a second response.
sourcepub fn read_body(&self, target: &mut [u8]) -> usize
pub fn read_body(&self, target: &mut [u8]) -> usize
Copy bytes from the request body into the target buffer and return the number of bytes written.
If the buffer is smaller than the contents of the body, the contents will be truncated to the size of the buffer.
sourcepub fn fields(&self) -> impl Iterator<Item = (&str, &str)>
pub fn fields(&self) -> impl Iterator<Item = (&str, &str)>
Create an interator over all header (name, value) tuples.
sourcepub fn server_name(&self) -> &str
pub fn server_name(&self) -> &str
Return the host name of the server.
Auto Trait Implementations
impl<'a> RefUnwindSafe for UnitRequest<'a>
impl<'a> !Send for UnitRequest<'a>
impl<'a> !Sync for UnitRequest<'a>
impl<'a> Unpin for UnitRequest<'a>
impl<'a> !UnwindSafe for UnitRequest<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more