Package org.eclipse.jetty.ee10.servlet
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
This method is invoked for the COMPLETE action handling in HttpChannel.handle.void
Called to indicate that the request cycle has been completed.void
flush()
int
long
boolean
isAsync()
boolean
isClosed()
boolean
isReady()
boolean
void
onFlushed
(long bytes) Invoked when bytes have been flushed to the network.void
void
void
recycle()
void
reopen()
void
void
Blocking send of stream content.void
sendContent
(InputStream in, Callback callback) Asynchronous send of stream content.void
sendContent
(ByteBuffer content) Blocking send of whole content.void
sendContent
(ByteBuffer content, Callback callback) Asynchronous send of whole content.void
Blocking send of channel content.void
sendContent
(ReadableByteChannel in, Callback callback) Asynchronous send of channel content.void
setBufferSize
(int size) void
setWriteListener
(jakarta.servlet.WriteListener writeListener) void
toString()
void
write
(byte[] b, int off, int len) void
write
(int b) void
write
(ByteBuffer buffer) void
Methods inherited from class jakarta.servlet.ServletOutputStream
print, print, print, print, print, print, println, println, println, println, println, println, println
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
HttpOutput
-
-
Method Details
-
isWritten
public boolean isWritten()- Returns:
- True if any content has been written via the
HttpServletResponse
API.
-
getWritten
public long getWritten()- Returns:
- The bytes written via the
HttpServletResponse
API. 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
getByteBuffer
-
isClosed
public boolean isClosed() -
isAsync
public boolean isAsync() -
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
print
- Overrides:
print
in classjakarta.servlet.ServletOutputStream
- Throws:
IOException
-
println
- Overrides:
println
in 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:
setWriteListener
in classjakarta.servlet.ServletOutputStream
-
isReady
public boolean isReady()- Specified by:
isReady
in classjakarta.servlet.ServletOutputStream
-
writeCallback
public void writeCallback() -
toString
-