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.
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.
OK, This PR has be merged. I will submit another PR to do this fix.
Thanks for your review.
| return cookies; | ||
| } | ||
|
|
||
| public static String getCharsetFromContentType(String contentType) { |
There was a problem hiding this comment.
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