Skip to main content

ConnectionH1

Struct ConnectionH1 

Source
pub struct ConnectionH1<Front: SocketHandler> {
    pub position: Position,
    pub readiness: Readiness,
    pub requests: usize,
    pub socket: Front,
    pub stream: Option<usize>,
    pub timeout_duration: Duration,
    pub parked_on_buffer_pressure: bool,
    pub write_failed: bool,
    pub close_notify_sent: bool,
    pub session_ulid: Ulid,
    pub reused_from_pool: bool,
    /* private fields */
}
Expand description

HTTP/1.1 connection handler within the mux layer.

Manages a single HTTP/1.1 connection (either frontend or backend), handling request/response forwarding through kawa buffers. Supports keep-alive, chunked transfer encoding, close-delimited responses, and upgrade (e.g., WebSocket).

Fields§

§position: Position§readiness: Readiness§requests: usize§socket: Front§stream: Option<usize>

Active stream index, or None when the connection has no assigned stream (initial client state before start_stream, or after end_stream detaches).

§timeout_duration: Duration

Configured idle timeout for this connection. The core never arms a wheel entry itself: it publishes the next instant it wants to be called back at through ConnectionH1::poll_timeout, and the embedder — the Mux adapter — owns the TimeoutContainer that reflects it onto the real timer. See LIFECYCLE.md §7.7.

§parked_on_buffer_pressure: bool

Set when readable exits early because the kawa buffer was full. Edge-triggered epoll will not re-fire READABLE for data already in the kernel socket buffer, so the cross-readiness mechanism must re-arm it via try_resume_reading once the peer drains the buffer.

§write_failed: bool

A write to the client failed (reset, broken pipe or another socket error): nothing more can be flushed to it, so the connection reports no pending write and the session closes instead of waiting to flush.

§close_notify_sent: bool

True once we’ve asked rustls to emit TLS close_notify for this frontend.

§session_ulid: Ulid

Connection/session ULID propagated from the parent super::Mux. Used to stamp the session slot of the [session req cluster backend] log prefix emitted by the local log_context! macro.

§reused_from_pool: bool

True once this backend connection has served a stream that it picked up out of the H1 keep-alive pool, rather than on the fresh dial that created it.

This is pingora’s client_reused bit — the provenance the protocol layer cannot see but the retry decision needs.

It does NOT prove what the peer did. An EOF with no response is indistinguishable at this layer from a stale pool socket, from an origin that half-closed after processing the request but before answering, and from one that crashed mid-request: readable treats every size == 0 alike, and an empty back buffer proves only that no response byte arrived. What this bit does is bound the window in which sozu is willing to re-issue: a connection that came out of the pool has been idle long enough for its peer to have closed it unobserved, a freshly dialled one has not. What makes re-issuing permissible at all is the idempotence gate (RFC 9110 §9.2.2) in Stream::can_replay_on_fresh_upstream; this bit only narrows when that permission is exercised, so only a reused connection arms request capture (sozu-proxy/sozu#1442). Always false on a Position::Server connection.

Implementations§

Source§

impl<Front: SocketHandler> ConnectionH1<Front>

Source

pub fn readable<E, L>( &mut self, context: &mut Context<L>, endpoint: E, ) -> MuxResult

Source

pub fn writable<E, L>( &mut self, context: &mut Context<L>, endpoint: E, ) -> MuxResult

Source

pub fn force_disconnect(&mut self) -> MuxResult

Source

pub fn has_pending_write(&self) -> bool

Source

pub fn initiate_close_notify(&mut self) -> bool

Source

pub fn close<E, L>(&mut self, context: &mut Context<L>, endpoint: E)

Source

pub fn end_stream<L>(&mut self, stream: usize, context: &mut Context<L>)

Source

pub fn start_stream<L>( &mut self, stream: usize, context: &mut Context<L>, ) -> bool

Trait Implementations§

Source§

impl<Front: SocketHandler> Debug for ConnectionH1<Front>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Front> !Freeze for ConnectionH1<Front>

§

impl<Front> !RefUnwindSafe for ConnectionH1<Front>

§

impl<Front> !Send for ConnectionH1<Front>

§

impl<Front> !Sync for ConnectionH1<Front>

§

impl<Front> Unpin for ConnectionH1<Front>
where Front: Unpin,

§

impl<Front> UnsafeUnpin for ConnectionH1<Front>
where Front: UnsafeUnpin,

§

impl<Front> UnwindSafe for ConnectionH1<Front>
where Front: UnwindSafe,

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, 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.