Open KostyantynFT opened 1 week ago
Hi @KostyantynFT thanks for posting this. Can I asked if you can try the following. Before you make the request, set the following properties with your values:
System.setProperty("http.proxyUser", "my-username");
System.setProperty("http.proxyPassword", "**************");
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
Yes, it works.
But I do not think we can use this approach. We have a big web-app and we call many different web-services and only for one of them we need to use a proxy (I spawn a Unirest instance for that).
At the moment I just added Unirest 3.14.1 to the pom, so we have both dependencies (3 and 4) and for these calls via proxy I use the old classes from kong.unirest.* packages. I think it should work this way.
Unfortunately this seems to be a limitation with Java itself
I think it would be useful to be able to select which client to use on creating/spawning Unirest - Java or Apache. The Apache client in 3.14.1 works perfectly. It is not very good to use a library that does not do so simple and common thing as proxy authentication.
Apache 4 does not support all the new features we need like HTTP2, and Websockets. Apache 5's async model is fully reactive and is incompatible with the way Unrest wants to do async, so it has never been able to "fit" as an engine.
Proxies with basic authorization do not work in Unirest 4 but works fine in 3.14.1.
It looks like the native Java client does not work correctly.
I setup a squid server with basic authorization.
Requests via Postman or Insomnia works fine.
But credentials are not provided when working via Unirest 4.4.4. So the proxy server returns the 407 error.
Here is the squid log. The first entry - a request with Unirest 3.14.1 - the user name is provided (ftproxy). The second entry - a request with Unirest 4.4.4 - the user name is empty and the request is denied.
Code:
Log: