gpt4 book ai didi

http - Charles 没有在我的 MAC pro 中捕获来自 Java 客户端(客户端基于 spring rest 模板)的 HTTP 请求

转载 作者:可可西里 更新时间:2023-11-01 16:37:08 26 4
gpt4 key购买 nike

环境:MAC Proc

我看过HTTP Traffic monitoring issue when using MonoTouch, HttpClient and Charles Proxy .

虽然我的问题与之类似,但我的应用程序使用的是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 - 所以如果你能让我知 Prop 体细节,或者你对配置 rest 模板以使用我的 mac os 代理的想法,那就太好了。 ..

基本上问题是如何配置我的 rest 模板(客户端),以便 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>

最佳答案

我也遇到了类似的问题。但我使用的是 JUnit 和核心 Java。下面是一个链接,在一些情况下对我有帮助。

https://www.charlesproxy.com/documentation/configuration/browser-and-system-configuration/

你可以去JAVA APPLICATION PROXY CONFIGURATION找答案。

You can configure your Java application to use Charles in code or as command line arguments to the java executable.

System.setProperty("http.proxyHost", "127.0.0.1");

System.setProperty("http.proxyPort", "8888");

对于 HTTPS 也是如此。请注意,您可能还需要配置 Java 在这种情况下信任 Charles 的根证书(请参阅 SSL 代理)。

关于http - Charles 没有在我的 MAC pro 中捕获来自 Java 客户端(客户端基于 spring rest 模板)的 HTTP 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33336584/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com