log.debug("DLS is enabled and request contains valid xcontent");
BytesReference modifiedContent = applyDls((BytesRestResponse)response);
int contentLength = modifiedContent.length();
resp.setContentLength(contentLength);
final ServletOutputStream out = resp.getOutputStream();
modifiedContent.writeTo(out);
out.close();
} else {
log.debug("DLS is not enabled or response does not contain valid xcontent");
int contentLength = response.content().length();