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.
Asked
Active
Viewed 2.4k times
26

Andrew
- 815
- 2
- 13
- 33
-
Is there a Java Servlet processing the post? – CFL_Jeff Mar 08 '12 at 16:03
-
are you sure it is not https traffic? – matcheek Mar 08 '12 at 16:05
-
There is not. I am using Apache's HTTPComponents to call an upload method from an API on the server. – Andrew Mar 08 '12 at 16:07
-
@matcheek It is HTTPS traffic. Can this be captured through Fiddler? – Andrew Mar 08 '12 at 16:07
-
yes you can: http://www.fiddler2.com/fiddler/help/httpsdecryption.asp – matcheek Mar 08 '12 at 16:11
3 Answers
20
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 ...
-
1The development server I am writting against uses a self signed certificate so I have written classes to trust all certificates. I have set the proxyHost and proxyPort properties, however I am still not seeing any traffic from the application through Fiddler. – Andrew Mar 08 '12 at 16:33
-
I was able to get this to work by using https in the properties and changing the local host to 127.0.0.1. – Andrew Mar 08 '12 at 16:46
-
2My change made it possible to view the HTTP GET request that uses HttpURLConnection. The POST request is using Apache's HttpComponents and I cannot see this traffic, still. – Andrew Mar 08 '12 at 16:55
-
@Andrew Using two independent technologies does not sound like a good design of your app (doubles the chance of problems). Anyway you can set the proxy in the apache http client: http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientExecuteProxy.java – Robert Mar 08 '12 at 18:16
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();

foch
- 1,039
- 10
- 21
0
With EasyRestClient use this:
ClientBuilder builder = new ResteasyClientBuilder().defaultProxy("localhost", 8888, "http");

user3227576
- 554
- 8
- 22