• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stacklok / toolhive / 25010200036

27 Apr 2026 05:37PM UTC coverage: 66.215% (+0.001%) from 66.214%
25010200036

push

github

web-flow
Strip Content-Length when wrapping tool filter response (#5077)

* Strip Content-Length when wrapping tool filter response

The toolFilterWriter buffers and may rewrite the response body to apply
tool filters or overrides. When the upstream sets an explicit
Content-Length (e.g. playwright-mcp on streamable-http), the rewritten
body usually has a different size and net/http rejects the write with
"http: wrote more than the declared Content-Length", sending zero body
bytes to the client. The MCP handshake then stalls at tools/list.

Drop Content-Length in WriteHeader so Go falls back to chunked transfer
encoding, which the MCP Streamable HTTP transport spec permits.

Fixes #5075

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Add regression test for Content-Length stripping

Without this test, a future refactor could silently revert the
toolFilterWriter.WriteHeader fix and reintroduce #5075 — TestToolFilterWriter_Flush
exercises WriteHeader but never asserts that an inbound Content-Length is
stripped. Adds a focused table test covering JSON+Content-Length,
SSE+Content-Length, and the no-Content-Length pass-through case.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Dan Barr <6922515+danbarr@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

1 of 1 new or added line in 1 file covered. (100.0%)

5 existing lines in 1 file now uncovered.

59432 of 89756 relevant lines covered (66.22%)

61.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.87
/pkg/transport/proxy/httpsse/http_proxy.go


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc