Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.58k stars 591 forks source link

Please add .proxy(host, port, username, password) method to the request scope #450

Closed zjor closed 1 year ago

zjor commented 1 year ago

There is Unirest.config().proxy(...) method which allows adding an authenticated Proxy

I need to be able to call Unirest.post(...).proxy(...)... and specify authenticated proxy per request, without setting the proxy for all requests in the whole app.

Please add a method accepting either username/password or the whole Proxy object.

ryber commented 1 year ago

People have asked for this before and unfortunately it is NOT possible because the proxy is part of the root client config and setting it per request would require each request to re-build the client which would destroy performance and cause a lot of thread flailing.

ryber commented 1 year ago

this is sort of complete in 3.14.0 you can try it, It takes a full "Proxy" object rather than the 4 params. I'm not convinced that it will actually pass the auth though, I'm pretty sure I tried that once upon a time and Apache wouldn't do it because the auth is only configurable on the full client and not per request, but give it a shot and let me know.

4.0.0-RC6 does not have this because the Java HttpClient doesn't have Proxy per request.