Skip to content

Instantly share code, notes, and snippets.

@vrnsky
Created January 18, 2021 04:44
Show Gist options
  • Save vrnsky/a94514044c1772238017ea526bcb8320 to your computer and use it in GitHub Desktop.
Save vrnsky/a94514044c1772238017ea526bcb8320 to your computer and use it in GitHub Desktop.
private static void logResponse(ContentCachingResponseWrapper response, String prefix) {
int status = response.getStatus();
logger.info("{} {} {}", prefix, status, HttpStatus.valueOf(status).getReasonPhrase());
response.getHeaderNames().forEach(header -> response.getHeaders(header).forEach(headerValue -> logger.info("{} {} {}", prefix, header, headerValue)));
logger.info("{}", prefix);
byte[] content = response.getContentAsByteArray();
if (content.length > 0) {
logContent(content, response.getContentType(), response.getCharacterEncoding(), prefix);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment