List of usage examples for org.eclipse.jgit.util TemporaryBuffer length
public long length()
From source file:org.webcat.core.http.SmartGZIPOutputStream.java
License:Open Source License
@Override public void close() throws IOException { super.close(); if (!startedOutput) { TemporaryBuffer out = this; if (out.length() > 256 && RequestUtils.acceptsGZIPEncoding(request)) { TemporaryBuffer gzbuf = new TemporaryBuffer.Heap(LIMIT); try { GZIPOutputStream gzip = new GZIPOutputStream(gzbuf); out.writeTo(gzip, null); gzip.close();/*from www .j a va 2s . c o m*/ if (gzbuf.length() < out.length()) { out = gzbuf; response.setHeader(HttpSupport.ENCODING_GZIP, HttpSupport.HDR_CONTENT_ENCODING); } } catch (IOException e) { // Likely caused by overflowing the buffer, meaning the // data would be larger if compressed. Discard compressed // copy and use the original. } } out.writeTo(outputStream, null); outputStream.flush(); } // Finally, append whatever was dumped into our stream to the response // content. outputStream.close(); response.appendContentData(outputStream.data()); }