Last active
January 24, 2019 18:50
-
-
Save kleinron/6b61aa5fff5fc3b68419 to your computer and use it in GitHub Desktop.
spark java enable gzip if needed
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 enableGzipIfNeeded(spark.Request request, spark.Response response) { | |
String accept = request.headers("Accept-Encoding"); | |
if (accept == null) { | |
return; | |
} | |
String[] tokens = accept.split(","); | |
if (Arrays.stream(tokens).map(String::trim).anyMatch(s -> s.equalsIgnoreCase("gzip"))) { | |
response.header("Content-Encoding", "gzip"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment