Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fiddler not capturing HTTP requests from Java Application

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.

like image 627
Andrew Avatar asked Sep 10 '25 20:09

Andrew


2 Answers

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 ...
like image 153
Robert Avatar answered Sep 12 '25 11:09

Robert


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();
like image 42
foch Avatar answered Sep 12 '25 09:09

foch