Package io.undertow.io
Class UndertowOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- io.undertow.io.UndertowOutputStream
-
- All Implemented Interfaces:
BufferWritableOutputStream,Closeable,Flushable,AutoCloseable
public class UndertowOutputStream extends OutputStream implements BufferWritableOutputStream
Buffering output stream that wraps a channel.This stream delays channel creation, so if a response will fit in the buffer it is not necessary to set the content length header.
- Author:
- Stuart Douglas
-
-
Constructor Summary
Constructors Constructor Description UndertowOutputStream(HttpServerExchange exchange)Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidflush()longgetBytesWritten()voidresetBuffer()If the response has not yet been written to the client this method will clear the streams buffer, invalidating any content that has already been written.voidtransferFrom(FileChannel source)voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)voidwrite(ByteBuffer byteBuffer)voidwrite(ByteBuffer[] buffers)-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Constructor Detail
-
UndertowOutputStream
public UndertowOutputStream(HttpServerExchange exchange)
Construct a new instance. No write timeout is configured.- Parameters:
exchange- The exchange
-
-
Method Detail
-
resetBuffer
public void resetBuffer()
If the response has not yet been written to the client this method will clear the streams buffer, invalidating any content that has already been written. If any content has already been sent to the client then this method will throw and IllegalStateException- Throws:
IllegalStateException- If the response has been committed
-
getBytesWritten
public long getBytesWritten()
-
write
public void write(int b) throws IOException- Specified by:
writein classOutputStream- Throws:
IOException
-
write
public void write(byte[] b) throws IOException- Overrides:
writein classOutputStream- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException- Overrides:
writein classOutputStream- Throws:
IOException
-
write
public void write(ByteBuffer[] buffers) throws IOException
- Specified by:
writein interfaceBufferWritableOutputStream- Throws:
IOException
-
write
public void write(ByteBuffer byteBuffer) throws IOException
- Specified by:
writein interfaceBufferWritableOutputStream- Throws:
IOException
-
flush
public void flush() throws IOException- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
transferFrom
public void transferFrom(FileChannel source) throws IOException
- Specified by:
transferFromin interfaceBufferWritableOutputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
-