pub struct HttpListener { /* private fields */ }Expand description
Cleartext HTTP/1.x listener.
§HTTP/2 over cleartext (h2c) is NOT supported
RFC 7540 §3.2 specified an Upgrade: h2c mechanism to negotiate HTTP/2
over a cleartext TCP connection, with a companion prior-knowledge
variant in §3.4. Both paths are intentionally absent from this listener:
- No
Upgrade: h2chandler: the HTTP/1.1 state machine forwardsUpgradeheaders to the backend but never responds101 Switching Protocolswith an HTTP/2 connection preface. - No prior-knowledge detection: the listener does not sniff the
24-byte
PRI * HTTP/2.0\r\n\r\nSM\r\n\r\nmagic string; a client that opens a TCP connection and immediately sends the preface will be interpreted as a malformed HTTP/1 request and rejected with 400.
RFC 9113 (the current HTTP/2 RFC, obsoleting 7540) formally deprecates
the Upgrade: h2c mechanism. Clients that want HTTP/2 MUST use the
TLS ALPN path (HttpsListener, selector h2) instead. This is
consistent with the industry consensus (nginx, envoy, cloudflare) and
removes an entire class of cleartext-preface smuggling primitives.
Implementations§
Source§impl HttpListener
impl HttpListener
pub fn new( config: HttpListenerConfig, token: Token, ) -> Result<HttpListener, ListenerError>
pub fn activate( &mut self, registry: &Registry, tcp_listener: Option<MioTcpListener>, ) -> Result<Token, ListenerError>
Sourcepub fn update_config(
&mut self,
patch: &UpdateHttpListenerConfig,
) -> Result<(), ListenerError>
pub fn update_config( &mut self, patch: &UpdateHttpListenerConfig, ) -> Result<(), ListenerError>
Apply a partial-update patch to this listener’s live configuration.
Fields absent in the patch (i.e. None) are preserved unchanged.
If http_answers is present only the listener-default templates are
replaced; per-cluster overrides in cluster_custom_answers are kept.
pub fn add_http_front( &mut self, http_front: HttpFrontend, ) -> Result<(), ListenerError>
pub fn remove_http_front( &mut self, http_front: HttpFrontend, ) -> Result<(), ListenerError>
Trait Implementations§
Source§impl L7ListenerHandler for HttpListener
impl L7ListenerHandler for HttpListener
fn get_sticky_name(&self) -> &str
Source§fn get_sozu_id_header(&self) -> &str
fn get_sozu_id_header(&self) -> &str
"Sozu-Id". Operators can rebrand via the
sozu_id_header listener config knob.fn get_connect_timeout(&self) -> u32
Source§fn frontend_from_request(
&self,
host: &str,
uri: &str,
method: &Method,
) -> Result<RouteResult, FrontendFromRequestError>
fn frontend_from_request( &self, host: &str, uri: &str, method: &Method, ) -> Result<RouteResult, FrontendFromRequestError>
Source§fn get_answers(&self) -> &Rc<RefCell<HttpAnswers>>
fn get_answers(&self) -> &Rc<RefCell<HttpAnswers>>
Source§fn get_h2_flood_config(&self) -> H2FloodConfig
fn get_h2_flood_config(&self) -> H2FloodConfig
Source§fn get_h2_connection_config(&self) -> H2ConnectionConfig
fn get_h2_connection_config(&self) -> H2ConnectionConfig
Source§fn get_h2_stream_idle_timeout(&self) -> Duration
fn get_h2_stream_idle_timeout(&self) -> Duration
Source§fn get_h2_graceful_shutdown_deadline(&self) -> Option<Duration>
fn get_h2_graceful_shutdown_deadline(&self) -> Option<Duration>
GOAWAY(NO_ERROR). Once the deadline elapses the mux
transitions to a forced close (final GOAWAY + session teardown). Read moreSource§fn get_elide_x_real_ip(&self) -> bool
fn get_elide_x_real_ip(&self) -> bool
X-Real-IP header from
forwarded requests (anti-spoofing). Read moreSource§fn get_send_x_real_ip(&self) -> bool
fn get_send_x_real_ip(&self) -> bool
X-Real-IP header carrying the
connection peer IP (post-PROXY-v2 unwrap, i.e. the original client
IP) to every forwarded request. Read moreSource§fn get_strict_sni_binding(&self) -> bool
fn get_strict_sni_binding(&self) -> bool
:authority / Host exact-match
the TLS SNI negotiated at handshake (CWE-346 / CWE-444). Read more