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
impl HttpPushSender
Sourcepub fn new() -> HttpPushSender
pub fn new() -> HttpPushSender
Creates a new HttpPushSender with the default 10-second request timeout
and default retry policy.
Sourcepub fn with_timeout(request_timeout: Duration) -> HttpPushSender
pub fn with_timeout(request_timeout: Duration) -> HttpPushSender
Creates a new HttpPushSender with a custom per-request timeout.
Sourcepub fn with_tls_config(tls_config: ClientConfig) -> HttpPushSender
Available on crate feature tls-rustls only.
pub fn with_tls_config(tls_config: ClientConfig) -> HttpPushSender
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.
Sourcepub const fn with_dns_timeout(self, timeout: Duration) -> HttpPushSender
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.
Sourcepub fn with_retry_policy(self, policy: PushRetryPolicy) -> HttpPushSender
pub fn with_retry_policy(self, policy: PushRetryPolicy) -> HttpPushSender
Sets a custom retry policy for push notification delivery.
Sourcepub const fn allow_private_urls(self) -> HttpPushSender
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.
Sourcepub fn with_allowed_hosts<I, S>(self, hosts: I) -> HttpPushSender
pub fn with_allowed_hosts<I, S>(self, hosts: I) -> HttpPushSender
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.
Sourcepub const fn https_only(self) -> HttpPushSender
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.
Sourcepub const fn with_proxy_resolved_names(self) -> HttpPushSender
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
impl Debug for HttpPushSender
Source§impl Default for HttpPushSender
impl Default for HttpPushSender
Source§fn default() -> HttpPushSender
fn default() -> HttpPushSender
Source§impl PushSender for HttpPushSender
impl PushSender for HttpPushSender
Source§fn max_delivery_duration(&self) -> Option<Duration>
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
fn allows_private_urls(&self) -> bool
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 moreSource§fn allows_webhook_url(&self, url: &str) -> bool
fn allows_webhook_url(&self, url: &str) -> bool
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
fn requires_https(&self) -> bool
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.Auto Trait Implementations§
impl !RefUnwindSafe for HttpPushSender
impl !UnwindSafe for HttpPushSender
impl Forget for HttpPushSender
impl Freeze for HttpPushSender
impl Move for HttpPushSender
impl Send for HttpPushSender
impl Sync for HttpPushSender
impl Unpin for HttpPushSender
impl UnsafeUnpin for HttpPushSender
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].