修正乱码问题
This commit is contained in:
@@ -24,6 +24,8 @@ import org.apache.commons.codec.digest.DigestUtils;
|
|||||||
import win.liyufan.im.ErrorCode;
|
import win.liyufan.im.ErrorCode;
|
||||||
import win.liyufan.im.RateLimiter;
|
import win.liyufan.im.RateLimiter;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
abstract public class RobotAction extends Action {
|
abstract public class RobotAction extends Action {
|
||||||
private final RateLimiter mLimitCounter = new RateLimiter(10, 1000);
|
private final RateLimiter mLimitCounter = new RateLimiter(10, 1000);
|
||||||
|
|
||||||
@@ -80,10 +82,15 @@ abstract public class RobotAction extends Action {
|
|||||||
if (request instanceof FullHttpRequest) {
|
if (request instanceof FullHttpRequest) {
|
||||||
FullHttpRequest fullHttpRequest = (FullHttpRequest) request;
|
FullHttpRequest fullHttpRequest = (FullHttpRequest) request;
|
||||||
byte[] bytes = Utils.readBytesAndRewind(fullHttpRequest.content());
|
byte[] bytes = Utils.readBytesAndRewind(fullHttpRequest.content());
|
||||||
String content = new String(bytes);
|
String content = null;
|
||||||
Gson gson = new Gson();
|
try {
|
||||||
T t = gson.fromJson(content, cls);
|
content = new String(bytes, "UTF-8");
|
||||||
return t;
|
Gson gson = new Gson();
|
||||||
|
T t = gson.fromJson(content, cls);
|
||||||
|
return t;
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user