使用Fiddler监控使用RestTemplate发送网络请求的Java应用
发布日期:2021-06-30 14:04:10 浏览次数:2 分类:技术文章

本文共 727 字,大约阅读时间需要 2 分钟。

原始Java代码:

public static void getUserInfo() {				String responseStr = null;		RestTemplate template = new RestTemplate();		try {			String token = "1c393c0003ea";			String url = "https://jerrywang.com:9002/rest/v2/electronics/users/cris.li03@qq.com";						ResponseEntity
response = template.exchange(url, HttpMethod.GET, new HttpEntity
(createHeaders(token)), String.class); responseStr = response.getBody(); System.out.println("response: " + responseStr); }catch (Exception e) { System.out.println("the exception message is: "+e.getMessage()); } }

在这段代码执行之前,加上https代理即可:

Properties props = System.getProperties();		props.put("https.proxyHost", "localhost");		props.put("https.proxyPort", "8888");

转载地址:https://jerry.blog.csdn.net/article/details/103637010 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:使用Fiddler为满足某些特定格式的网络请求返回mock响应
下一篇:如何设置Fiddler来拦截Java代码发送的HTTP请求,进行各种问题排查

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2024年04月15日 18时14分15秒