Skip to main content

HttpListener

Struct HttpListener 

Source
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: h2c handler: the HTTP/1.1 state machine forwards Upgrade headers to the backend but never responds 101 Switching Protocols with 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\n magic 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

Source

pub fn new( config: HttpListenerConfig, token: Token, ) -> Result<HttpListener, ListenerError>

Source

pub fn activate( &mut self, registry: &Registry, tcp_listener: Option<MioTcpListener>, ) -> Result<Token, ListenerError>

Source

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.

Source

pub fn add_http_front( &mut self, http_front: HttpFrontend, ) -> Result<(), ListenerError>

Source

pub fn remove_http_front( &mut self, http_front: HttpFrontend, ) -> Result<(), ListenerError>

Trait Implementations§

Source§

impl L7ListenerHandler for HttpListener

Source§

fn get_sticky_name(&self) -> &str

Source§

fn get_sozu_id_header(&self) -> &str

Name of the correlation header Sozu injects into every request and response body. Default: "Sozu-Id". Operators can rebrand via the sozu_id_header listener config knob.
Source§

fn get_connect_timeout(&self) -> u32

Source§

fn frontend_from_request( &self, host: &str, uri: &str, method: &Method, ) -> Result<RouteResult, FrontendFromRequestError>

retrieve a frontend by parsing a request’s hostname, uri and method
Source§

fn get_answers(&self) -> &Rc<RefCell<HttpAnswers>>

retrieve the listener’s configured HTTP answers (templates)
Source§

fn get_h2_flood_config(&self) -> H2FloodConfig

H2 flood detection thresholds from the listener config. Returns the default config when the listener does not provide custom values.
Source§

fn get_h2_connection_config(&self) -> H2ConnectionConfig

H2 connection tuning from the listener config. Returns the default config when the listener does not provide custom values.
Source§

fn get_h2_stream_idle_timeout(&self) -> Duration

Per-stream idle timeout for H2 connections. An open stream that makes no forward progress for this duration is cancelled (RST_STREAM / CANCEL). Mitigates slow-multiplex Slowloris where a client keeps connection-level activity high (resetting the connection idle timer on every frame) while pinning streams for the full nominal connection timeout. Read more
Source§

fn get_h2_graceful_shutdown_deadline(&self) -> Option<Duration>

Wall-clock budget granted to in-flight H2 streams after soft-stop sent the initial GOAWAY(NO_ERROR). Once the deadline elapses the mux transitions to a forced close (final GOAWAY + session teardown). Read more
Source§

fn get_elide_x_real_ip(&self) -> bool

Whether to strip any client-supplied X-Real-IP header from forwarded requests (anti-spoofing). Read more
Source§

fn get_send_x_real_ip(&self) -> bool

Whether to append a proxy-generated X-Real-IP header carrying the connection peer IP (post-PROXY-v2 unwrap, i.e. the original client IP) to every forwarded request. Read more
Source§

fn get_strict_sni_binding(&self) -> bool

Whether requests must have their :authority / Host exact-match the TLS SNI negotiated at handshake (CWE-346 / CWE-444). Read more
Source§

impl ListenerHandler for HttpListener

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more