Repository navigation
feat(fetch): support custom Response constructor - #186
Conversation
Allows passing a Response constructor (e.g. srvx's `FastResponse`) via
`proxyFetch(addr, req, init, { Response })`. When set, the upstream
`IncomingMessage` is passed as the body as-is, skipping the
`Readable.toWeb()` conversion for Node-to-Node proxies.
Resolves #185
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #186 +/- ##
==========================================
+ Coverage 95.03% 95.05% +0.01%
==========================================
Files 8 8
Lines 806 809 +3
Branches 330 332 +2
==========================================
+ Hits 766 769 +3
Misses 35 35
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Resolves #185 (option 1).
Adds a
Responseoption toproxyFetch():When a custom constructor is set, the upstream
IncomingMessageis passed as the body as-is, with noReadable.toWeb(). Constructors that accept Node.js streams, like srvx'sFastResponse/NodeResponse, can then pipe it natively, so a Node-to-Node proxy (e.g. env-runner'srunner.fetch()) skips both stream conversions. httpxy still has no srvx dependency because the feature is opt-in.Status, statusText and headers are built the same way as before: hop-by-hop headers are stripped and multi-value headers like
set-cookieare kept. 204/304 still get anullbody. Without the option, nothing changes: the globalResponsewith a web stream body.Tests
test/fetch.test.ts, newResponse optionblock:IncomingMessageas its bodynullbody for 204Responsealso accepts the stream (async iterable)[email protected]:serve()+FastResponseproxies a 1 MB body and repeatedset-cookieheaders correctly.README and AGENTS.md are updated.
🤖 Generated with AI assistant
Summary by CodeRabbit
proxyFetchnow supports an optional customResponseconstructor, allowing upstream response bodies to be used as Node.js streams without conversion.Responseand web streams.