Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top