java.lang.Runnablepublic class HttpOutput
extends javax.servlet.ServletOutputStream
implements java.lang.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.
| Modifier and Type | Class | Description |
|---|---|---|
static interface |
HttpOutput.Interceptor |
The HttpOutput.Interceptor is a single intercept point for all
output written to the HttpOutput: via writer; via output stream;
asynchronously; or blocking.
|
| Constructor | Description |
|---|---|
HttpOutput(HttpChannel channel) |
| Modifier and Type | Method | Description |
|---|---|---|
protected SharedBlockingCallback.Blocker |
acquireWriteBlockingCallback() |
|
void |
close() |
|
void |
flush() |
|
int |
getBufferSize() |
|
HttpChannel |
getHttpChannel() |
|
HttpOutput.Interceptor |
getInterceptor() |
|
long |
getWritten() |
|
boolean |
isAllContentWritten() |
|
boolean |
isAsync() |
|
boolean |
isClosed() |
|
boolean |
isReady() |
|
boolean |
isWritten() |
|
void |
onFlushed(long bytes) |
Invoked when bytes have been flushed to the network.
|
void |
print(java.lang.String s) |
|
void |
recycle() |
|
void |
reopen() |
|
void |
resetBuffer() |
|
void |
run() |
|
void |
sendContent(java.io.InputStream in) |
Blocking send of stream content.
|
void |
sendContent(java.io.InputStream in,
Callback callback) |
Asynchronous send of stream content.
|
void |
sendContent(java.nio.ByteBuffer content) |
Blocking send of whole content.
|
void |
sendContent(java.nio.ByteBuffer content,
Callback callback) |
Asynchronous send of whole content.
|
void |
sendContent(java.nio.channels.ReadableByteChannel in) |
Blocking send of channel content.
|
void |
sendContent(java.nio.channels.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) |
|
java.lang.String |
toString() |
|
void |
write(byte[] b,
int off,
int len) |
|
void |
write(int b) |
|
void |
write(java.nio.ByteBuffer buffer) |
|
protected void |
write(java.nio.ByteBuffer content,
boolean complete,
Callback callback) |
public HttpOutput(HttpChannel channel)
public HttpChannel getHttpChannel()
public HttpOutput.Interceptor getInterceptor()
public void setInterceptor(HttpOutput.Interceptor interceptor)
public boolean isWritten()
public long getWritten()
public void reopen()
public boolean isAllContentWritten()
protected SharedBlockingCallback.Blocker acquireWriteBlockingCallback() throws java.io.IOException
java.io.IOExceptionprotected void write(java.nio.ByteBuffer content,
boolean complete,
Callback callback)
public void close()
close in class java.io.OutputStreampublic boolean isClosed()
public boolean isAsync()
public void flush()
throws java.io.IOException
flush in class java.io.OutputStreamjava.io.IOExceptionpublic void write(byte[] b,
int off,
int len)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void write(java.nio.ByteBuffer buffer)
throws java.io.IOException
java.io.IOExceptionpublic void write(int b)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void print(java.lang.String s)
throws java.io.IOException
print in class javax.servlet.ServletOutputStreamjava.io.IOExceptionpublic void sendContent(java.nio.ByteBuffer content)
throws java.io.IOException
content - The whole content to sendjava.io.IOException - if the send failspublic void sendContent(java.io.InputStream in)
throws java.io.IOException
in - The stream content to sendjava.io.IOException - if the send failspublic void sendContent(java.nio.channels.ReadableByteChannel in)
throws java.io.IOException
in - The channel content to sendjava.io.IOException - if the send failspublic void sendContent(HttpContent content) throws java.io.IOException
content - The HTTP content to sendjava.io.IOException - if the send failspublic void sendContent(java.nio.ByteBuffer content,
Callback callback)
content - The whole content to sendcallback - The callback to use to notify success or failurepublic void sendContent(java.io.InputStream in,
Callback callback)
in - The stream content to sendcallback - The callback to use to notify success or failurepublic void sendContent(java.nio.channels.ReadableByteChannel in,
Callback callback)
in - The channel content to sendcallback - The callback to use to notify success or failurepublic void sendContent(HttpContent httpContent, Callback callback)
httpContent - The HTTP content to sendcallback - The callback to use to notify success or failurepublic int getBufferSize()
public void setBufferSize(int size)
public void onFlushed(long bytes)
throws java.io.IOException
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.
bytes - the number of bytes flushedjava.io.IOException - if the minimum data rate, when set, is not respectedWriteFlusher.Listenerpublic void recycle()
public void resetBuffer()
public void setWriteListener(javax.servlet.WriteListener writeListener)
setWriteListener in class javax.servlet.ServletOutputStreampublic boolean isReady()
isReady in class javax.servlet.ServletOutputStreampublic void run()
run in interface java.lang.Runnablepublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 1995–2018 Webtide. All rights reserved.