Package org.eclipse.jetty.server
Class HttpOutput
java.lang.Object
java.io.OutputStream
jakarta.servlet.ServletOutputStream
org.eclipse.jetty.server.HttpOutput
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,Runnable
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe HttpOutput.Interceptor is a single intercept point for all output written to the HttpOutput: via writer; via output stream; asynchronously; or blocking. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SharedBlockingCallback.Blockervoidclose()voidvoidCalled 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()voidvoidrun()voidBlocking 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.voidsendContent(HttpContent content) Blocking send of HTTP content.voidsendContent(HttpContent httpContent, Callback callback) Asynchronous send of HTTP content.voidsetBufferSize(int size) voidsetInterceptor(HttpOutput.Interceptor interceptor) voidsetWriteListener(jakarta.servlet.WriteListener writeListener) voidtoString()voidwrite(byte[] b, int off, int len) voidwrite(int b) voidwrite(ByteBuffer buffer) Methods inherited from class jakarta.servlet.ServletOutputStream
print, print, print, print, print, print, println, println, println, println, println, println, printlnMethods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
HttpOutput
-
-
Method Details
-
getHttpChannel
-
getInterceptor
-
setInterceptor
-
isWritten
public boolean isWritten() -
getWritten
public long getWritten() -
reopen
public void reopen() -
acquireWriteBlockingCallback
- Throws:
IOException
-
softClose
public void softClose() -
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
-
getBuffer
-
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
Blocking send of HTTP content.- Parameters:
content- The HTTP 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
-
sendContent
Asynchronous send of HTTP content.- Parameters:
httpContent- The HTTP 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.
The number of flushed bytes may be different from the bytes written by the application if an
HttpOutput.Interceptorchanged them, for example by compressing them.- 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
-
run
public void run() -
toString
-