use of org.openecard.apache.http.ParseException in project open-ecard by ecsec.
the class HttpAppPluginActionHandler method getRequestBody.
private RequestBody getRequestBody(HttpRequest httpRequest, String resourceName) throws IOException {
try {
HttpEntityEnclosingRequest entityRequest = (HttpEntityEnclosingRequest) httpRequest;
HttpEntity entity = entityRequest.getEntity();
InputStream is = entity.getContent();
// TODO: This assumes the content is UTF-8. Evaluate what is actually sent.
String value = FileUtils.toString(is);
String mimeType = ContentType.get(entity).getMimeType();
// TODO: find out if we have a Base64 coded value
boolean base64Content = false;
RequestBody body = new RequestBody(resourceName, null);
body.setValue(value, mimeType, base64Content);
return body;
} catch (UnsupportedCharsetException | ParseException e) {
LOG.error("Failed to create request body.", e);
}
return null;
}
Aggregations