How to enable wire logging for a java HttpURLConnection traffic?

后端 未结 8 955
离开以前
离开以前 2020-11-27 04:56

I\'ve used Jakarta commons HttpClient in another project and I would like the same wire logging output but using the \"standard\" HttpUrlConnection.

I\'ve used Fiddl

8条回答
  •  甜味超标
    2020-11-27 05:56

    What about using AspectJ to insert a Pointcut to add logging advice around a method? I believe AspectJ can weave it's way into private/protected methods.

    It appears that sun.net.www.protocol.http.HttpURLConnection.writeRequest may call sun.net.www.http.HttpClient.writeRequest which takes the MessageHeader Object as an input so that would be your target.

    In the end this might work but will be awfully fragile and only work on the Sun JVM; and really you could only trust the exact version you are using.

提交回复
热议问题