Skip to content

Commit 114436b

Browse files
committed
fix(transport): reuse awaits_no_response and warn on ignored replies
1 parent 8837cfe commit 114436b

2 files changed

Lines changed: 4 additions & 18 deletions

File tree

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -360,14 +360,7 @@ impl StreamableHttpClient for reqwest::Client {
360360
let body = response.bytes().await?;
361361
match serde_json::from_slice::<ServerJsonRpcMessage>(&body) {
362362
Ok(parsed) => Ok(StreamableHttpPostResponse::Json(parsed, session_id)),
363-
Err(e)
364-
if matches!(
365-
message,
366-
ClientJsonRpcMessage::Notification(_)
367-
| ClientJsonRpcMessage::Response(_)
368-
| ClientJsonRpcMessage::Error(_)
369-
) =>
370-
{
363+
Err(e) if awaits_no_response => {
371364
tracing::warn!(
372365
"could not parse JSON response as ServerJsonRpcMessage, treating as accepted: {e}"
373366
);
@@ -385,7 +378,7 @@ impl StreamableHttpClient for reqwest::Client {
385378
// empty body, where an absent Content-Length stops the check above
386379
// from firing.
387380
_ if awaits_no_response => {
388-
tracing::debug!(
381+
tracing::warn!(
389382
"ignoring unexpected content type {content_type:?} on a POST that awaits no response"
390383
);
391384
Ok(StreamableHttpPostResponse::Accepted)

‎crates/rmcp/src/transport/common/unix_socket.rs‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,7 @@ impl StreamableHttpClient for UnixSocketHttpClient {
325325
.to_bytes();
326326
match serde_json::from_slice::<ServerJsonRpcMessage>(&body) {
327327
Ok(parsed) => Ok(StreamableHttpPostResponse::Json(parsed, session_id)),
328-
Err(e)
329-
if matches!(
330-
message,
331-
ClientJsonRpcMessage::Notification(_)
332-
| ClientJsonRpcMessage::Response(_)
333-
| ClientJsonRpcMessage::Error(_)
334-
) =>
335-
{
328+
Err(e) if awaits_no_response => {
336329
tracing::warn!(
337330
"could not parse JSON response as ServerJsonRpcMessage, treating as accepted: {e}"
338331
);
@@ -347,7 +340,7 @@ impl StreamableHttpClient for UnixSocketHttpClient {
347340
// from the body, so accept any 2xx rather than failing the send on an
348341
// unexpected or absent Content-Type.
349342
_ if awaits_no_response => {
350-
tracing::debug!(
343+
tracing::warn!(
351344
"ignoring unexpected content type {:?} on a POST that awaits no response",
352345
content_type
353346
);

0 commit comments

Comments
 (0)