[Feature Request] Http proxy support in version 7
deko2369 opened this issue · 7 comments
Feature Request
I want to use MessagingApiClient with HTTP proxy in version 7.
In version 6, LineMessagingClient is available via proxy using the following code:
// This is v6 code.
OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder();
Authenticator proxyAuthenticator =
(route, response) -> response
.request()
.newBuilder()
.header("Proxy-Authorization", "Bearer <token>")
.build();
okHttpClientBuilder
.proxy(
new Proxy(
Proxy.Type.HTTP,
new InetSocketAddress("proxy.example.com", 8080)
)
)
.proxyAuthenticator(proxyAuthenticator);
RetryableLineMessagingClient
.builder("token")
.okHttpClientBuilder(okHttpClientBuilder, true)
.build();
Ah, since version 7, SDK developers decide to hide the implementation detail of the HTTP client library. As a result, there's no hook point to set proxy configuration in version 7.
So, we need to add the interface to configure proxy...
And so, this document is not correct in version 7. https://github.com/line/line-bot-sdk-java#how-do-i-use-a-proxy-server
Thank you for your reply.
Do you have any plan to add proxy interface to MessagingApiClient?
Maybe the interface should be like this:
api = MessagingApiClient.builder("MY_OWN_TOKEN")
.apiEndPoint(URI.create(wireMockServer.baseUrl()))
.proxy(
new Proxy(
Proxy.Type.HTTP,
new InetSocketAddress("proxy.example.com", 8080)
)
)
.build();
(Proxy
object is java.net.Proxy
I proposed PR
Looks good to me!
In addition, proxy server may have authentication (using Proxy-Authorization
HTTP header), the client needs to have an interface to set Authenticator
instance.
https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/-builder/proxy-authenticator/
Thanks!