@Override public byte[] inflate(InputStream data) throws CompressionException { ByteArrayOutputStream out = new ByteArrayOutputStream(); try (SnappyFramedInputStream snappy = new SnappyFramedInputStream(data, true)) { IOUtils.copy(snappy, out); } catch (IOException e) { throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName(), e); } return out.toByteArray(); }
@Override public byte[] deflate(InputStream data) throws CompressionException { ByteArrayOutputStream out = new ByteArrayOutputStream(); try (SnappyFramedOutputStream snappy = new SnappyFramedOutputStream(out)) { IOUtils.copy(data, snappy); } catch (IOException e) { throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName(), e); } return out.toByteArray(); }
@Override public byte[] inflate(InputStream data) throws CompressionException { ByteArrayOutputStream out; GZIPInputStream gzip = null; try { out = new ByteArrayOutputStream(); gzip = new GZIPInputStream(data); IOUtils.copy(gzip, out); } catch (IOException e) { throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName(), e); } finally { if (gzip != null) { IOUtils.closeQuietly(gzip); } } return out.toByteArray(); }
@Override public byte[] deflate(InputStream data) throws CompressionException { ByteArrayOutputStream out; GZIPOutputStream gzip = null; try { out = new ByteArrayOutputStream(); gzip = new GZIPOutputStream(out); IOUtils.copy(data, gzip); } catch (IOException e) { throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName(), e); } finally { if (gzip != null) { IOUtils.closeQuietly(gzip); } } return out.toByteArray(); }
@Override public byte[] inflate(InputStream data) throws CompressionException { try { byte[] temp = IOUtils.toByteArray(data); return Snappy.uncompress(temp, 0, temp.length); } catch (IOException e) { throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName(), e); } }
@Override public byte[] deflate(InputStream data) throws CompressionException { try { byte[] temp = IOUtils.toByteArray(data); return Snappy.compress(temp); } catch (IOException e) { throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName(), e); } } }
throw new CompressionException(CompressionConstants.DECODING_ERROR + CompressionConstants.BAD_STREAM, e); throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName());
@Override public byte[] inflate(InputStream data) throws CompressionException { ByteArrayOutputStream out = new ByteArrayOutputStream(); BZip2CompressorInputStream bzip2 = null; try { bzip2 = new BZip2CompressorInputStream(data); IOUtils.copy(bzip2, out); } catch (IOException e) { throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName(), e); } finally { if (bzip2 != null) { IOUtils.closeQuietly(bzip2); } } return out.toByteArray(); }
throw new CompressionException(CompressionConstants.DECODING_ERROR + CompressionConstants.BAD_STREAM, e); throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName(), e); throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName());
public int getResponseCompressionThreshold(MessageHeaders message) throws CompressionException { String responseCompressionThreshold = message.getHeader(HttpConstants.HEADER_RESPONSE_COMPRESSION_THRESHOLD); // If Response-Compression-Threshold header is present, use that value. If not, use the value in _defaultResponseCompressionConfig. if (responseCompressionThreshold != null) { try { return Integer.parseInt(responseCompressionThreshold); } catch (NumberFormatException e) { throw new CompressionException(CompressionConstants.INVALID_THRESHOLD + responseCompressionThreshold); } } return _defaultResponseCompressionConfig.getCompressionThreshold(); } }
throw new CompressionException(CompressionConstants.ILLEGAL_FORMAT + entry, e); throw new CompressionException(CompressionConstants.ILLEGAL_FORMAT + entry);
@Override public byte[] deflate(InputStream data) throws CompressionException { ByteArrayOutputStream out = new ByteArrayOutputStream(); BZip2CompressorOutputStream compressor = null; try { out = new ByteArrayOutputStream(); compressor = new BZip2CompressorOutputStream(out); IOUtils.copy(data, compressor); compressor.finish(); } catch (IOException e) { throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName(), e); } finally { if (compressor != null) { IOUtils.closeQuietly(compressor); } } return out.toByteArray(); } }
throw new CompressionException(CompressionConstants.ILLEGAL_FORMAT + entry, e); throw new CompressionException(CompressionConstants.ILLEGAL_FORMAT + entry);
throw new CompressionException(CompressionConstants.SERVER_ENCODING_ERROR + compressionHeader); throw new CompressionException(CompressionConstants.SERVER_ENCODING_ERROR + compressionHeader);
throw new CompressionException(CompressionConstants.UNSUPPORTED_ENCODING + requestContentEncoding); throw new CompressionException(CompressionConstants.REQUEST_ANY_ERROR + requestContentEncoding);
if (encoding == null || encoding == StreamEncodingType.ANY) throw new CompressionException(CompressionConstants.UNSUPPORTED_ENCODING + requestContentEncoding); if (compressor == null) throw new CompressionException(CompressionConstants.UNKNOWN_ENCODING + encoding);
if (responseCompression == null) throw new CompressionException(HttpConstants.ACCEPT_ENCODING + " not in local attribute.");
if (responseAcceptedEncodings == null) throw new CompressionException(HttpConstants.ACCEPT_ENCODING + " not in local attribute.");
@Override public byte[] deflate(InputStream data) throws CompressionException { try { byte[] temp = IOUtils.toByteArray(data); return Snappy.compress(temp); } catch (IOException e) { throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName(), e); } } }
@Override public byte[] inflate(InputStream data) throws CompressionException { try { byte[] temp = IOUtils.toByteArray(data); return Snappy.uncompress(temp, 0, temp.length); } catch (IOException e) { throw new CompressionException(CompressionConstants.DECODING_ERROR + getContentEncodingName(), e); } }