in aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal/servlet/AwsHttpServletRequest.java [376:397]
protected ServletInputStream bodyStringToInputStream(String body, boolean isBase64Encoded) throws IOException {
if (body == null) {
return new AwsServletInputStream(new NullInputStream(0, false, false));
}
byte[] bodyBytes;
if (isBase64Encoded) {
bodyBytes = Base64.getMimeDecoder().decode(body);
} else {
String encoding = getCharacterEncoding();
if (encoding == null) {
encoding = Charset.defaultCharset().name();
}
try {
bodyBytes = body.getBytes(encoding);
} catch (Exception e) {
log.error("Could not read request with character encoding: " + SecurityUtils.crlf(encoding), e);
bodyBytes = body.getBytes(Charset.defaultCharset());
}
}
ByteArrayInputStream requestBodyStream = new ByteArrayInputStream(bodyBytes);
return new AwsServletInputStream(requestBodyStream);
}