Skip to content

Conversation

@odrobnik
Copy link
Contributor

@odrobnik odrobnik commented Dec 8, 2025

Summary

  • aggregate HTTP request bodies without changing HTTPHandler initialization
  • expose request processing override via subclassing and update chunked-body test accordingly
  • keep full payload dispatch until request end to avoid partial handling

Testing

  • swift test --filter HTTPHandlerChunkedBodyTests

Codex Task


Note

Aggregate multi-chunk HTTP request bodies and add an overridable processRequest in HTTPHandler, with a unit test verifying chunk aggregation.

  • Transport (Sources/SwiftMCP/Transport/HTTPHandler.swift):
    • Aggregate multi-chunk request bodies by copying initial buffer and appending subsequent chunks before processing.
    • Add processRequest(context:head:body:) and call it on .end; keep handleRequest and delegate from processRequest.
    • Change HTTPHandler from final to class to enable subclassing.
  • Tests (Tests/SwiftMCPTests/HTTPHandlerTests.swift):
    • Add HTTPHandlerChunkedBodyTests using EmbeddedChannel and a TestHTTPHandler subclass overriding processRequest to assert body aggregation.

Written by Cursor Bugbot for commit b8553e3. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.


try await Task.sleep(nanoseconds: 100_000_000)

#expect(handler.capturedBody?.contains("\"jsonrpc\":\"2.0\"") == true)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Test doesn't verify second chunk aggregation actually works

The test named "Aggregates multi-chunk bodies before decoding" only asserts that "jsonrpc":"2.0" is present in the captured body, but this string is entirely contained in the first chunk. If the body aggregation logic were broken and only the first chunk was retained, the test would still pass. The assertion needs to verify content from the second chunk (such as "TestClient") to actually confirm that multi-chunk aggregation works correctly.

Fix in Cursor Fix in Web

@odrobnik odrobnik closed this Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants