opengoofy/hippo4j

[Bug] Server-Example HTTP header line does not conform to RFC 7230 and has been ignored.

Pan-YuJie opened this issue · 0 comments

Search before asking

  • I had searched in the issues and found no similar issues.

Environment

Windows

Hippo4j version

1.5.0

What happened

在Server模式下,启动 ServerExampleApplication后其向ServerApplication发起请求出现 does not conform to RFC 7230 and has been ignored.(不符合 RFC 7230 并已被忽略)

ServerApplication控制台信息:
5feee933e5438295d41c2ac2ad5f454

ServerExampleApplication控制台信息:
2cb8da108ffb3035a38842b6f498b97

初步确认问题是:
高版本8.x后的 tomcat版本 中的新特性:就是严格按照 RFC 7230 规范进行访问解析。
请求地址传参时,在url中传了一段带有特殊字符的参数,参数中有不在RFC7230 中的保留字段中,所以会报这个错。

解决方法:
配置转义字符,解决当请求路径中特殊字符,解决高版本Tomcat对接口参数限制字符,解析失败从而出现RFC7230、RFC3986问题

@Configuration
public class RFC7230 {
 
    /**
     * 解决Tomcat RFC7230问题
     * @return
     */
    @Bean
    public ConfigurableServletWebServerFactory webServerFactory() {
        TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
        factory.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> {
            connector.setProperty("relaxedQueryChars", "|{}[](),/:;<=>?@[\\]{}\\");
            connector.setProperty("relaxedPathChars", "|{}[](),/:;<=>?@[\\]{}\\");
            connector.setProperty("rejectIllegalHeader", "false");
        });
 
        return factory;
    }
}


### How to reproduce

启动ServerApplication,后启动ServerExampleApplication出现

### Debug logs

_No response_

### Are you willing to submit PR?

- [X] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) *