springboot mitre HTTP Proxy Servlet POST hang timeout 不执行的解决方案

最近在玩 mitre HTTP-Proxy-Servlet 。 最开始在网上找的例子是 jetty 容器的。代理转发post么有问题。

集成到 springboot 里后,发现 get 方法OK, post方法老是等待中,并且最后 timeout.

邪门了,找了半天原因没找到。 然后又重新运行 jetty的例子,发现一切ok, 这就说明不是 proxy源码的锅,是springboot的。

然后看 proxy github的说明,发现了类似的备注蛛丝马迹。(在springboot或者springMVC框架里,post表单 会提前消费,也就是优先级执行大于新加的proxyservlet)

 

 

 然后看issue看了半天

https://github.com/mitre/HTTP-Proxy-Servlet/issues/83    [POST will hang at execute]

最后找到这个人的回复,应该是说明上对应的 disabling FilterRegistrationBean. 。(其实应该写 disable HiddenHttpMethodFilter 更好理解! )

 

  @Bean
    public FilterRegistrationBean registration(HiddenHttpMethodFilter filter) {
        FilterRegistrationBean registration = new FilterRegistrationBean(filter);
        registration.setEnabled(false);
        return registration;
    }

 

 至此,解决问题。感谢开源!

https://stackoverflow.com/questions/8522568/why-is-httpservletrequest-inputstream-empty

 

提前消费的原因应该是这个spring的源码。

 

posted @ 2020-06-30 08:11  断舍离-重学JAVA之路  阅读(974)  评论(0编辑  收藏  举报