Getting Java HTTP Requests to appear in Fiddler

Fiddler is a handy tool to inspect http request/responses. When Fiddler starts-up by default it sets itself up to act as the proxy so any libraries that uses WinInet will have their http calls proxyied through Fiddler. For Java programs however you will need to instruct it to use Fiddler as a proxy if you want to see the calls in Fidder.

The properties you need to launch your Java application with, are:

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

Where 8888 is the default port that fiddler sets itself up, you can check this in Fiddler through Tools -> Fiddler Options

Refer to this StackOverflow post for more details

Few things to note :

  1. the above properties will work if you are using the standard Java libraries for making http requests. If you are using any other libraries for this (e.g. Commons HttpClient), then you’ll have to check if they have a different way of setting the proxy configurations.
  2. Secondly, requests for localhost for someone reason I can’t get them to go via the proxy (I guess the standard Java libraries has special rule for localhost). The work-round I had to employ is to use localhost. (note the dot after localhost this isn’t a typo )

If your using RestTemplate in conjunction with CommonsClientHttpRequestFactory (which uses Apache HttpClient underneath) then you need to set the HostConfiguration with proxy configuration. This blog I came across to describe the spring updates to do this

One Reply to “Getting Java HTTP Requests to appear in Fiddler”

Leave a Reply

Your email address will not be published.