Fiddler 调试 HTTP Java 应用程序

1、关闭自动抓取,只监听 8888 端口。

点击 Capturing

2、设置 http 代理服务器信息。

/**
 * 设置http代理
 * */
public void enableHttpProxy() {
    System.setProperty("http.proxyHost", "127.0.0.1");
    System.setProperty("http.proxyPort", "8888");
}

3、使用 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("http://wx.sanguosha.com/api/clock/do", String.class);
        System.out.println(text);
    }


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

4、Fiddler 抓包查看。

作者:magic_kid_2010,如果觉得笔者的博客对您有所帮助,欢迎【犒赏

发布了82 篇原创文章 · 获赞 13 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/magic_kid_2010/article/details/101195695