Top Description Fields Constructors Methods
org.eclipse.jgit.http.server

pack-priv Class SmartOutputStream

extends TemporaryBuffer
Class Inheritance
Static Imports
org.eclipse.jgit.http.server.ServletUtils.acceptsGzipEncoding, org.eclipse.jgit.util.HttpSupport.ENCODING_GZIP, .HttpSupport.HDR_CONTENT_ENCODING

Buffers a response, trying to gzip it if the user agent supports that.

If the response overflows the buffer, gzip is skipped and the response is streamed to the client as its produced, most likely using HTTP/1.1 chunked encoding. This is useful for servlets that produce mixed-mode content, where smaller payloads are primarily pure text that compresses well, while much larger payloads are heavily compressed binary data. UploadPackServlet is one such servlet.

Field Summary

Modifier and TypeField and Description
private boolean
private static final int
private final HttpServletRequest
private final HttpServletResponse
private boolean
Inherited from org.eclipse.jgit.util.TemporaryBuffer:
DEFAULT_IN_CORE_LIMIT

Constructor Summary

AccessConstructor and Description
pack-priv
SmartOutputStream(final HttpServletRequest req, final HttpServletResponse rsp, boolean compressStream)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides org.eclipse.jgit.util.TemporaryBuffer.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with this stream.

protected OutputStream
overflow()

Implements abstract org.eclipse.jgit.util.TemporaryBuffer.overflow.

Open the overflow output stream, so the remaining output can be stored.

private void
Inherited from org.eclipse.jgit.util.TemporaryBuffer:
copydestroydoFlushlengthopenInputStreamopenInputStreamWithAutoDestroyresettoByteArraytoByteArraytoStringwritewritewriteTo

Field Detail

compressStreamback to summary
private boolean compressStream
LIMITback to summary
private static final int LIMIT
reqback to summary
private final HttpServletRequest req
rspback to summary
private final HttpServletResponse rsp
startedOutputback to summary
private boolean startedOutput

Constructor Detail

SmartOutputStreamback to summary
pack-priv SmartOutputStream(final HttpServletRequest req, final HttpServletResponse rsp, boolean compressStream)

Method Detail

closeback to summary
public void close() throws IOException

Overrides org.eclipse.jgit.util.TemporaryBuffer.close.

Implements java.io.Closeable.close.

Doc from org.eclipse.jgit.util.TemporaryBuffer.close.

Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.OutputStream.close.

if an I/O error occurs.

overflowback to summary
protected OutputStream overflow() throws IOException

Implements abstract org.eclipse.jgit.util.TemporaryBuffer.overflow.

Doc from org.eclipse.jgit.util.TemporaryBuffer.overflow.

Open the overflow output stream, so the remaining output can be stored.

Returns:OutputStream

the output stream to receive the buffered content, followed by the remaining output.

Annotations
@Override
Exceptions
IOException:
the buffer cannot create the overflow stream.
writeResponseback to summary
private void writeResponse(TemporaryBuffer out) throws IOException