Class MultiByteHttpData
java.lang.Object
io.netty.util.AbstractReferenceCounted
io.netty.handler.codec.http.multipart.AbstractHttpData
org.jboss.resteasy.reactive.client.impl.multipart.MultiByteHttpData
- All Implemented Interfaces:
io.netty.buffer.ByteBufHolder,io.netty.handler.codec.http.multipart.FileUpload,io.netty.handler.codec.http.multipart.HttpData,io.netty.handler.codec.http.multipart.InterfaceHttpData,io.netty.util.ReferenceCounted,Comparable<io.netty.handler.codec.http.multipart.InterfaceHttpData>
public class MultiByteHttpData
extends io.netty.handler.codec.http.multipart.AbstractHttpData
implements io.netty.handler.codec.http.multipart.FileUpload
A FileUpload implementation that is responsible for sending Multi<Byte> as a file in a multipart message.
It is meant to be used by the
PausableHttpPostRequestEncoder
When created, MultiByteHttpData will subscribe to the underlying Multi and request BUFFER_SIZE
of bytes.
Before reading the next chunk of data with getChunk(int), the post encoder checks if data isReady(int)
and if not, triggers suspend(int). That's because a chunk smaller than requested is treated as the end of input.
Then, when the requested amount of bytes is ready, or the underlying Multi is completed, `resumption` is executed.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.handler.codec.http.multipart.InterfaceHttpData
io.netty.handler.codec.http.multipart.InterfaceHttpData.HttpDataType -
Field Summary
FieldsFields inherited from class io.netty.handler.codec.http.multipart.AbstractHttpData
definedSize, size -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddContent(io.netty.buffer.ByteBuf buffer, boolean last) intcompareTo(io.netty.handler.codec.http.multipart.InterfaceHttpData o) intio.netty.handler.codec.http.multipart.FileUploadcopy()voiddelete()io.netty.handler.codec.http.multipart.FileUploadbooleanbyte[]get()io.netty.buffer.ByteBufio.netty.buffer.ByteBufgetChunk(int toRead)
NOTE: should only be invoked whenisReady(int)returns truegetFile()io.netty.handler.codec.http.multipart.InterfaceHttpData.HttpDataTypeinthashCode()booleanbooleanisReady(int chunkSize) check if it is possible to read the next chunk of data of a given sizelonglength()booleanio.netty.handler.codec.http.multipart.FileUploadreplace(io.netty.buffer.ByteBuf content) io.netty.handler.codec.http.multipart.FileUploadretain()io.netty.handler.codec.http.multipart.FileUploadretain(int increment) io.netty.handler.codec.http.multipart.FileUploadvoidsetContent(io.netty.buffer.ByteBuf buffer) voidsetContent(File file) voidsetContent(InputStream inputStream) voidsetContentTransferEncoding(String contentTransferEncoding) voidsetContentType(String contentType) voidsetFilename(String filename) toString()io.netty.handler.codec.http.multipart.FileUploadtouch()io.netty.handler.codec.http.multipart.FileUploadMethods inherited from class io.netty.handler.codec.http.multipart.AbstractHttpData
checkSize, content, deallocate, definedLength, getCharset, getMaxSize, getName, isCompleted, setCharset, setCompleted, setCompleted, setMaxSizeMethods inherited from class io.netty.util.AbstractReferenceCounted
refCnt, release, release, setRefCntMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.netty.buffer.ByteBufHolder
contentMethods inherited from interface io.netty.handler.codec.http.multipart.HttpData
checkSize, definedLength, getCharset, getMaxSize, isCompleted, setCharset, setMaxSizeMethods inherited from interface io.netty.handler.codec.http.multipart.InterfaceHttpData
getNameMethods inherited from interface io.netty.util.ReferenceCounted
refCnt, release, release
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE- See Also:
-
-
Constructor Details
-
MultiByteHttpData
public MultiByteHttpData(String name, String filename, String contentType, String contentTransferEncoding, Charset charset, io.smallrye.mutiny.Multi<Byte> content, Consumer<Throwable> errorHandler, io.vertx.core.Context context, Runnable resumption) - Parameters:
name- name of the parameterfilename- file namecontentType- content typecontentTransferEncoding- "binary" for sending binary filescharset- the charsetcontent- the Multi to senderrorHandler- error handler invoked when the Multi emits an exceptioncontext- Vertx context on which the data is sentresumption- the action to execute when the requested amount of bytes is ready, or the Multi is completed
-
-
Method Details
-
setContent
- Specified by:
setContentin interfaceio.netty.handler.codec.http.multipart.HttpData- Throws:
IOException
-
addContent
- Specified by:
addContentin interfaceio.netty.handler.codec.http.multipart.HttpData- Throws:
IOException
-
setContent
- Specified by:
setContentin interfaceio.netty.handler.codec.http.multipart.HttpData- Throws:
IOException
-
setContent
- Specified by:
setContentin interfaceio.netty.handler.codec.http.multipart.HttpData- Throws:
IOException
-
delete
public void delete()- Specified by:
deletein interfaceio.netty.handler.codec.http.multipart.HttpData
-
get
- Specified by:
getin interfaceio.netty.handler.codec.http.multipart.HttpData- Throws:
IOException
-
getByteBuf
public io.netty.buffer.ByteBuf getByteBuf()- Specified by:
getByteBufin interfaceio.netty.handler.codec.http.multipart.HttpData
-
isReady
public boolean isReady(int chunkSize) check if it is possible to read the next chunk of data of a given size- Parameters:
chunkSize- amount of bytes- Returns:
- true if the requested amount of bytes is ready to be read or the Multi is completed, i.e. there will be no more bytes to read
-
getChunk
public io.netty.buffer.ByteBuf getChunk(int toRead)
NOTE: should only be invoked whenisReady(int)returns true- Specified by:
getChunkin interfaceio.netty.handler.codec.http.multipart.HttpData- Parameters:
toRead- amount of bytes to read- Returns:
- ByteBuf with the requested bytes
-
getString
- Specified by:
getStringin interfaceio.netty.handler.codec.http.multipart.HttpData
-
getString
- Specified by:
getStringin interfaceio.netty.handler.codec.http.multipart.HttpData
-
renameTo
- Specified by:
renameToin interfaceio.netty.handler.codec.http.multipart.HttpData
-
isInMemory
public boolean isInMemory()- Specified by:
isInMemoryin interfaceio.netty.handler.codec.http.multipart.HttpData
-
getFile
- Specified by:
getFilein interfaceio.netty.handler.codec.http.multipart.HttpData
-
copy
public io.netty.handler.codec.http.multipart.FileUpload copy()- Specified by:
copyin interfaceio.netty.buffer.ByteBufHolder- Specified by:
copyin interfaceio.netty.handler.codec.http.multipart.FileUpload- Specified by:
copyin interfaceio.netty.handler.codec.http.multipart.HttpData
-
duplicate
public io.netty.handler.codec.http.multipart.FileUpload duplicate()- Specified by:
duplicatein interfaceio.netty.buffer.ByteBufHolder- Specified by:
duplicatein interfaceio.netty.handler.codec.http.multipart.FileUpload- Specified by:
duplicatein interfaceio.netty.handler.codec.http.multipart.HttpData
-
retainedDuplicate
public io.netty.handler.codec.http.multipart.FileUpload retainedDuplicate()- Specified by:
retainedDuplicatein interfaceio.netty.buffer.ByteBufHolder- Specified by:
retainedDuplicatein interfaceio.netty.handler.codec.http.multipart.FileUpload- Specified by:
retainedDuplicatein interfaceio.netty.handler.codec.http.multipart.HttpData
-
replace
public io.netty.handler.codec.http.multipart.FileUpload replace(io.netty.buffer.ByteBuf content) - Specified by:
replacein interfaceio.netty.buffer.ByteBufHolder- Specified by:
replacein interfaceio.netty.handler.codec.http.multipart.FileUpload- Specified by:
replacein interfaceio.netty.handler.codec.http.multipart.HttpData
-
retain
public io.netty.handler.codec.http.multipart.FileUpload retain(int increment) - Specified by:
retainin interfaceio.netty.buffer.ByteBufHolder- Specified by:
retainin interfaceio.netty.handler.codec.http.multipart.FileUpload- Specified by:
retainin interfaceio.netty.handler.codec.http.multipart.HttpData- Specified by:
retainin interfaceio.netty.handler.codec.http.multipart.InterfaceHttpData- Specified by:
retainin interfaceio.netty.util.ReferenceCounted- Overrides:
retainin classio.netty.handler.codec.http.multipart.AbstractHttpData
-
retain
public io.netty.handler.codec.http.multipart.FileUpload retain()- Specified by:
retainin interfaceio.netty.buffer.ByteBufHolder- Specified by:
retainin interfaceio.netty.handler.codec.http.multipart.FileUpload- Specified by:
retainin interfaceio.netty.handler.codec.http.multipart.HttpData- Specified by:
retainin interfaceio.netty.handler.codec.http.multipart.InterfaceHttpData- Specified by:
retainin interfaceio.netty.util.ReferenceCounted- Overrides:
retainin classio.netty.handler.codec.http.multipart.AbstractHttpData
-
touch
public io.netty.handler.codec.http.multipart.FileUpload touch()- Specified by:
touchin interfaceio.netty.buffer.ByteBufHolder- Specified by:
touchin interfaceio.netty.handler.codec.http.multipart.FileUpload- Specified by:
touchin interfaceio.netty.handler.codec.http.multipart.HttpData- Specified by:
touchin interfaceio.netty.handler.codec.http.multipart.InterfaceHttpData- Specified by:
touchin interfaceio.netty.util.ReferenceCounted- Specified by:
touchin classio.netty.handler.codec.http.multipart.AbstractHttpData
-
touch
- Specified by:
touchin interfaceio.netty.buffer.ByteBufHolder- Specified by:
touchin interfaceio.netty.handler.codec.http.multipart.FileUpload- Specified by:
touchin interfaceio.netty.handler.codec.http.multipart.HttpData- Specified by:
touchin interfaceio.netty.handler.codec.http.multipart.InterfaceHttpData- Specified by:
touchin interfaceio.netty.util.ReferenceCounted- Specified by:
touchin classio.netty.handler.codec.http.multipart.AbstractHttpData
-
hashCode
public int hashCode() -
equals
-
compareTo
public int compareTo(io.netty.handler.codec.http.multipart.InterfaceHttpData o) - Specified by:
compareToin interfaceComparable<io.netty.handler.codec.http.multipart.InterfaceHttpData>
-
compareTo
-
getHttpDataType
public io.netty.handler.codec.http.multipart.InterfaceHttpData.HttpDataType getHttpDataType()- Specified by:
getHttpDataTypein interfaceio.netty.handler.codec.http.multipart.InterfaceHttpData
-
getFilename
- Specified by:
getFilenamein interfaceio.netty.handler.codec.http.multipart.FileUpload
-
setFilename
- Specified by:
setFilenamein interfaceio.netty.handler.codec.http.multipart.FileUpload
-
setContentType
- Specified by:
setContentTypein interfaceio.netty.handler.codec.http.multipart.FileUpload
-
getContentType
- Specified by:
getContentTypein interfaceio.netty.handler.codec.http.multipart.FileUpload
-
getContentTransferEncoding
- Specified by:
getContentTransferEncodingin interfaceio.netty.handler.codec.http.multipart.FileUpload
-
setContentTransferEncoding
- Specified by:
setContentTransferEncodingin interfaceio.netty.handler.codec.http.multipart.FileUpload
-
length
public long length()- Specified by:
lengthin interfaceio.netty.handler.codec.http.multipart.HttpData- Overrides:
lengthin classio.netty.handler.codec.http.multipart.AbstractHttpData
-
toString
-