【问题标题】:WebClient max header sizeWebClient 最大标头大小
【发布时间】:2020-08-28 20:56:48
【问题描述】:

有什么方法可以配置响应的最大标头大小?

我从 netty 框架收到以下错误:

io.netty.handler.codec.TooLongFrameException: HTTP header is larger than 8192 bytes.
    at io.netty.handler.codec.http.HttpObjectDecoder$HeaderParser.newException(HttpObjectDecoder.java:983)
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 

显然反应堆added an API为此,但我看不到在spring Web Flux的WebClient中这是如何控制的。我正在使用以下版本

      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-webflux</artifactId>
        <version>2.3.2.RELEASE</version>
      </dependency>

有什么想法吗?

【问题讨论】:

  • 尝试在application.properties中设置server.max-http-header-size
  • 我认为这个问题的意思是关于 WebClient 响应的响应,而 server.max-http-header-size 限制传入请求的大小,如果我没记错的话。

标签: spring-webflux response-headers reactor-netty


【解决方案1】:

您可以将 reactor 的 reactor.netty.http.client.HttpClient 配置为具有自定义 maxHeaderSize 并将此预配置的 HttpClient 插入您的 WebClient 实例中。

HttpClient httpClient =
    HttpClient.create().httpResponseDecoder(spec -> spec.maxHeaderSize(32 * 1024));

WebClient webClient =
    WebClient.builder().clientConnector(new ReactorClientHttpConnector(httpClient))
    .build();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-12
    • 2011-02-06
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-02
    相关资源
    最近更新 更多