-
Notifications
You must be signed in to change notification settings - Fork 26.5k
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
Fix the issue where the charset from Content-Type is not parsed correctly, and refactor the related code. #15188
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 3.3 #15188 +/- ##
============================================
+ Coverage 60.74% 60.76% +0.02%
Complexity 10897 10897
============================================
Files 1885 1885
Lines 86071 86070 -1
Branches 12894 12892 -2
============================================
+ Hits 52286 52303 +17
+ Misses 28332 28319 -13
+ Partials 5453 5448 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
...oting-http12/src/test/java/org/apache/dubbo/remoting/http12/message/codec/HttpUtilsTest.java
Show resolved
Hide resolved
…ctly, and refactor the related code.
1dfff91
to
6781c13
Compare
@Stellar1999 rfc7231/3.1.1.1. Media Type According to the description in the RFC document, the Perhaps it is also necessary to define a new method:
|
Thanks for your review. |
charset = StringUtils.EMPTY_STRING; | ||
} else { | ||
charset = contentType.substring(index + CHARSET_PREFIX.length()).trim(); | ||
charset = charset.split(";")[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A tip, do not use split as it scans and slices the whole string and checks for regexp, use indexOf(char) for best performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, This PR has be merged. I will submit another PR to do this fix.
Thanks for your review.
@@ -81,6 +81,22 @@ public static List<HttpCookie> decodeCookies(String value) { | |||
return cookies; | |||
} | |||
|
|||
public static String getCharsetFromContentType(String contentType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parse or resolve will be btter than get.
parseCharset(String contentType)
Clear enough.
What is the purpose of the change?
Fix the issue where the charset from Content-Type is not parsed correctly, and refactor the related code.
Ref:issue #15187
Checklist