#[non_exhaustive]pub struct StreamableHttpClientTransportConfig {
pub uri: Arc<str>,
pub retry_config: Arc<dyn SseRetryPolicy>,
pub channel_buffer_capacity: usize,
pub max_concurrent_requests: usize,
pub control_request_timeout: Duration,
pub session_recovery_timeout: Duration,
pub allow_stateless: bool,
pub auth_header: Option<String>,
pub custom_headers: HashMap<HeaderName, HeaderValue>,
pub max_sse_event_size: usize,
pub reinit_on_expired_session: bool,
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.uri: Arc<str>§retry_config: Arc<dyn SseRetryPolicy>§channel_buffer_capacity: usize§max_concurrent_requests: usizeMaximum number of ordinary http POSTs in progress (default: 16).
A POST stops counting when it completes or opens an sse response stream.
Zero is treated as one. Cancellation and replies use a separate queue
with one extra POST slot and use Self::control_request_timeout.
control_request_timeout: DurationMaximum time a cancellation or reply POST can run after it starts (default: five seconds). Time spent waiting in the control queue does not count toward this timeout.
session_recovery_timeout: DurationMaximum wait for old POSTs to finish before session recovery (default: five seconds).
The new initialization handshake has a separate timeout of the same length.
An unfinished old POST returns StreamableHttpError::SessionRecoveryTimeout
and is not retried because the server may have processed it.
allow_stateless: boolif true, the transport will not require a session to be established
auth_header: Option<String>The value to send in the authorization header
custom_headers: HashMap<HeaderName, HeaderValue>Custom HTTP headers to include with every request
max_sse_event_size: usizeMaximum raw size of one SSE event accepted from the server.
The built-in reqwest and Unix socket clients enforce this value. Custom
StreamableHttpClient implementations must override the corresponding
*_with_max_sse_event_size methods to enforce it.
reinit_on_expired_session: boolAutomatically creates a new session when the server reports an expired
session (http 404).
Ordinary POSTs that fail with SessionExpired in the same session share one
recovery attempt:
- Wait for old POSTs, up to
Self::session_recovery_timeout. - Repeat the original
initializehandshake and open new streams. - Retry each ordinary POST that failed with
SessionExpiredonce.
Control POSTs and other POST failures are not retried. If recovery or a retry fails, the transport returns an error to the caller.
Implementations§
Source§impl StreamableHttpClientTransportConfig
impl StreamableHttpClientTransportConfig
pub fn with_uri(uri: impl Into<Arc<str>>) -> StreamableHttpClientTransportConfig
Sourcepub fn max_concurrent_requests(
self,
limit: usize,
) -> StreamableHttpClientTransportConfig
pub fn max_concurrent_requests( self, limit: usize, ) -> StreamableHttpClientTransportConfig
Set how many ordinary POSTs can run at once. One keeps them serial; zero also means one.
Sourcepub fn control_request_timeout(
self,
timeout: Duration,
) -> StreamableHttpClientTransportConfig
pub fn control_request_timeout( self, timeout: Duration, ) -> StreamableHttpClientTransportConfig
Set the timeout for cancellation and reply POSTs, starting when each POST starts.
Sourcepub fn session_recovery_timeout(
self,
timeout: Duration,
) -> StreamableHttpClientTransportConfig
pub fn session_recovery_timeout( self, timeout: Duration, ) -> StreamableHttpClientTransportConfig
Set the separate timeouts for waiting for old POSTs and creating a replacement session.
Sourcepub fn auth_header<T>(self, value: T) -> StreamableHttpClientTransportConfig
pub fn auth_header<T>(self, value: T) -> StreamableHttpClientTransportConfig
Set the authorization header to send with requests
§Arguments
value- A bearer token without theBearerprefix
Sourcepub fn custom_headers(
self,
custom_headers: HashMap<HeaderName, HeaderValue>,
) -> StreamableHttpClientTransportConfig
pub fn custom_headers( self, custom_headers: HashMap<HeaderName, HeaderValue>, ) -> StreamableHttpClientTransportConfig
Set custom HTTP headers to include with every request
§Arguments
custom_headers- A HashMap of header names to header values
§Example
use std::collections::HashMap;
use http::{HeaderName, HeaderValue};
use rmcp::transport::streamable_http_client::StreamableHttpClientTransportConfig;
let mut headers = HashMap::new();
headers.insert(
HeaderName::from_static("x-custom-header"),
HeaderValue::from_static("custom-value")
);
let config = StreamableHttpClientTransportConfig::with_uri("http://localhost:8000")
.custom_headers(headers);Sourcepub fn max_sse_event_size(
self,
bytes: usize,
) -> StreamableHttpClientTransportConfig
pub fn max_sse_event_size( self, bytes: usize, ) -> StreamableHttpClientTransportConfig
Set the maximum raw size of one SSE event accepted from the server.
Sourcepub fn reinit_on_expired_session(
self,
enable: bool,
) -> StreamableHttpClientTransportConfig
pub fn reinit_on_expired_session( self, enable: bool, ) -> StreamableHttpClientTransportConfig
Set whether the transport should attempt transparent re-initialization on session expiration
See Self::reinit_on_expired_session for details.
§Example
use rmcp::transport::streamable_http_client::StreamableHttpClientTransportConfig;
let config = StreamableHttpClientTransportConfig::with_uri("http://localhost:8000")
.reinit_on_expired_session(true);Trait Implementations§
Source§impl Clone for StreamableHttpClientTransportConfig
impl Clone for StreamableHttpClientTransportConfig
Source§fn clone(&self) -> StreamableHttpClientTransportConfig
fn clone(&self) -> StreamableHttpClientTransportConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more