feat(http): Add pluggable HttpAdapter interface for HTTP transport#334
Draft
douglasmiller wants to merge 3 commits into
Draft
feat(http): Add pluggable HttpAdapter interface for HTTP transport#334douglasmiller wants to merge 3 commits into
douglasmiller wants to merge 3 commits into
Conversation
Introduce HttpAdapter, HttpResponse, and DefaultHttpAdapter in the com.recurly.v3.http package. DefaultHttpAdapter wraps OkHttp and owns gzip negotiation, connection management, and timeout configuration. BaseClient now builds its headers map directly and delegates all transport to the injected adapter, removing the OkHttp dependency from the SDK core. ClientOptions gains setHttpAdapter() as the injection point. HeaderInterceptor is removed; its User-Agent logic moves to BaseClient. Co-Authored-By: Claude <noreply@anthropic.com>
Replace OkHttp transport with java.net.HttpURLConnection; remove okhttp and logging-interceptor compile dependencies. Preserve debug logging behind RECURLY_INSECURE + RECURLY_DEBUG using System.out.println. Fix 411 errors on POST/PUT with null body by sending Content-Length: 0, matching OkHttp prior behavior. Add contract tests for this case. Update the implementation guide to use OkHttp as the example adapter instead of java.net.http.HttpClient. Co-Authored-By: Claude <noreply@anthropic.com>
Send Accept-Encoding: gzip on every request and transparently decompress gzip-encoded responses in DefaultHttpAdapter. Covers both success and error response bodies. Two new contract tests verify decompression end-to-end. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduce a pluggable
HttpAdapterinterface that decouples the Recurly Java clientfrom any specific HTTP library. Replace the previous OkHttp-based implementation with
a
DefaultHttpAdapterbuilt on Java's built-inHttpURLConnection, removing the OkHttpdependency. Add automatic gzip decompression for HTTP responses and expose
ClientOptions.setHttpAdapter()so callers can inject a custom implementation.Testing
Setup / Prerequisites:
Happy Path:
mvn testExpected: BUILD SUCCESS, 0 failures
ClientOptionswith a customHttpAdapterimplementation and verifythe client uses it instead of the default.
Expected: custom adapter is called for each API request
Edge Cases / Error Cases:
Content-Encoding: gzipheaderExpected: body is transparently decompressed before parsing
IOExceptionExpected: wrapped in the appropriate Recurly exception type
Automated Test Coverage:
mvn testHttpAdapterContract,DefaultHttpAdapterContractTest,HttpResponseTest,BaseClientTest,HeaderInterceptorTest🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com