Created
January 18, 2021 04:44
-
-
Save vrnsky/925fcf96b598cdcf77d592138ed1940f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void logContent(byte[] content, String contentType, String contentEncoding, String prefix) { | |
MediaType mediaType = MediaType.valueOf(contentType); | |
boolean visible = VISIBLE_TYPES.stream().anyMatch(visibleType -> visibleType.includes(mediaType)); | |
if (visible) { | |
try { | |
String contentString = new String(content, contentEncoding); | |
Stream.of(contentString.split("\r\n|\r\n")).forEach(line -> logger.info("{} {}", prefix, line)); | |
} catch (UnsupportedEncodingException e) { | |
logger.info("{}, [{} bytes content]", prefix, content.length); | |
} | |
} else { | |
logger.info("{}, [{} bytes content]", prefix, content.length); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment