protected String readRequestBody() throws IOException{
String contentEncoding = getRequest().getHeader("Accept-Encoding");
String resStr = null;
if (contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip")) {
resStr = GzipUtils.gzipInput2String(getRequest().getInputStream());
}else{
StringBuilder sb = new StringBuilder();
try {
BufferedReader reader = getRequest().getReader();
String s = null;
while ((s = reader.readLine()) != null) {
sb.append(s);
}
} catch (IOException e) {
e.printStackTrace();
}
resStr = sb.toString();
}
return resStr;
}
获取http请求中的请求体的信息
最新推荐文章于 2024-06-28 21:55:38 发布