Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HttpClient abstract class #879

Merged
merged 1 commit into from
Nov 1, 2019

Conversation

ob-stripe
Copy link
Contributor

@ob-stripe ob-stripe commented Nov 1, 2019

r? @brandur-stripe @richardm-stripe

(Targets ob-request-object until #878 is merged. You probably want to review #878 first.)

Renames HttpClient to HttpURLConnectionClient (because this client uses java.net.HttpURLConnection to make HTTP requests), and adds a new HttpClient abstract class.

This will make it easy to provide alternative implementations, e.g. to use a different HTTP library or to write a mock client.

I went with an abstract class rather than an interface because I expect that HttpClient will have some concrete methods. For instance, the request retry logic should be applicable regardless of the concrete HTTP client implementation.

The diff is hard to read because git/GitHub failed to pick up that HttpClient was renamed to HttpURLConnectionClient :/

@richardm-stripe
Copy link
Contributor

Is the hope here to enable users to substitute their favorite HTTP library? Or is it strictly for developers of stripe-java.

@richardm-stripe
Copy link
Contributor

Regardless,
lgtm

@ob-stripe ob-stripe changed the base branch from ob-request-object to integration-client-refactor November 1, 2019 16:40
@ob-stripe
Copy link
Contributor Author

Thanks Richard!

Is the hope here to enable users to substitute their favorite HTTP library? Or is it strictly for developers of stripe-java.

Both. There hasn't been a ton of demand for being able to use alternative HTTP libraries, but some users have been asking for an easier way to mock requests in their Stripe integration tests.

@ob-stripe ob-stripe merged commit 30b8687 into integration-client-refactor Nov 1, 2019
@ob-stripe ob-stripe deleted the ob-http-client-abstract branch November 1, 2019 16:49
@brandur-stripe
Copy link
Contributor

Great to finally see some movement on this Olivier! Nice one.

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.

3 participants