环境:MAC进程
我研究了使用 MonoTouch、HttpClient 和 Charles Proxy 时的 HTTP 流量监控问题。
虽然我的问题与之类似,但我的应用程序正在使用RestTemplate http://docs.spring.io/autorepo/docs/spring-android/1.0.x/reference/html/rest-template.html。每当请求通过网络浏览器(具体来说是 Safari 和 Chrome)时,我都能够捕获 HTTP 和 HTTPS 流量,而当我通过我的应用程序(基本上使用 RestTemplate)发出休息请求时,Charles 代理不会捕获它们。
从上述问题的答案来看,应该是与RestTempate上的代理设置有关。但我是一名 .NET 开发人员,对 fiddler 非常熟悉 - 但最近转向 Java,对 Charles 还很陌生 - 因此,如果您能让我知道具体细节,或者您对配置 REST 模板以使用我的 macOS 代理的想法,那就太好了。 ..
基本上问题是如何配置我的休息模板(客户端),以便 charles Web 代理能够通过我的应用程序(客户端)捕获请求和响应。
其余模板由扩展 __https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/http/client/ SimpleClientHttpRequestFactory .html 的自定义请求工厂实例化。
看起来我需要做类似的事情(参考:http://docs.spring.io/spring-integration/reference/html/http.html#http-proxy)
<bean id="requestFactory"
class="org.springframework.http.client.SimpleClientHttpRequestFactory">
<property name="proxy">
<bean id="proxy" class="java.net.Proxy">
<constructor-arg>
<util:constant static-field="java.net.Proxy.Type.HTTP"/>
</constructor-arg>
<constructor-arg>
<bean class="java.net.InetSocketAddress">
<constructor-arg value="123.0.0.1"/>
<constructor-arg value="8080"/>
</bean>
</constructor-arg>
</bean>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)