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 void
close()
void
flush()
long
getBytesWritten()
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.void
transferFrom(FileChannel source)
void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(int b)
void
write(ByteBuffer byteBuffer)
void
write(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:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] b) throws IOException
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(ByteBuffer[] buffers) throws IOException
- Specified by:
write
in interfaceBufferWritableOutputStream
- Throws:
IOException
-
write
public void write(ByteBuffer byteBuffer) throws IOException
- Specified by:
write
in interfaceBufferWritableOutputStream
- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
transferFrom
public void transferFrom(FileChannel source) throws IOException
- Specified by:
transferFrom
in interfaceBufferWritableOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
-