代码之家  ›  专栏  ›  技术社区  ›  Frischling

Reading POST body:java.lang.IllegalStateException:只允许一个连接接收订户

  •  0
  • Frischling  · 技术社区  · 7 年前

    在springwebflux中,当我阅读一篇博文,并尝试使用它时,它总是导致标题中的IllegalStateException。

      @Bean
      public RouterFunction<ServerResponse> selectByPost(SasoSecurityFacade solrHandler) {
        return RouterFunctions.route(RequestPredicates.POST("/v1/{collection}/select")
                                         .and(RequestPredicates.accept(MediaType.APPLICATION_JSON)), request -> request.bodyToMono(String.class)
            .flatMap(s -> {
              System.out.println(s);
              return ServerResponse.ok()
                  .syncBody(s);
            }));
      }
    

    同样重要的是(事实证明),对服务器的请求:

    curl 'https://<myserver>:9443/v1/banana-int/select' -H 'Pragma: no-cache' -H 'Origin: https://<myserver>:9443' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' -H 'Content-type: application/x-www-form-urlencoded' -H 'Accept: application/json, text/plain, */*' -H 'Cache-Control: no-cache' -H 'Referer: https://<myserver>:9443/banana/src/index.html' -H 'Connection: keep-alive' -H 'DNT: 1' --data 'q=*:*&rows=20&wt=json' --compressed
    

    我做错什么了?如何调试?还有谁在读我的帖子,所以我得到了这个错误信息?

    1 回复  |  直到 7 年前
        1
  •  3
  •   Brian Clozel    7 年前

    您发送的请求是POST-Form请求,由 HiddenHttpMethodFilter . 此筛选器正在使用表单数据来改变HTTP方法,以防通过 "_method" 参数。

    在这种情况下,使用专用的 request.formData()

    如果你想完全禁用这个行为, you'll be able to set a property in Spring Boot 2.1