Charset cs = contentType.getCharset();
if (cs != null) {
charset = cs.name();
}
}
StringEntity entity = new StringEntity((String) data, charset);
if (contentType != null) {
entity.setContentType(contentType.toString());
}
answer = entity;
}
// fallback as input stream
if (answer == null) {
// force the body as an input stream since this is the fallback
InputStream is = in.getMandatoryBody(InputStream.class);
InputStreamEntity entity = new InputStreamEntity(is, -1);
if (contentType != null) {
entity.setContentType(contentType.toString());
}
answer = entity;
}
}
} catch (UnsupportedEncodingException e) {