如上述评论中所述,我看到以下选项:
- 使用像wireshark这样的外部数据包分析器
- 使用 httptrace 执行器,您可以在此处查看示例
- 写一个拦截器,你可以在这里看到
使用 httpTrace 执行器
httptrace提供有关 HTTP 请求/响应交换的信息。可以通过访问 /actuator/httptrace 来调用它。可以使用curl:
$ curl 'http://localhost:8080/actuator/httptrace' -i -X GET
或直接从浏览器,在本地机器上http://localhost:8080/actuator/httptrace。
信息以 JSON 格式提供:
HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 503
{
"traces" : [ {
"timestamp" : "2019-12-06T06:13:02.341Z",
"principal" : {
"name" : "alice"
},
"session" : {
"id" : "41a5c57b-112a-4b15-8ea9-05c5942e7e88"
},
"request" : {
"method" : "GET",
"uri" : "https://api.example.com",
"headers" : {
"Accept" : [ "application/json" ]
}
},
"response" : {
"status" : 200,
"headers" : {
"Content-Type" : [ "application/json" ]
}
},
"timeTaken" : 1
} ]
}