Skip to content

Commit b96f0c6

Browse files
committed
refactor: narrow SSE limit public API surface
1 parent c1563e1 commit b96f0c6

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

crates/rmcp/src/transport/common/client_side_sse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::model::ServerJsonRpcMessage;
1515
pub type BoxedSseResponse = BoxStream<'static, Result<Sse, SseError>>;
1616

1717
/// Maximum raw size of one SSE event accepted from a remote server.
18-
pub const DEFAULT_MAX_SSE_EVENT_SIZE: usize = 16 * 1024 * 1024;
18+
pub(crate) const DEFAULT_MAX_SSE_EVENT_SIZE: usize = 16 * 1024 * 1024;
1919

2020
#[derive(Debug, Error)]
2121
enum BoundedSseStreamError {

crates/rmcp/src/transport/streamable_http_client.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ pub trait StreamableHttpClient: Clone + Send + 'static {
288288
+ '_;
289289
/// Send a message while enforcing a maximum raw SSE event size.
290290
///
291+
/// `max_sse_event_size` is not a per-request option: it is the
292+
/// transport-wide [`StreamableHttpClientTransportConfig::max_sse_event_size`]
293+
/// value, passed identically on every call because the limit must be applied
294+
/// inside the client (at the raw byte layer, before SSE parsing) rather than
295+
/// by the caller.
296+
///
291297
/// Custom clients that parse SSE responses should override this method.
292298
/// The default implementation delegates to [`Self::post_message`].
293299
fn post_message_with_max_sse_event_size(
@@ -326,6 +332,12 @@ pub trait StreamableHttpClient: Clone + Send + 'static {
326332
+ '_;
327333
/// Open an SSE stream while enforcing a maximum raw event size.
328334
///
335+
/// `max_sse_event_size` is not a per-request option: it is the
336+
/// transport-wide [`StreamableHttpClientTransportConfig::max_sse_event_size`]
337+
/// value, passed identically on every call because the limit must be applied
338+
/// inside the client (at the raw byte layer, before SSE parsing) rather than
339+
/// by the caller.
340+
///
329341
/// Custom clients that parse SSE responses should override this method.
330342
/// The default implementation delegates to [`Self::get_stream`].
331343
fn get_stream_with_max_sse_event_size(

crates/rmcp/src/transport/streamable_http_server.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ pub mod session;
33
pub mod tower;
44
pub use session::{RestoreOutcome, SessionId, SessionManager, SessionRestoreMarker};
55
#[cfg(all(feature = "transport-streamable-http-server", not(feature = "local")))]
6-
pub use tower::{
7-
DEFAULT_MAX_REQUEST_BODY_BYTES, StreamableHttpServerConfig, StreamableHttpService,
8-
};
6+
pub use tower::{StreamableHttpServerConfig, StreamableHttpService};

crates/rmcp/src/transport/streamable_http_server/tower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use crate::{
3939
};
4040

4141
/// Default maximum POST request body size (4 MiB).
42-
pub const DEFAULT_MAX_REQUEST_BODY_BYTES: usize = 4 * 1024 * 1024;
42+
pub(crate) const DEFAULT_MAX_REQUEST_BODY_BYTES: usize = 4 * 1024 * 1024;
4343

4444
#[non_exhaustive]
4545
#[derive(Debug, Clone)]

0 commit comments

Comments
 (0)