环境:MAC Proc
我在使用 MonoTouch、HttpClient 和 Charles Proxy 时查看了 HTTP 流量监控问题。
虽然我的问题与它类似,但我的应用程序正在使用RestTemplate http://docs.spring.io/autorepo/docs/spring-android/1.0.x/reference/html/rest-template.html。每当通过 Web 浏览器(特别是 Safari 和 Chrome)发出请求时,我都能够捕获 HTTP 和 HTTPS 流量,而当我通过我的应用程序(基本上使用 RestTemplate)发出休息请求时,Charles 代理没有捕获它们。
从以上问题的回答来看,应该是RestTempate上的设置代理设置相关的东西。但是我是一个 .NET 开发人员并且非常熟悉提琴手——但最近转移到 Java 并且对 Charles 来说是新的——所以如果你能告诉我具体的细节,或者你对配置 rest 模板以使用我的 mac os 代理的想法,那就太好了。 ..
基本上问题是如何配置我的休息模板(客户端),以便 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>