Class HttpOutput
java.lang.Object
java.io.OutputStream
jakarta.servlet.ServletOutputStream
org.eclipse.jetty.ee10.servlet.HttpOutput
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
public class HttpOutput
extends jakarta.servlet.ServletOutputStream
HttpOutput implements ServletOutputStream
as required by the Servlet specification.
HttpOutput buffers content written by the application until a
further write will overflow the buffer, at which point it triggers a commit
of the response.
HttpOutput can be closed and reopened, to allow requests included
via RequestDispatcher.include(ServletRequest, ServletResponse) to
close the stream, to be reopened after the inclusion ends.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidThis method is invoked for the COMPLETE action handling in HttpChannel.handle.voidCalled to indicate that the request cycle has been completed.voidflush()intlongbooleanisAsync()booleanisClosed()booleanisReady()booleanvoidonFlushed(long bytes) Invoked when bytes have been flushed to the network.voidvoidvoidrecycle()voidreopen()voidvoidBlocking send of stream content.voidsendContent(InputStream in, Callback callback) Asynchronous send of stream content.voidsendContent(ByteBuffer content) Blocking send of whole content.voidsendContent(ByteBuffer content, Callback callback) Asynchronous send of whole content.voidBlocking send of channel content.voidsendContent(ReadableByteChannel in, Callback callback) Asynchronous send of channel content.voidsetBufferSize(int size) voidsetWriteListener(jakarta.servlet.WriteListener writeListener) voidtoString()voidwrite(byte[] b, int off, int len) voidwrite(int b) voidwrite(ByteBuffer buffer) voidMethods inherited from class jakarta.servlet.ServletOutputStream
print, print, print, print, print, print, println, println, println, println, println, println, printlnMethods inherited from class OutputStream
nullOutputStream, write
-
Constructor Details
-
HttpOutput
-
-
Method Details
-
isWritten
public boolean isWritten()- Returns:
- True if any content has been written via the
HttpServletResponseAPI.
-
getWritten
public long getWritten()- Returns:
- The bytes written via the
HttpServletResponseAPI. This may differ from the bytes reported byResponse.getContentBytesWritten(Response)due to buffering, compression, other interception or writes that bypass the servlet API.
-
reopen
public void reopen() -
softClose
public void softClose() -
complete
This method is invoked for the COMPLETE action handling in HttpChannel.handle. The callback passed typically will call completed to finish the request cycle and so may need to asynchronously wait for: a pending/blocked operation to finish and then either an async close or wait for an application close to complete.- Parameters:
callback- The callback to complete when writing the output is complete.
-
completed
Called to indicate that the request cycle has been completed. -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
getByteBuffer
-
isClosed
public boolean isClosed() -
isAsync
public boolean isAsync() -
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
print
- Overrides:
printin classjakarta.servlet.ServletOutputStream- Throws:
IOException
-
println
- Overrides:
printlnin classjakarta.servlet.ServletOutputStream- Throws:
IOException
-
sendContent
Blocking send of whole content.- Parameters:
content- The whole content to send- Throws:
IOException- if the send fails
-
sendContent
Blocking send of stream content.- Parameters:
in- The stream content to send- Throws:
IOException- if the send fails
-
sendContent
Blocking send of channel content.- Parameters:
in- The channel content to send- Throws:
IOException- if the send fails
-
sendContent
Asynchronous send of whole content.- Parameters:
content- The whole content to sendcallback- The callback to use to notify success or failure
-
sendContent
Asynchronous send of stream content. The stream will be closed after reading all content.- Parameters:
in- The stream content to sendcallback- The callback to use to notify success or failure
-
sendContent
Asynchronous send of channel content. The channel will be closed after reading all content.- Parameters:
in- The channel content to sendcallback- The callback to use to notify success or failure
-
getBufferSize
public int getBufferSize() -
setBufferSize
public void setBufferSize(int size) -
onFlushed
Invoked when bytes have been flushed to the network.
- Parameters:
bytes- the number of bytes flushed- Throws:
IOException- if the minimum data rate, when set, is not respected- See Also:
-
recycle
public void recycle() -
resetBuffer
public void resetBuffer() -
setWriteListener
public void setWriteListener(jakarta.servlet.WriteListener writeListener) - Specified by:
setWriteListenerin classjakarta.servlet.ServletOutputStream
-
isReady
public boolean isReady()- Specified by:
isReadyin classjakarta.servlet.ServletOutputStream
-
writeCallback
public void writeCallback() -
toString
-