Package io.undertow.io
Class UndertowOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- io.undertow.io.UndertowOutputStream
-
- All Implemented Interfaces:
BufferWritableOutputStream,java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class UndertowOutputStream extends java.io.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(java.nio.channels.FileChannel source)voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)voidwrite(java.nio.ByteBuffer byteBuffer)voidwrite(java.nio.ByteBuffer[] buffers)
-
-
-
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:
java.lang.IllegalStateException- If the response has been committed
-
getBytesWritten
public long getBytesWritten()
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(java.nio.ByteBuffer[] buffers) throws java.io.IOException- Specified by:
writein interfaceBufferWritableOutputStream- Throws:
java.io.IOException
-
write
public void write(java.nio.ByteBuffer byteBuffer) throws java.io.IOException- Specified by:
writein interfaceBufferWritableOutputStream- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.OutputStream- Throws:
java.io.IOException
-
transferFrom
public void transferFrom(java.nio.channels.FileChannel source) throws java.io.IOException- Specified by:
transferFromin interfaceBufferWritableOutputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
-