Fiddler not capturing HTTP requests from Java Application

别等时光非礼了梦想. 提交于 2019-12-09 07:43:26

问题


I am currently writing a java application that uses HTTP POST to upload a csv file and a few other parameters to a server. The server keeps returning 500 errors to my application and I would like to view the HTTP request in Fiddler so I can see the POST request.
When I run Fiddler it will not capture any HTTP traffic from the Java application. I have written a GET request that works, so I know I can communicate with the server, however no traffic is shown through Fiddler.


回答1:


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 ...



回答2:


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();



回答3:


With EasyRestClient use this:

ClientBuilder builder = new ResteasyClientBuilder().defaultProxy("localhost", 8888, "http");


来源:https://stackoverflow.com/questions/9620720/fiddler-not-capturing-http-requests-from-java-application

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