private static InputStream getInputStream(StreamConnection sc, String urlAddress) throws IOException { InputStream stream = sc.getInputStream(); String encoding = sc.getEncoding(); if ("gzip".equals(encoding) || urlAddress.endsWith(".gz")) { return new GZIPInputStream(stream); } if ("deflate".equals(encoding)) { return new DeflaterInputStream(stream); } return stream; }
InputStreamBody data = new InputStreamBody(new DeflaterInputStream(inputStream), filename);
InputStreamBody data = new InputStreamBody(new DeflaterInputStream(inputStream), filename);
@Override public InputStream compress(InputStream in) { return new DeflaterInputStream(in); }
@Override public CompressedInput getCompressedStream(final InputStream inputStream) { return () -> new DeflaterInputStream(inputStream); }
public InputStream getCompressedStream(InputStream unCompressedStream) { return new DeflaterInputStream(unCompressedStream); }
@Override protected InputStream getCompressionStream(InputStream input) { return new DeflaterInputStream(input, new Deflater(compressionLevel)); } }
public static InputStream toDeflateInputStream(InputStream source) { return new DeflaterInputStream(source, new Deflater(Deflater.BEST_COMPRESSION)); }
public static InputStream toDeflateInputStream(InputStream source) { return new DeflaterInputStream(source, new Deflater(Deflater.BEST_COMPRESSION)); }
public InputStream asStream() throws IOException { InputStream inputStream = connection.getResponseCode() < 400 ? connection.getInputStream() : connection.getErrorStream(); String encoding = connection.getHeaderField("Content-Encoding"); if ("gzip".equals(encoding)) inputStream = new GZIPInputStream(inputStream); else if ("deflate".equals(encoding)) inputStream = new DeflaterInputStream(inputStream); return inputStream; }
public InputStream asStream() throws IOException { InputStream inputStream = connection.getResponseCode() < 400 ? connection.getInputStream() : connection.getErrorStream(); String encoding = connection.getHeaderField("Content-Encoding"); if ("gzip".equals(encoding)) inputStream = new GZIPInputStream(inputStream); else if ("deflate".equals(encoding)) inputStream = new DeflaterInputStream(inputStream); return inputStream; }
private InputStream getInputStream(HttpURLConnection urlConn) throws IOException { InputStream is = urlConn.getInputStream(); String contentEncoding = urlConn.getContentEncoding(); if (contentEncoding == null) { return is; } if ("gzip".equalsIgnoreCase(contentEncoding)) { return new GZIPInputStream(is); } if ("deflate".equalsIgnoreCase(contentEncoding)) { return new DeflaterInputStream(is); } // This should never happen throw new IOException("Unsupported content encoding " + contentEncoding); } }
... out.println("Content-Encoding: deflate"); // NOTICE deflate encoding out.println("Content-Type: text/html"); out.println("Connection: close"); out.println(); String x = "jsonp1330xxxxx462022184([["; DeflaterInputStream dis = new DeflaterInputStream(out); dis.write(x.getBytes("utf-8")); // JSON is UTF-8 dis.close(); server.close(); // this a bad idea, the client may not have read the data yet
@Override public ReadOnlyFilteredCOSStream dispatch(StreamSource source) { return new ReadOnlyFilteredCOSStream(dictionary, new DeflaterInputStream(source.getSource()), -1); } });
@Override public ReadOnlyFilteredCOSStream dispatch(StreamSource source) { return new ReadOnlyFilteredCOSStream(dictionary, new DeflaterInputStream(source.getSource()), -1); } });
@Override protected byte[] compress0(byte[] b) throws Exception { return IOUtil.read(new DeflaterInputStream(new ByteArrayInputStream(b))); }
@Override public ReadOnlyFilteredCOSStream dispatch(FileSource source) throws TaskIOException { try { ReadOnlyFilteredCOSStream retVal = new ReadOnlyFilteredCOSStream(dictionary, new DeflaterInputStream(new FileInputStream(source.getSource())), -1); retVal.setEmbeddedInt(COSName.PARAMS.getName(), COSName.SIZE, source.getSource().length()); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(source.getSource().lastModified()); retVal.setEmbeddedDate(COSName.PARAMS.getName(), COSName.MOD_DATE, calendar); return retVal; } catch (FileNotFoundException e) { throw new TaskIOException(e); } }
@Override public ReadOnlyFilteredCOSStream dispatch(FileSource source) throws TaskIOException { try { ReadOnlyFilteredCOSStream retVal = new ReadOnlyFilteredCOSStream(dictionary, new DeflaterInputStream(new FileInputStream(source.getSource())), -1); retVal.setEmbeddedInt(COSName.PARAMS.getName(), COSName.SIZE, source.getSource().length()); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(source.getSource().lastModified()); retVal.setEmbeddedDate(COSName.PARAMS.getName(), COSName.MOD_DATE, calendar); return retVal; } catch (FileNotFoundException e) { throw new TaskIOException(e); } }
protected T createContent(InputStream in, long length, String hashSha1) { DeflaterInputStream inZip = new DeflaterInputStream(in, new Deflater(Deflater.BEST_COMPRESSION)); T fileEntity = createInstance(); fileEntity.setContent(getSession().getLobHelper().createBlob(inZip, length)); fileEntity.setHashSha1(hashSha1); fileEntity.setSize(length); fileEntity.setInclusionDate(new Date()); return fileEntity; }
@Override public void storeAssociatedDocument(String uniqueId, String fileName, InputStream is, boolean compress, long timestamp, Map<String, String> metadataMap) throws Exception { GridFSBucket gridFS = createGridFSConnection(); if (compress) { is = new DeflaterInputStream(is); } deleteAssociatedDocument(uniqueId, fileName); GridFSUploadOptions gridFSUploadOptions = getGridFSUploadOptions(uniqueId, fileName, compress, timestamp, metadataMap); gridFS.uploadFromStream(fileName, is, gridFSUploadOptions); }