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

Duplicated code between ApacheRequest and JdkRequest #223

Open
andreoss opened this issue Sep 3, 2020 · 0 comments
Open

Duplicated code between ApacheRequest and JdkRequest #223

andreoss opened this issue Sep 3, 2020 · 0 comments

Comments

@andreoss
Copy link
Collaborator

andreoss commented Sep 3, 2020

The difference between ApacheRequest and JdkRequest is the anonymous inter classes defining initial Wire for the primary connection (by using either JDK or apache-http client), otherwise two classes are the same and just delegate to BaseRequest.

Proposal:

  1. Extract inner Wire implementations as separate classes: JdkWire, ApacheWire
  2. Rename BaseRequest to RequestOn
new RequestOn(new JdkWire(...), url);
  1. Make JdkRequest & etc aliases for new RequestOn(new JdkWire(..), ..)

Thus:

  1. Bug-prone TrustedWire is no longer needed, we can pass SSLContext directly to the initial Wire.
    Solves: ApacheRequest.java:68-70: TrustedWire does not support... #202 TrustedWire changes SSLSocketFactory globally #178
  2. Method .through(Class<? extends Wire>), can be replaced by a simple and more obvious composition of different Wire objects, i.e
new RequestOn(new RetryWire(new LoggingWire(new JdkWire(...)))

There is no way to use Wire objects like that now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants