public class HttpOutput extends ServletOutputStream implements 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 and 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 and Description |
|---|
HttpOutput(HttpChannel channel) |
| Modifier and Type | Method and Description |
|---|---|
ByteBuffer |
acquireBuffer() |
void |
close() |
void |
complete(Callback callback) |
void |
completed()
Called to indicate that the request cycle has been completed.
|
void |
flush() |
ByteBuffer |
getBuffer() |
int |
getBufferSize() |
HttpChannel |
getHttpChannel() |
HttpOutput.Interceptor |
getInterceptor() |
long |
getWritten() |
boolean |
isAsync() |
boolean |
isClosed() |
boolean |
isReady() |
boolean |
isWritten() |
void |
onFlushed(long bytes)
Invoked when bytes have been flushed to the network.
|
void |
print(String s) |
void |
println(boolean b) |
void |
println(char c) |
void |
println(double d) |
void |
println(float f) |
void |
println(int i) |
void |
println(long l) |
void |
println(String s) |
void |
recycle() |
void |
reopen() |
void |
resetBuffer() |
void |
run() |
void |
sendContent(ByteBuffer content)
Blocking send of whole content.
|
void |
sendContent(ByteBuffer content,
Callback callback)
Asynchronous send of whole content.
|
void |
sendContent(HttpContent content)
Blocking send of HTTP content.
|
void |
sendContent(HttpContent httpContent,
Callback callback)
Asynchronous send of HTTP content.
|
void |
sendContent(InputStream in)
Blocking send of stream content.
|
void |
sendContent(InputStream in,
Callback callback)
Asynchronous send of stream content.
|
void |
sendContent(ReadableByteChannel in)
Blocking send of channel content.
|
void |
sendContent(ReadableByteChannel in,
Callback callback)
Asynchronous send of channel content.
|
void |
setBufferSize(int size) |
void |
setInterceptor(HttpOutput.Interceptor interceptor) |
void |
setWriteListener(WriteListener writeListener) |
void |
softClose() |
String |
toString() |
void |
write(byte[] b,
int off,
int len) |
void |
write(ByteBuffer buffer) |
void |
write(int b) |
print, print, print, print, print, print, printlnwritepublic 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 void softClose()
public void complete(Callback callback)
public void completed()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionpublic ByteBuffer getBuffer()
public ByteBuffer acquireBuffer()
public boolean isClosed()
public boolean isAsync()
public void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in class OutputStreamIOExceptionpublic void write(ByteBuffer buffer) throws IOException
IOExceptionpublic void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void print(String s) throws IOException
print in class ServletOutputStreamIOExceptionpublic void println(String s) throws IOException
println in class ServletOutputStreamIOExceptionpublic void println(boolean b)
throws IOException
println in class ServletOutputStreamIOExceptionpublic void println(char c)
throws IOException
println in class ServletOutputStreamIOExceptionpublic void println(int i)
throws IOException
println in class ServletOutputStreamIOExceptionpublic void println(long l)
throws IOException
println in class ServletOutputStreamIOExceptionpublic void println(float f)
throws IOException
println in class ServletOutputStreamIOExceptionpublic void println(double d)
throws IOException
println in class ServletOutputStreamIOExceptionpublic void sendContent(ByteBuffer content) throws IOException
content - The whole content to sendIOException - if the send failspublic void sendContent(InputStream in) throws IOException
in - The stream content to sendIOException - if the send failspublic void sendContent(ReadableByteChannel in) throws IOException
in - The channel content to sendIOException - if the send failspublic void sendContent(HttpContent content) throws IOException
content - The HTTP content to sendIOException - if the send failspublic void sendContent(ByteBuffer content, Callback callback)
content - The whole content to sendcallback - The callback to use to notify success or failurepublic void sendContent(InputStream in, Callback callback)
in - The stream content to sendcallback - The callback to use to notify success or failurepublic void sendContent(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 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 flushedIOException - if the minimum data rate, when set, is not respectedWriteFlusher.Listenerpublic void recycle()
public void resetBuffer()
public void setWriteListener(WriteListener writeListener)
setWriteListener in class ServletOutputStreampublic boolean isReady()
isReady in class ServletOutputStreamCopyright © 2010 - 2020 Adobe. All Rights Reserved