pub struct Request<'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

Allocate a buffer for the initial response, capable of containing at most max_fields_count fields (headers), and at most max_response_size bytes for the field names, field values, and response content combined.

The buffer can be filled and sent using the methods on the returned Response.

The buffer can be resized with Response::realloc.

Send an initial response to the client.

This is a convenience method that calls the Request::create_response, Response::add_field, Response::add_content, and Response::send methods.

Panic

This method will panic if the header name is longer than u8::MAX bytes, or if the header value is longer than u32::MAX.

Allocate and send additional response chunks to the client, using a writer to copy data into the chunks.

A chunk will be immediately sent to the client once the writer’s memory buffer reaches chunk_size, or flush() is called on the writer.

The writer will also flush when dropped, but may panic in case of errors.

Panic

Panics if flushing was not successful when flushing during a drop. It is recommended to manually call flush(), or use the Request::send_chunks_with_writer() method.

Allocate and send additional response chunks to the client.

This is similar to write_chunks(), but will also flush the writer before returning, convert the result into a UnitError, and log the error.

This is useful to prevent errors from being silently ignored if the writer needs to flush while being dropped.

Send another chunk of bytes for this request’s response. The bytes will be immediately sent to the client.

This method allocates a buffer in Unit’s shared memory region, and calls a user function to fill it.

The user function receives a &mut &mut [u8] slice, and the write! macro can be used to advance the start position of the slice. Only the bytes between the original start and the new start positions will be sent, and the rest will be discarded.

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.

Create a reader that implements the Read trait, which will read from the request body in a blocking manner.

Create an interator over all header (name, value) tuples.

Return whether or not the request was encrypted.

Return the method of the request (e.g. “GET”).

Return the protocol version of the request (e.g. “HTTP/1.1”).

Return the remote IP address of the client.

Return the local IP address of the server.

Return the host name of the server.

Return the combined URI path and query string.

Return the URI path.

Return the URI query string.

Log an error message.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.