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.FileUploadA FileUpload implementation that is responsible for sending Multi<Byte> as a file in a multipart message. It is meant to be used by thePausableHttpPostRequestEncoderWhen created, MultiByteHttpData will subscribe to the underlying Multi and requestBUFFER_SIZEof bytes. Before reading the next chunk of data withgetChunk(int), the post encoder checks if dataisReady(int)and if not, triggerssuspend(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.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_BUFFER_SIZE
-
Constructor Summary
Constructors Constructor Description 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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddContent(io.netty.buffer.ByteBuf buffer, boolean last)intcompareTo(io.netty.handler.codec.http.multipart.InterfaceHttpData o)intcompareTo(MultiByteHttpData o)io.netty.handler.codec.http.multipart.FileUploadcopy()voiddelete()io.netty.handler.codec.http.multipart.FileUploadduplicate()booleanequals(Object o)byte[]get()io.netty.buffer.ByteBufgetByteBuf()io.netty.buffer.ByteBufgetChunk(int toRead)
NOTE: should only be invoked whenisReady(int)returns trueStringgetContentTransferEncoding()StringgetContentType()FilegetFile()StringgetFilename()io.netty.handler.codec.http.multipart.InterfaceHttpData.HttpDataTypegetHttpDataType()StringgetString()StringgetString(Charset encoding)inthashCode()booleanisInMemory()booleanisReady(int chunkSize)check if it is possible to read the next chunk of data of a given sizebooleanrenameTo(File dest)io.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.FileUploadretainedDuplicate()voidsetContent(io.netty.buffer.ByteBuf buffer)voidsetContent(File file)voidsetContent(InputStream inputStream)voidsetContentTransferEncoding(String contentTransferEncoding)voidsetContentType(String contentType)voidsetFilename(String filename)StringtoString()io.netty.handler.codec.http.multipart.FileUploadtouch()io.netty.handler.codec.http.multipart.FileUploadtouch(Object hint)-
Methods inherited from class io.netty.handler.codec.http.multipart.AbstractHttpData
checkSize, content, deallocate, definedLength, getCharset, getMaxSize, getName, isCompleted, length, setCharset, setCompleted, setCompleted, setMaxSize
-
Methods inherited from class io.netty.util.AbstractReferenceCounted
refCnt, release, release, setRefCnt
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
setContent
public void setContent(io.netty.buffer.ByteBuf buffer) throws IOException- Specified by:
setContentin interfaceio.netty.handler.codec.http.multipart.HttpData- Throws:
IOException
-
addContent
public void addContent(io.netty.buffer.ByteBuf buffer, boolean last) throws IOException- Specified by:
addContentin interfaceio.netty.handler.codec.http.multipart.HttpData- Throws:
IOException
-
setContent
public void setContent(File file) throws IOException
- Specified by:
setContentin interfaceio.netty.handler.codec.http.multipart.HttpData- Throws:
IOException
-
setContent
public void setContent(InputStream inputStream) throws IOException
- 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
public byte[] get() throws IOException- 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
public String getString()
- Specified by:
getStringin interfaceio.netty.handler.codec.http.multipart.HttpData
-
getString
public String getString(Charset encoding)
- Specified by:
getStringin interfaceio.netty.handler.codec.http.multipart.HttpData
-
renameTo
public boolean renameTo(File dest)
- 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
public File 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
public io.netty.handler.codec.http.multipart.FileUpload touch(Object hint)
- 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
-
compareTo
public int compareTo(io.netty.handler.codec.http.multipart.InterfaceHttpData o)
- Specified by:
compareToin interfaceComparable<io.netty.handler.codec.http.multipart.InterfaceHttpData>
-
compareTo
public int compareTo(MultiByteHttpData o)
-
getHttpDataType
public io.netty.handler.codec.http.multipart.InterfaceHttpData.HttpDataType getHttpDataType()
- Specified by:
getHttpDataTypein interfaceio.netty.handler.codec.http.multipart.InterfaceHttpData
-
getFilename
public String getFilename()
- Specified by:
getFilenamein interfaceio.netty.handler.codec.http.multipart.FileUpload
-
setFilename
public void setFilename(String filename)
- Specified by:
setFilenamein interfaceio.netty.handler.codec.http.multipart.FileUpload
-
setContentType
public void setContentType(String contentType)
- Specified by:
setContentTypein interfaceio.netty.handler.codec.http.multipart.FileUpload
-
getContentType
public String getContentType()
- Specified by:
getContentTypein interfaceio.netty.handler.codec.http.multipart.FileUpload
-
getContentTransferEncoding
public String getContentTransferEncoding()
- Specified by:
getContentTransferEncodingin interfaceio.netty.handler.codec.http.multipart.FileUpload
-
setContentTransferEncoding
public void setContentTransferEncoding(String contentTransferEncoding)
- Specified by:
setContentTransferEncodingin interfaceio.netty.handler.codec.http.multipart.FileUpload
-
-