pub struct RequestHead {
pub id: usize,
pub uri: Url,
pub method: Method,
pub version: Version,
pub headers: HeaderMap,
pub headers_vec: Vec<HeaderItem>,
pub extensions: RefCell<Extensions>,
/* private fields */
}Expand description
The parsed metadata for an HTTP request.
Fields§
§id: usizeIdentifier of the connection that received the request.
uri: UrlRequest URI.
A request received over HTTP/2 holds only its :path pseudo-header
here, or its :authority for CONNECT, see scheme
and authority.
method: MethodRequest method.
version: VersionHTTP protocol version.
headers: HeaderMapParsed request headers.
headers_vec: Vec<HeaderItem>Headers in their original order and with their original names.
This collection is populated only when
HttpServiceConfig::set_headers_vec
is enabled.
extensions: RefCell<Extensions>Request-local type map.
Implementations§
Source§impl RequestHead
impl RequestHead
Sourcepub fn scheme(&self) -> Option<&str>
pub fn scheme(&self) -> Option<&str>
Returns the request scheme.
The scheme of an absolute-form target, or the :scheme pseudo-header of
an HTTP/2 request, whose uri is in origin-form. Origin-form
HTTP/1 requests carry no scheme. It is not derived from the connection,
so it does not tell whether the request arrived over TLS.
Returns the request authority.
The authority of an absolute-form or authority-form target, or the
:authority pseudo-header of an HTTP/2 request, whose uri
is in origin-form. It is not taken from the Host header. It is
validated only if the server validates request targets.
Sourcepub fn extensions(&self) -> Ref<'_, Extensions>
pub fn extensions(&self) -> Ref<'_, Extensions>
Returns the request extensions.
Sourcepub fn extensions_mut(&self) -> RefMut<'_, Extensions>
pub fn extensions_mut(&self) -> RefMut<'_, Extensions>
Returns mutable access to the request extensions.
Sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Returns mutable access to the request headers.
Sourcepub fn headers_vec(&self) -> &[HeaderItem]
pub fn headers_vec(&self) -> &[HeaderItem]
Returns headers preserved in their original order and casing.
Sourcepub fn set_connection_type(&mut self, ctype: ConnectionType)
pub fn set_connection_type(&mut self, ctype: ConnectionType)
Sets the request connection behavior.
Connection types are flags, and calling this method again does not clear
a previously set type. When several are set, Close takes precedence
over KeepAlive, which takes precedence over Upgrade.
Sourcepub fn connection_type(&self) -> ConnectionType
pub fn connection_type(&self) -> ConnectionType
Returns the request connection behavior.
Sourcepub fn no_chunking(&mut self, val: bool)
pub fn no_chunking(&mut self, val: bool)
Enables or disables chunked transfer encoding.
A streaming request body without chunked coding requires a Content-Length header.
pub fn stream(&self) -> Option<&StreamRef>
Sourcepub fn peer_addr(&self) -> Option<SocketAddr>
pub fn peer_addr(&self) -> Option<SocketAddr>
Returns the peer socket address.
Peer address is actual socket address, if proxy is used in front of ntex http server, then peer address would be address of this proxy.
Sourcepub fn take_io(&self) -> Option<(IoBoxed, Codec)>
pub fn take_io(&self) -> Option<(IoBoxed, Codec)>
Takes ownership of the I/O stream and HTTP/1 codec for an upgrade.
The handle is installed only after an upgrade is acknowledged through
the HTTP/1 control service. This is a one-shot operation: subsequent
calls return None. Calls made from filter callbacks of the
connection return None and leave the handle in place.