Skip to content

Commit a821a5e

Browse files
committed
docs(transport): describe redirect handling in default_http_client
Document on `from_uri` and `from_config` which redirects the default client follows, that a 308 does not change the stored URI, and that a client passed to `with_client` keeps its own redirect policy.
1 parent b2c18e3 commit a821a5e

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎crates/rmcp/src/transport/common/reqwest/streamable_http_client.rs‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,13 @@ impl StreamableHttpClientTransport<reqwest::Client> {
366366
/// let transport = StreamableHttpClientTransport::from_uri("http://localhost:8000/mcp");
367367
/// ```
368368
///
369+
/// # Redirects
370+
///
371+
/// The default client follows same-origin 307 and 308 redirects, up to 10
372+
/// hops. A 301, 302 or 303, or a redirect to another origin, returns an
373+
/// error. A 308 does not change the stored URI. To use another redirect
374+
/// policy, pass your own `reqwest::Client` to [`with_client`](Self::with_client).
375+
///
369376
/// # Feature requirement
370377
///
371378
/// This method requires the `transport-streamable-http-client-reqwest` feature.
@@ -385,6 +392,9 @@ impl StreamableHttpClientTransport<reqwest::Client> {
385392
/// # Arguments
386393
///
387394
/// * `config` - The config to use with this transport
395+
///
396+
/// Uses the same default client as [`from_uri`](Self::from_uri), including
397+
/// its redirect handling.
388398
pub fn from_config(config: StreamableHttpClientTransportConfig) -> Self {
389399
StreamableHttpClientTransport::with_client(Self::default_http_client(), config)
390400
}
@@ -401,7 +411,9 @@ impl StreamableHttpClientTransport<reqwest::Client> {
401411
/// would turn a POST into a bodyless GET and lose the message, and a
402412
/// cross-origin redirect would replay the session id and caller-supplied
403413
/// custom headers to another host, so both are returned to the caller as
404-
/// the redirect response instead.
414+
/// the redirect response instead. A followed 308 does not update the
415+
/// stored URI, so each request still starts at the configured one. A
416+
/// client passed to `with_client` keeps its own redirect policy.
405417
fn default_http_client() -> reqwest::Client {
406418
reqwest::Client::builder()
407419
.pool_max_idle_per_host(0)

0 commit comments

Comments
 (0)