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
impl Request
Sourcepub unsafe fn from_ngx_http_request<'a>(
r: *mut ngx_http_request_t,
) -> &'a mut Request
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
.
Sourcepub fn upstream(&self) -> Option<*mut ngx_http_upstream_t>
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
Sourcepub fn connection(&self) -> *mut ngx_connection_t
pub fn connection(&self) -> *mut ngx_connection_t
Pointer to a ngx_connection_t
client connection object.
Sourcepub fn get_module_ctx<T>(&self, module: &ngx_module_t) -> Option<&T>
pub fn get_module_ctx<T>(&self, module: &ngx_module_t) -> Option<&T>
Get Module context
Sourcepub fn set_module_ctx(&self, value: *mut c_void, module: &ngx_module_t)
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
Sourcepub fn get_complex_value(
&self,
cv: &ngx_http_complex_value_t,
) -> Option<&NgxStr>
pub fn get_complex_value( &self, cv: &ngx_http_complex_value_t, ) -> Option<&NgxStr>
Get the value of a complex value.
Sourcepub fn discard_request_body(&mut self) -> Status
pub fn discard_request_body(&mut self) -> Status
Discard (read and ignore) the request body.
Sourcepub fn user_agent(&self) -> Option<&NgxStr>
pub fn user_agent(&self) -> Option<&NgxStr>
Client HTTP User-Agent.
Sourcepub fn set_status(&mut self, status: HTTPStatus)
pub fn set_status(&mut self, status: HTTPStatus)
Set HTTP status of response.
Sourcepub fn add_header_in(&mut self, key: &str, value: &str) -> Option<()>
pub fn add_header_in(&mut self, key: &str, value: &str) -> Option<()>
Add header to the headers_in
object.
See https://nginx.org/en/docs/dev/development_guide.html#http_request
Sourcepub fn add_header_out(&mut self, key: &str, value: &str) -> Option<()>
pub fn add_header_out(&mut self, key: &str, value: &str) -> Option<()>
Add header to the headers_out
object.
See https://nginx.org/en/docs/dev/development_guide.html#http_request
Sourcepub fn set_content_length_n(&mut self, n: usize)
pub fn set_content_length_n(&mut self, n: usize)
Set response body Content-Length.
Sourcepub fn send_header(&mut self) -> Status
pub fn send_header(&mut self) -> Status
Send the output header.
Do not call this function until all output headers are set.
Sourcepub fn header_only(&self) -> bool
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.
Sourcepub fn unparsed_uri(&self) -> &NgxStr
pub fn unparsed_uri(&self) -> &NgxStr
full uri - containing path and args
Sourcepub fn output_filter(&mut self, body: &mut ngx_chain_t) -> Status
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.
Sourcepub fn internal_redirect(&self, location: &str) -> Status
pub fn internal_redirect(&self, location: &str) -> Status
Perform internal redirect to a location
Sourcepub 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
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
Sourcepub fn headers_in_iterator(&self) -> NgxListIterator<'_> ⓘ
pub fn headers_in_iterator(&self) -> NgxListIterator<'_> ⓘ
Iterate over headers_in each header item is (&str, &str) (borrowed)
Sourcepub fn headers_out_iterator(&self) -> NgxListIterator<'_> ⓘ
pub fn headers_out_iterator(&self) -> NgxListIterator<'_> ⓘ
Iterate over headers_out each header item is (&str, &str) (borrowed)