oxsean commented on code in PR #15188:
URL: https://github.com/apache/dubbo/pull/15188#discussion_r1976990285
##########
dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/HttpUtils.java:
##########
@@ -81,6 +81,22 @@ public static List<HttpCookie> decodeCookies(String value) {
return cookies;
}
+ public static String getCharsetFromContentType(String contentType) {
+ String charset = null;
+ if (contentType == null) {
+ charset = StringUtils.EMPTY_STRING;
+ } else {
+ int index = contentType.lastIndexOf(CHARSET_PREFIX);
+ if (index == -1) {
+ charset = StringUtils.EMPTY_STRING;
+ } else {
+ charset = contentType.substring(index +
CHARSET_PREFIX.length()).trim();
+ charset = charset.split(";")[0];
Review 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.
##########
dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/HttpUtils.java:
##########
@@ -81,6 +81,22 @@ public static List<HttpCookie> decodeCookies(String value) {
return cookies;
}
+ public static String getCharsetFromContentType(String contentType) {
Review Comment:
parse or resolve will be btter than get.
parseCharset(String contentType)
Clear enough.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]