Package org.eclipse.jetty.server
Class HttpOutput
java.lang.Object
java.io.OutputStream
javax.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
Modifier and TypeClassDescriptionstatic interface
The HttpOutput.Interceptor is a single intercept point for all output written to the HttpOutput: via writer; via output stream; asynchronously; or blocking. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected SharedBlockingCallback.Blocker
void
close()
void
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
run()
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
sendContent
(HttpContent content) Blocking send of HTTP content.void
sendContent
(HttpContent httpContent, Callback callback) Asynchronous send of HTTP content.void
setBufferSize
(int size) void
setInterceptor
(HttpOutput.Interceptor interceptor) void
setWriteListener
(javax.servlet.WriteListener writeListener) void
toString()
void
write
(byte[] b, int off, int len) void
write
(int b) void
write
(ByteBuffer buffer) Methods inherited from class javax.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
-
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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
getBuffer
-
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 classjavax.servlet.ServletOutputStream
- Throws:
IOException
-
println
- Overrides:
println
in classjavax.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.Interceptor
changed 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(javax.servlet.WriteListener writeListener) - Specified by:
setWriteListener
in classjavax.servlet.ServletOutputStream
-
isReady
public boolean isReady()- Specified by:
isReady
in classjavax.servlet.ServletOutputStream
-
run
public void run() -
toString
-