Skip to content

perf(http): extract POST body as Bytes#159

Open
SVilgelm wants to merge 1 commit into
rust-mcp-stack:mainfrom
SVilgelm:perf/bytes-body-extraction
Open

perf(http): extract POST body as Bytes#159
SVilgelm wants to merge 1 commit into
rust-mcp-stack:mainfrom
SVilgelm:perf/bytes-body-extraction

Conversation

@SVilgelm
Copy link
Copy Markdown
Contributor

📌 Summary

The streamable-HTTP POST handler extracted the body as an owned String, allocating and copying on every request. It now extracts Bytes and borrows the body as UTF-8, avoiding the per-request allocation; non-UTF-8 bodies are rejected with 400.

🔍 Related Issues

✨ Changes Made

  • Replace the String extractor with Bytes in handle_streamable_http_post.
  • Borrow the bytes as &str (zero-copy) and reject invalid UTF-8 with 400.

Extract the streamable-HTTP POST body as Bytes and borrow it as UTF-8 instead of allocating an owned String per request; reject non-UTF-8 bodies with 400.

Assisted-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Sergey Vilgelm <sergey@vilgelm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant