Add HttpAdapter interface for custom HTTP transport injection - #378
Add HttpAdapter interface for custom HTTP transport injection#378fcunha-recurly wants to merge 1 commit into
Conversation
e0e7359 to
8a75e94
Compare
Adversarial ReviewBlocking1. 2. Advisory3. 4. |
|
Adversarial review notes
Automated adversarial review by Claude. Actively looks for reasons the PR should not merge. Use your judgment. |
Introduces HttpAdapter (abstract base), DefaultHttpAdapter (built-in
https/http implementation), and HttpAdapterContract (contract test
harness) so users can inject a custom HTTP adapter at construction time
via new Client(apiKey, { httpAdapter: adapter }).
DefaultHttpAdapter owns gzip/deflate decoding, Content-Length, keep-alive
agents, timeout, and ECONNRESET retry. BaseClient and Http are refactored
to delegate transport entirely through the adapter interface. MockClient
and all existing tests are updated to the new (method, url, headers, body)
adapter signature. A lib/testing.js entry point exposes the contract suite
for adapter authors, and an integration test skips unless RECURLY_API_KEY
is set.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
8a75e94 to
d5e6778
Compare
All callers in the repo were updated in the same commit (
Fixed — replaced with
By design. Gzip is optional for custom adapters. The contract suite intentionally does not require it and the README documents the behavior.
Acknowledged. This is a server-side SDK so bundled environments are not the primary target. Happy to revisit if it becomes a real issue.
This behavior predates this PR — the same logic was in |
|
Code quality review ( Result: FAIL — 2 blocking, 5 advisory Blocking1. Duplicated 2. ECONNRESET retry logic has zero test coverage — Advisory3. Flaky "network failure" test — 4. 5. 6. Dead 7. |
Summary
HttpAdapterabstract base class with a singleexecute(method, url, headers, body)method that returnsPromise<HttpResponse>DefaultHttpAdapter(built-in implementation) which owns gzip/deflate decoding,Content-Length, keep-alive agents, timeout, and ECONNRESET retry — extracted from the previousHttp.makeRequestandBaseClientlogicnew Client(apiKey, { httpAdapter: adapter })— validated asinstanceof HttpAdapter, defaults toDefaultHttpAdapterHttpAdapter,DefaultHttpAdapter,HttpMethod, andHttpResponsefrom the top-levelrecurlymodulelib/testing.jsentry point exposingHttpAdapterContract.runSuitefor adapter authors to verify their implementationMockClient,BaseClient.test.js,Http.test.js, andPager.test.jsto the new adapter-based transport🤖 Generated with Claude Code