Вопрос

I'm debugging some code that was written using java.net.HttpURLConnection. I'd like to set a property to enable logging of HTTP Request and Response headers as is possible in the Apache HTTP Components library with the org.apache.http.headers category.

Is this possible with HttpURLConnection? Do I need to breakout Charles Proxy or Wireshark?

Это было полезно?

Решение

According to Sun's HttpURLConnection source there is some logging support via JUL.

This would require setting up java.util.logging with sun.net.www.protocol.http.HttpURLConnection.level=ALL.

See http://www.rgagnon.com/javadetails/java-debug-HttpURLConnection-problem.html for example.

There is also system property -Djavax.net.debug=all. But it's mainly useful for SSL debugging.

BTW, Wireshark is also a rather easy option.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top