#[non_exhaustive]pub struct StreamableHttpClientTransportConfig {
pub uri: Arc<str>,
pub retry_config: Arc<dyn SseRetryPolicy>,
pub channel_buffer_capacity: usize,
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§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: boolEnables transparent recovery when the server reports an expired session (HTTP 404).
When enabled, the transport performs one automatic recovery attempt:
- Replays the original
initializehandshake to create a new session. - Re-establishes streaming state for that session.
- Retries the in-flight request that failed with
SessionExpired.
This recovery is best-effort and bounded to a single attempt. If recovery fails, the original failure path is preserved and the error is returned to the caller.
Implementations§
Source§impl StreamableHttpClientTransportConfig
impl StreamableHttpClientTransportConfig
pub fn with_uri(uri: impl Into<Arc<str>>) -> StreamableHttpClientTransportConfig
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