Saturday, March 11, 2017

Use Fidder to debug http request from java application

Fiddler is a very handy tool for http related debug.  After starting, it automatically start to capture any http request go through system proxy. Also it by default listen to port 8888. For debug Java application, we stop the automatic capturing, only use the port 8888.  


This articlae is for debug HTTP  request from java application, if the java application send out HTTPS request, please go to this article


You have a java application, which send http requestion out.  For debugging purpose, You want to find out what exactly be sent out as well as its response.



Set http proxy for JVM either from java command or inside java code, here is a simple example by setting System properties in Java code.

package com.shengwang.demo;

import org.springframework.web.client.RestTemplate;

public class DemoMain {
  public static void main(String[] args) {
    enableHttpProxy(); // set system properties for http proxy
    RestTemplate restTemplate = new RestTemplate();
    String text = restTemplate.getForObject("", String.class);

  public static void enableHttpProxy() {
    System.setProperty("http.proxyHost", "");
    System.setProperty("http.proxyPort", "8888");

This simple code just try to access After running it, we should be able to see the Http request and response from fiddler like below.



Post a Comment

Powered by Blogger.

About The Author

My Photo

Has been a senior software developer, project manager for 10+ years. Dedicate himself to Alcatel-Lucent and China Telecom for delivering software solutions.


Unordered List