Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
Pan-YuJie opened this issue Sep 4, 2023 · 0 comments
Closed
1 task done
Labels
type: bug Something isn't working

Comments

@Pan-YuJie
Copy link
Contributor

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) *
@Pan-YuJie Pan-YuJie added the type: bug Something isn't working label Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant