【问题标题】:Is it possible to dump the HTTP Headers when using java.net.HttpURLConnection?使用 java.net.HttpURLConnection 时是否可以转储 HTTP 标头?
【发布时间】:2012-09-06 07:55:06
【问题描述】:

我正在调试一些使用java.net.HttpURLConnection 编写的代码。我想设置一个属性来启用 HTTP 请求和响应标头的日志记录,这可以在 Apache HTTP 组件库中使用 org.apache.http.headers 类别。

HttpURLConnection 可以做到这一点吗?我需要突破 Charles Proxy 或 Wireshark 吗?

【问题讨论】:

标签: java http-headers wireshark apache-httpcomponents charles-proxy


【解决方案1】:

根据Sun's HttpURLConnection source,JUL 提供了一些日志记录支持。

这需要使用sun.net.www.protocol.http.HttpURLConnection.level=ALL 设置java.util.logging。

例如,请参阅http://www.rgagnon.com/javadetails/java-debug-HttpURLConnection-problem.html

还有系统属性-Djavax.net.debug=all。但主要是useful for SSL debugging

顺便说一句,Wireshark 也是一个相当简单的选择。

【讨论】:

  • 这正是我所需要的。来源始终是事实的来源,所以我应该先看看那里,但这似乎是不错的功能,我不知道为什么它没有出现在 Javadoc 中。
猜你喜欢
  • 2021-04-02
  • 2014-01-16
  • 1970-01-01
  • 2012-06-28
  • 2012-03-20
  • 2012-04-14
  • 2011-09-08
  • 2018-09-30
  • 2022-01-21
相关资源
最近更新 更多