Gar*_*son 9 eclipse jax-rs http-proxy resteasy
我似乎无法让JAX-RS客户端在Java 8上使用Web代理.我正在使用RESTEasy 3.0.10.Final,并在Windows 7 Professional 64位上运行Eclipse 4.4.2.
我在localhost运行时设置了一个FreeProxy服务器192.168.1.123:3128.我打开登录并telnet到192.168.1.123 3128并发出手册GET.请求显示在日志中.
然后我启动我的Java应用程序,设置http.proxyHost=192.168.1.123和http.proxyPort=3128系统属性.(我甚至-D在启动JVM时尝试使用它.)(注意,我不希望localhost问题发挥作用,因为我连接到实际的IP地址,而不是localhost.)
我使用ClientBuilder.newBuilder().build()并执行GET资源创建JAX-RS客户端.FreeProxy日志中没有显示任何内容.
为了让JAX-RS客户端使用代理,我该怎么办?
lef*_*loh 11
所述ResteasyClientBuilder提供以限定defaultProxy的方法:
ResteasyClient client = new ResteasyClientBuilder().defaultProxy("localhost", 8080, "http").build();
Run Code Online (Sandbox Code Playgroud)
似乎可以-Dhttp.proxyHost通过使用不同的引擎而不是.RESTeasy来使用Java的代理属性(例如) HttpClient。java.net.HttpURLConnection支持开箱即用的代理属性:
ResteasyClient client = new ResteasyClientBuilder().httpEngine(new URLConnectionEngine()).build();
Run Code Online (Sandbox Code Playgroud)