Skip to main content

HttpPushSender

Struct HttpPushSender 

Source
pub struct HttpPushSender { /* private fields */ }
Expand description

HTTP-based PushSender using hyper.

Retries failed deliveries according to a configurable PushRetryPolicy.

§Transport

With the tls-rustls feature (enabled by default via the a2a-protocol-sdk crate) this sender delivers over both http:// and https:// — the latter being the norm for production and what the A2A spec’s webhook field describes. Without the feature it is plaintext-HTTP only and fails fast on an https:// target with a clear, actionable error rather than a late, opaque connector failure.

You can always supply a fully custom TLS stack via RequestHandlerBuilder::with_push_sender; PushSender is a public, object-safe trait.

§HTTPS and DNS-rebinding

The SSRF pre-flight (validate_webhook_url_with_dns) always runs, rejecting webhooks that resolve to private/loopback/link-local addresses, and the delivery then connects only to the addresses it checked, to close the DNS-rebinding window between the check and the connect. For https:// the connection has to ask for the host name (SNI and the certificate are checked against it), so the client’s resolver is told that the name is those addresses for the length of the delivery; the certificate is still verified against the name. http:// is pinned the same way since 0.16.0; it was rewritten to the address, which matched the proxy rules, NO_PROXY included, against the address and not the name (audit NEW-b-4, ADR 0043). Until 0.16.0 https:// was not pinned and relied on TLS alone, which stops a rebound server from impersonating the host but not a TCP connection and a ClientHello to an internal address (audit D-13, SEC-13).

A host with several addresses is tried in turn by the connector, in the resolver’s order, within each attempt (audit B-13). Behind a proxy the proxy resolves the name, so there is no pin; see docs/audits/2026-11-01-triage/DECISIONS.md, F16, and with_proxy_resolved_names.

§Security

  • Rejects webhook URLs targeting private/loopback/link-local addresses to prevent SSRF attacks (including IPv4-in-IPv6 smuggling), and pins the validated IP against DNS-rebinding between validation and connect.
  • Validates authentication credentials to prevent HTTP header injection (rejects values containing CR/LF characters).

Implementations§

Source§

impl HttpPushSender

Source

pub fn new() -> HttpPushSender

Creates a new HttpPushSender with the default 10-second request timeout and default retry policy.

Source

pub fn with_timeout(request_timeout: Duration) -> HttpPushSender

Creates a new HttpPushSender with a custom per-request timeout.

Source

pub fn with_tls_config(tls_config: ClientConfig) -> HttpPushSender

Available on crate feature tls-rustls only.

Creates an HttpPushSender that delivers HTTPS using a custom rustls ClientConfig instead of the default Mozilla root store.

Use this to trust an internal/private CA for webhook endpoints, or to present a client certificate for mutual TLS. Uses the default per-request timeout and retry policy (chain with_retry_policy to change them). http:// targets are still delivered in plaintext.

Requires the tls-rustls feature.

Source

pub const fn with_dns_timeout(self, timeout: Duration) -> HttpPushSender

Bounds the SSRF pre-flight’s DNS lookup. Default: 5 seconds.

send resolves the webhook’s hostname before its first request so the resolved address can be checked against the private ranges and pinned. That lookup had no bound of its own until 0.12: a resolver that hung spent the whole push_delivery_timeout before any request was made, and timeout_outcome then reported TIMEOUT — “go and look at the endpoint” — for a resolver problem. A lookup past this bound fails the delivery with an error naming the hostname and the bound, and the bound is counted in max_delivery_duration.

Source

pub fn with_retry_policy(self, policy: PushRetryPolicy) -> HttpPushSender

Sets a custom retry policy for push notification delivery.

Source

pub const fn allow_private_urls(self) -> HttpPushSender

Creates an HttpPushSender that allows private/loopback URLs.

Warning: This disables SSRF protection and should only be used in testing or trusted environments.

Source

pub fn with_allowed_hosts<I, S>(self, hosts: I) -> HttpPushSender
where I: IntoIterator<Item = S>, S: AsRef<str>,

Delivers only to webhooks whose host is one of hosts (spec §13.2: implement URL allowlists where appropriate). Hosts compare exactly, ignoring ASCII case, against the URL’s host without its port; no wildcards. A push config naming any other host is refused when it is created, and a delivery to one is refused before any connection is made. The SSRF checks still apply to allowed hosts.

Source

pub const fn https_only(self) -> HttpPushSender

Delivers only to https:// webhooks (spec §13.2: webhook URLs SHOULD use HTTPS). A push config with any other scheme is refused when it is created, and a delivery to one is refused before any connection is made. Off by default, so http:// webhooks are delivered in plaintext unless this is set.

Source

pub const fn with_proxy_resolved_names(self) -> HttpPushSender

Behind a proxy that resolves names itself, delivers to a webhook whose name this process cannot resolve, instead of failing it (audit NEW-b-1, ADR 0043). Off by default.

The SSRF screen resolves a webhook’s host here and refuses a private answer. Where this process’s resolver answers only internal names and every external request goes through a proxy (Squid, Zscaler and their like), that lookup fails for every external webhook. With this set, when the proxy rules send a webhook through a proxy and the lookup gets no answer (no record, NXDOMAIN, or the with_dns_timeout bound), the delivery goes to the proxy by name. The name is still screened by its form (localhost, *.internal, a numeric IPv4 spelling, …), and a name that does resolve here is still refused when any answer is private.

The proxy is then the screen for names only it can resolve, an internal name behind split-horizon DNS among them: deny private, loopback, link-local and metadata addresses in its own policy before turning this on. A destination NO_PROXY exempts goes direct and must resolve here as before.

Trait Implementations§

Source§

impl Debug for HttpPushSender

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for HttpPushSender

Source§

fn default() -> HttpPushSender

Returns the “default value” for a type. Read more
Source§

impl PushSender for HttpPushSender

Source§

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

max_attempts requests at request_timeout each, plus the backoff between them. backoff is consulted by index and falls back to its last entry, which is what the retry loop below actually does — the arithmetic here has to match that loop or the number it reports is a second thing to keep in step by hand.

Source§

fn allows_private_urls(&self) -> bool

Returns true if this sender allows webhook URLs targeting private/loopback addresses. Used by the handler to skip SSRF validation at push config creation time in testing environments. Read more
Source§

fn allows_webhook_url(&self, url: &str) -> bool

Whether this sender will deliver to url at all, checked when a push config is created so a URL the sender would refuse is rejected then, not stored. Default: true. HttpPushSender answers from its with_allowed_hosts allowlist.
Source§

fn requires_https(&self) -> bool

Whether this sender delivers only to https:// webhooks, checked when a push config is created so an http:// URL is refused then, with a reason. Default: false. HttpPushSender answers from https_only.
Source§

fn send<'a>( &'a self, url: &'a str, event: &'a StreamResponse, config: &'a TaskPushNotificationConfig, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>

Sends a streaming event to the client’s webhook URL. Read more

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
§

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

§

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

§

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

§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

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

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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