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 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(java.nio.channels.FileChannel source)
void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(int b)
void
write(java.nio.ByteBuffer byteBuffer)
void
write(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:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(java.nio.ByteBuffer[] buffers) throws java.io.IOException
- Specified by:
write
in interfaceBufferWritableOutputStream
- Throws:
java.io.IOException
-
write
public void write(java.nio.ByteBuffer byteBuffer) throws java.io.IOException
- Specified by:
write
in interfaceBufferWritableOutputStream
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
transferFrom
public void transferFrom(java.nio.channels.FileChannel source) throws java.io.IOException
- Specified by:
transferFrom
in interfaceBufferWritableOutputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
-