Fiddler not capturing HTTP requests from Java Application

不羁岁月 提交于 2019-12-03 09:37:06
Robert

You can simply set Fiddler as HTTP proxy for your application by setting the properties

http.proxyHost to localhost and http.proxyPort to 8888 for HTTP traffic and https.proxyHost / https.proxyPort for HTTPS traffic. For HTTPS traffic you also have to add the Fiddler root certificate (exportable in options dialog) as trusted certificate to your application.

You can do so by adding the following lines at the beginning of your code

System.setProperty("http.proxyHost", "localhost");
System.setProperty("http.proxyPort", "8888");

or set them via command line when starting the Java-VM:

java -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8888 ...

With Jetty HTTP client, the previous solution doesn't work. The following works however:

HttpClient httpClient = new HttpClient();
httpClient.setProxy(new Address("127.0.0.1", 8888));
httpClient.start();

With EasyRestClient use this:

ClientBuilder builder = new ResteasyClientBuilder().defaultProxy("localhost", 8888, "http");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!