public RequestWrapper(HttpServletRequest request) {
int contentLength = request.getContentLength();
StringBuilder stringBuilder =
new StringBuilder();
InputStream inputStream =
null;
try {
inputStream = request.getInputStream();
}
catch (IOException e) {
}
if (inputStream !=
null) {
try (BufferedReader bufferedReader =
new BufferedReader(
new InputStreamReader(inputStream))) {
char[] charBuffer =
new char[contentLength];
int bytesRead;
while ((bytesRead = bufferedReader.read(charBuffer)) >
0) {
stringBuilder.append(charBuffer,
0, bytesRead);
}
}
catch (IOException e) {
}
}
else {
stringBuilder.append(
"");
}
body = stringBuilder.toString();
}
public ServletInputStream getInputStream()
throws IOException {
return new ServletInputStreamWrapper(
new ByteArrayInputStream(
body.getBytes()));
}
}