Struct Request

Source
pub struct Request(/* private fields */);
Expand description

Wrapper struct for an ngx_http_request_t pointer, providing methods for working with HTTP requests.

See https://nginx.org/en/docs/dev/development_guide.html#http_request

Implementations§

Source§

impl Request

Source

pub unsafe fn from_ngx_http_request<'a>( r: *mut ngx_http_request_t, ) -> &'a mut Request

Create a Request from an ngx_http_request_t.

§Safety

The caller has provided a valid non-null pointer to a valid ngx_http_request_t which shares the same representation as Request.

Source

pub fn is_main(&self) -> bool

Is this the main request (as opposed to a subrequest)?

Source

pub fn pool(&self) -> Pool

Request pool.

Source

pub fn upstream(&self) -> Option<*mut ngx_http_upstream_t>

Returns the result as an Option if it exists, otherwise None.

The option wraps an ngx_http_upstream_t instance, it will be none when the underlying NGINX request does not have a pointer to a ngx_http_upstream_t upstream structure.

ngx_http_upstream_t is best described in https://nginx.org/en/docs/dev/development_guide.html#http_load_balancing

Source

pub fn connection(&self) -> *mut ngx_connection_t

Pointer to a ngx_connection_t client connection object.

Source

pub fn log(&self) -> *mut ngx_log_t

Pointer to a ngx_log_t.

Source

pub fn get_module_ctx<T>(&self, module: &ngx_module_t) -> Option<&T>

Get Module context

Source

pub fn set_module_ctx(&self, value: *mut c_void, module: &ngx_module_t)

Sets the value as the module’s context.

See https://nginx.org/en/docs/dev/development_guide.html#http_request

Source

pub fn get_complex_value( &self, cv: &ngx_http_complex_value_t, ) -> Option<&NgxStr>

Get the value of a complex value.

Source

pub fn discard_request_body(&mut self) -> Status

Discard (read and ignore) the request body.

Source

pub fn user_agent(&self) -> Option<&NgxStr>

Client HTTP User-Agent.

Source

pub fn set_status(&mut self, status: HTTPStatus)

Set HTTP status of response.

Source

pub fn add_header_in(&mut self, key: &str, value: &str) -> Option<()>

Source

pub fn add_header_out(&mut self, key: &str, value: &str) -> Option<()>

Source

pub fn set_content_length_n(&mut self, n: usize)

Set response body Content-Length.

Source

pub fn send_header(&mut self) -> Status

Send the output header.

Do not call this function until all output headers are set.

Source

pub fn header_only(&self) -> bool

Flag indicating that the output does not require a body.

For example, this flag is used by HTTP HEAD requests.

Source

pub fn method(&self) -> Method

request method

Source

pub fn path(&self) -> &NgxStr

path part of request only

Source

pub fn unparsed_uri(&self) -> &NgxStr

full uri - containing path and args

Source

pub fn output_filter(&mut self, body: &mut ngx_chain_t) -> Status

Send the response body.

This function can be called multiple times. Set the last_buf flag in the last body buffer.

Source

pub fn internal_redirect(&self, location: &str) -> Status

Perform internal redirect to a location

Source

pub fn subrequest( &self, uri: &str, module: &ngx_module_t, post_callback: unsafe extern "C" fn(*mut ngx_http_request_t, *mut c_void, ngx_int_t) -> ngx_int_t, ) -> Status

Send a subrequest

Source

pub fn headers_in_iterator(&self) -> NgxListIterator<'_>

Iterate over headers_in each header item is (&str, &str) (borrowed)

Source

pub fn headers_out_iterator(&self) -> NgxListIterator<'_>

Iterate over headers_out each header item is (&str, &str) (borrowed)

Trait Implementations§

Source§

impl AsMut<ngx_http_request_s> for Request

Source§

fn as_mut(&mut self) -> &mut ngx_http_request_t

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<ngx_http_request_s> for Request

Source§

fn as_ref(&self) -> &ngx_http_request_t

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for Request

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a Request> for *const ngx_http_request_t

Source§

fn from(request: &'a Request) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a mut Request> for *mut ngx_http_request_t

Source§

fn from(request: &'a mut Request) -> Self

Converts to this type from the input type.
Source§

impl HttpModuleConfExt for Request

Source§

unsafe fn http_main_conf_unchecked<T>( &self, module: &ngx_module_t, ) -> Option<NonNull<T>>

Get a non-null reference to the main configuration structure for HTTP module Read more
Source§

unsafe fn http_server_conf_unchecked<T>( &self, module: &ngx_module_t, ) -> Option<NonNull<T>>

Get a non-null reference to the server configuration structure for HTTP module Read more
Source§

unsafe fn http_location_conf_unchecked<T>( &self, module: &ngx_module_t, ) -> Option<NonNull<T>>

Get a non-null reference to the location configuration structure for HTTP module Read more

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.