class PostmanService {

    void appendResponseBody(StringBuilder html, Stream stream, String contentType) {
        if (stream.getTempFile() != null) {
            String fileContent;
            try {
                fileContent = FileUtils.readFileToString(stream.getTempFile(), StandardCharsets.UTF_8);
                fileContent = prettyPrint(fileContent, contentType);
            } catch (IOException e) {
                log.error("Cannot read temporary file {}", stream.getTempFile(), e);
                fileContent = "Error in ARA while reading the content of the response received by Newman:\n" +
                        ExceptionUtils.getStackTrace(e);
            }

            html.append("<pre>").append(escapeHtml(fileContent)).append("</pre>\n");
        }
    }

}