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:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
class SmartOutputStream extends TemporaryBuffer
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
Fields Modifier and Type Field Description private boolean
compressStream
private static int
LIMIT
private javax.servlet.http.HttpServletRequest
req
private javax.servlet.http.HttpServletResponse
rsp
private boolean
startedOutput
-
Fields inherited from class org.eclipse.jgit.util.TemporaryBuffer
DEFAULT_IN_CORE_LIMIT
-
-
Constructor Summary
Constructors Constructor Description SmartOutputStream(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse rsp, boolean compressStream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
protected java.io.OutputStream
overflow()
Open the overflow output stream, so the remaining output can be stored.private void
writeResponse(TemporaryBuffer out)
-
Methods inherited from class org.eclipse.jgit.util.TemporaryBuffer
copy, destroy, doFlush, length, openInputStream, openInputStreamWithAutoDestroy, reset, toByteArray, toByteArray, toString, write, write, writeTo
-
-
-
-
Field Detail
-
LIMIT
private static final int LIMIT
- See Also:
- Constant Field Values
-
req
private final javax.servlet.http.HttpServletRequest req
-
rsp
private final javax.servlet.http.HttpServletResponse rsp
-
compressStream
private boolean compressStream
-
startedOutput
private boolean startedOutput
-
-
Method Detail
-
overflow
protected java.io.OutputStream overflow() throws java.io.IOException
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:
java.io.IOException
- the buffer cannot create the overflow stream.
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classTemporaryBuffer
- Throws:
java.io.IOException
-
writeResponse
private void writeResponse(TemporaryBuffer out) throws java.io.IOException
- Throws:
java.io.IOException
-
-