square / okhttp

Square’s meticulous HTTP client for the JVM, Android, and GraalVM.
https://square.github.io/okhttp/
Apache License 2.0
45.77k stars 9.15k forks source link

Changing proxy dynamically #8023

Closed MohammadFakhraee closed 1 year ago

MohammadFakhraee commented 1 year ago

I'm using OkHttpClient with Retrofit which both are injected using Dagger Hilt. But I need an option to change proxy (which is currently set to OkHttpClient using '.proxy()') dynamically.

The situation that I am trying to implement is as so: I wanna request to an end point which returns a list of host-port pairs. I wanna set one or all of the configs in OkHttpClient to use these proxies if there is any.

I even created a stackoverflow question here but no one has responded. I also saw this question in stackoverflow but no one responded to that either. Any suggestion to implement this work?

yschimke commented 1 year ago

Why not implement ProxySelector and put your logic in there?

Closing as I think this is already supported API.