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] http header Content-Type not be parsed correctly #15187

Open
3 of 4 tasks
brookqin opened this issue Feb 28, 2025 · 1 comment
Open
3 of 4 tasks

[Bug] http header Content-Type not be parsed correctly #15187

brookqin opened this issue Feb 28, 2025 · 1 comment
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage

Comments

@brookqin
Copy link

brookqin commented Feb 28, 2025

Pre-check

  • I am sure that all the content I provide is in English.

Search before asking

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

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

Dubbo java 3.3.3 JDK 17

Steps to reproduce this issue

When the HTTP header Content-Type: multipart/form-data; charset=utf-8; boundary=__X_PAW_BOUNDARY__, a parsing exception will occur.

java.nio.charset.IllegalCharsetNameException: utf-8; boundary=__X_PAW_BOUNDARY__
	at java.base/java.nio.charset.Charset.checkName(Charset.java:328) ~[na:na]
	at java.base/java.nio.charset.Charset.lookup2(Charset.java:512) ~[na:na]
	at java.base/java.nio.charset.Charset.lookup(Charset.java:492) ~[na:na]
	at java.base/java.nio.charset.Charset.forName(Charset.java:556) ~[na:na]
	at org.apache.dubbo.remoting.http12.message.DefaultHttpRequest.getDecoder(DefaultHttpRequest.java:611) ~[dubbo-3.3.3.jar:3.3.3]
	at org.apache.dubbo.remoting.http12.message.DefaultHttpRequest.queryParameterValues(DefaultHttpRequest.java:441) ~[dubbo-3.3.3.jar:3.3.3]
	at org.apache.dubbo.remoting.http12.message.DefaultHttpRequest.queryParameter(DefaultHttpRequest.java:436) ~[dubbo-3.3.3.jar:3.3.3]
	at org.apache.dubbo.rpc.protocol.tri.rest.mapping.ContentNegotiator.negotiate(ContentNegotiator.java:78) ~[dubbo-3.3.3.jar:3.3.3]
	at org.apache.dubbo.rpc.protocol.tri.rest.mapping.RestRequestHandlerMapping.getRequestHandler(RestRequestHandlerMapping.java:90) ~[dubbo-3.3.3.jar:3.3.3]
	at org.apache.dubbo.rpc.protocol.tri.route.DefaultRequestRouter.route(DefaultRequestRouter.java:50) ~[dubbo-3.3.3.jar:3.3.3]
	at org.apache.dubbo.rpc.protocol.tri.h12.AbstractServerTransportListener.doRoute(AbstractServerTransportListener.java:122) ~[dubbo-3.3.3.jar:3.3.3]
	at org.apache.dubbo.rpc.protocol.tri.h12.AbstractServerTransportListener.onBeforeMetadata(AbstractServerTransportListener.java:118) ~[dubbo-3.3.3.jar:3.3.3]
	at org.apache.dubbo.rpc.protocol.tri.h12.AbstractServerTransportListener.onMetadata(AbstractServerTransportListener.java:85) ~[dubbo-3.3.3.jar:3.3.3]
	at org.apache.dubbo.rpc.protocol.tri.h12.AbstractServerTransportListener.onMetadata(AbstractServerTransportListener.java:54) ~[dubbo-3.3.3.jar:3.3.3]
	at org.apache.dubbo.remoting.http12.netty4.h1.NettyHttp1ConnectionHandler.channelRead0(NettyHttp1ConnectionHandler.java:56) ~[dubbo-3.3.3.jar:3.3.3]

What you expected to happen

Correctly parse HTTP header

Anything else

contentType should be split to list, not just substring

public String charset() {
String charset = this.charset;
if (charset == null) {
String contentType = contentType();
if (contentType == null) {
charset = StringUtils.EMPTY_STRING;
} else {
int index = contentType.lastIndexOf(HttpUtils.CHARSET_PREFIX);
charset = index == -1
? StringUtils.EMPTY_STRING
: contentType.substring(index + 8).trim();
}
this.charset = charset;
}
return charset.isEmpty() ? null : charset;
}

Are you willing to submit a pull request to fix on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

@brookqin brookqin added component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage labels Feb 28, 2025
@Stellar1999
Copy link
Contributor

Stellar1999 commented Feb 28, 2025

You're right. We'll fix it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage
Projects
Status: Todo
Development

No branches or pull requests

2 participants