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 boolean
private static final int
private final javax.servlet.http.HttpServletRequest
private final javax.servlet.http.HttpServletResponse
private boolean
Fields 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 TypeMethodDescriptionvoid
close()
protected OutputStream
overflow()
Open the overflow output stream, so the remaining output can be stored.private void
Methods inherited from class org.eclipse.jgit.util.TemporaryBuffer
copy, destroy, doFlush, length, openInputStream, openInputStreamWithAutoDestroy, reset, toByteArray, toByteArray, toString, write, write, writeTo
Methods 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:
overflow
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classTemporaryBuffer
- Throws:
IOException
-
writeResponse
- Throws:
IOException
-