BAEL-3188 How to compress requests using the Spring RestTemplate. Updated GzipUtils code following editor review. (#7746)
This commit is contained in:
parent
f53e9e55eb
commit
4cf99eb77c
@ -30,15 +30,11 @@ public class GzipUtils {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static byte[] compress(byte[] body) throws IOException {
|
public static byte[] compress(byte[] body) throws IOException {
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
try {
|
try (GZIPOutputStream gzipOutputStream = new GZIPOutputStream(baos)) {
|
||||||
try (GZIPOutputStream gzipOutputStream = new GZIPOutputStream(output)) {
|
|
||||||
gzipOutputStream.write(body);
|
gzipOutputStream.write(body);
|
||||||
}
|
}
|
||||||
} finally {
|
return baos.toByteArray();
|
||||||
output.close();
|
|
||||||
}
|
|
||||||
return output.toByteArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user