spring-webflux - Spring Webflux Reactor Netty : HTTP Request/Response Hex Dump?

标签 spring-webflux reactor-netty

我们必须在 application.properties 中设置什么日志级别才能在 reactor-netty 的控制台中以 hex dump 的形式查看完整的 HTTP 请求和响应以及 header 和正文?

logging.level.reactor.netty=trace

仅显示响应 http header 。

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 248
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1 ; mode=block
Referrer-Policy: no-referrer

最佳答案

保持日志记录级别为 DEBUG 或 TRACE 并按照以下说明操作:

  1. 如果您想查看服务器的hex dump,您可以像这样自定义它:
@Component
public class MyNettyWebServerCustomizer
        implements WebServerFactoryCustomizer<NettyReactiveWebServerFactory> {
    @Override
    public void customize(NettyReactiveWebServerFactory factory) {
        factory.addServerCustomizers(httpServer -> httpServer.wiretap(true));
    }
}
  1. 如果您想查看客户端的hex dump,那么您可以像这样自定义它:
WebClient.builder()
        .clientConnector(new ReactorClientHttpConnector(HttpClient.create().wiretap(true)))
        .build();

关于spring-webflux - Spring Webflux Reactor Netty : HTTP Request/Response Hex Dump?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55275393/

相关文章:

java - 使用 Spring Web 客户端发送带有查询参数的 HTTP 通知

java - 为什么我的 Spring webflux 应用程序在每个请求上都会生成临时文件?

spring - 为 WebTestClient 禁用 TLS 证书检查

java - Spring 5 webflux 如何为现有 Webclient 设置超时

Netty HttpClient - 响应超时与读取超时

java - 如何在 HttpDecompressor 之前添加 GlobalTrafficShapingHandler

java - Spring Webflux : Extract a value from a Mono and save it into another variable

java - Spring Cloud 网关: Modified Response Body is Truncated

java - 在 Reactor Netty HttpClient/HttpServer 配置中,我无法在发送到服务器的帖子上检索请求对象

spring-boot - 配置多个 OAuth2 授权服务器和单个资源服务器之间的通信