public class CollectBytes
extends java.lang.Object
implements rx.Observable.Transformer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>
Observable.Transformer to collect a stream of ByteBufs into a single
ByteBuf. On success the receiver must release the returned ByteBuf.
On failure this will release all received ByteBufs.
This Transformer should not be used with ContentSource.autoRelease()
as this will release the underlying collected ByteBufs before the collection is complete.
| Modifier and Type | Class and Description |
|---|---|
static class |
CollectBytes.TooMuchDataException |
| Modifier and Type | Method and Description |
|---|---|
static CollectBytes |
all()
Collect all emitted ByteBufs into a single ByteBuf.
|
rx.Observable<io.netty.buffer.ByteBuf> |
call(rx.Observable<io.netty.buffer.ByteBuf> upstream) |
static CollectBytes |
upTo(int maxBytes)
Collect all emitted ByteBufs into a single ByteBuf until maxBytes have
been collected.
|
public static CollectBytes all()
Integer.MAX_VALUE
bytes. This is the upper limit of ByteBuf.readableBytes(). If more than
Integer#MAX_VALUE bytes are received a CollectBytes.TooMuchDataException will be emitted.
Throwable.getCause()
will contain an
OnErrorThrowable.OnNextValue with the bytes accumulated before the exception
was thrown.public static CollectBytes upTo(int maxBytes)
CollectBytes.TooMuchDataException. Throwable.getCause()
will contain an
OnErrorThrowable.OnNextValue with the bytes accumulated before the exception
was thrown.maxBytes - the maximum number of bytes to readjava.lang.IllegalArgumentException - when maxBytes is negativepublic rx.Observable<io.netty.buffer.ByteBuf> call(rx.Observable<io.netty.buffer.ByteBuf> upstream)
call in interface rx.functions.Func1<rx.Observable<io.netty.buffer.ByteBuf>,rx.Observable<io.netty.buffer.ByteBuf>>