Package org.eclipse.jgit.http.server
Class SmartOutputStream
java.lang.Object
java.io.OutputStream
org.eclipse.jgit.util.TemporaryBuffer
org.eclipse.jgit.http.server.SmartOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jgit.util.TemporaryBuffer
TemporaryBuffer.Heap, TemporaryBuffer.LocalFile -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate static final intprivate final javax.servlet.http.HttpServletRequestprivate final javax.servlet.http.HttpServletResponseprivate booleanFields inherited from class org.eclipse.jgit.util.TemporaryBuffer
DEFAULT_IN_CORE_LIMIT -
Constructor Summary
ConstructorsConstructorDescriptionSmartOutputStream(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse rsp, boolean compressStream) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected OutputStreamoverflow()Open the overflow output stream, so the remaining output can be stored.private voidMethods inherited from class org.eclipse.jgit.util.TemporaryBuffer
copy, destroy, doFlush, length, openInputStream, openInputStreamWithAutoDestroy, reset, toByteArray, toByteArray, toString, write, write, writeToMethods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Field Details
-
LIMIT
private static final int LIMIT- See Also:
-
req
private final javax.servlet.http.HttpServletRequest req -
rsp
private final javax.servlet.http.HttpServletResponse rsp -
compressStream
private boolean compressStream -
startedOutput
private boolean startedOutput
-
-
Constructor Details
-
SmartOutputStream
SmartOutputStream(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse rsp, boolean compressStream)
-
-
Method Details
-
overflow
Open the overflow output stream, so the remaining output can be stored.- Specified by:
overflowin classTemporaryBuffer- Returns:
- the output stream to receive the buffered content, followed by the remaining output.
- Throws:
IOException- the buffer cannot create the overflow stream.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classTemporaryBuffer- Throws:
IOException
-
writeResponse
- Throws:
IOException
-