private void writeEntity(OutputStream out, RestMessage res) throws IOException { res.getEntity().write(out); // Append final CRLF to make it easier to modify the files in a text editor. This is not // compatible with the HTTP spec, but should work for most of our use cases. write(out, CRLF); }
/** * Similar to {@link #readMap(com.linkedin.r2.message.rest.RestMessage)}, but will throw an * {@link IOException} instead of a {@link RestLiInternalException} * * @throws IOException if the message entity cannot be parsed. */ public static DataMap readMapWithExceptions(final RestMessage message) throws IOException { try { return DataMapConverter.bytesToDataMap(message.getHeader(RestConstants.HEADER_CONTENT_TYPE), message.getEntity()); } catch (MimeTypeParseException e) { throw new RoutingException(e.getMessage(), HttpStatus.S_400_BAD_REQUEST.getCode(), e); } }