Class MultipartBody
- java.lang.Object
-
- org.asynchttpclient.request.body.multipart.MultipartBody
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Body
,RandomAccessBody
public class MultipartBody extends Object implements RandomAccessBody
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.asynchttpclient.request.body.Body
Body.BodyState
-
-
Constructor Summary
Constructors Constructor Description MultipartBody(List<MultipartPart<? extends Part>> parts, String contentType, byte[] boundary)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
byte[]
getBoundary()
long
getContentLength()
Gets the length of the body.String
getContentType()
Body.BodyState
transferTo(io.netty.buffer.ByteBuf target)
Reads the next chunk of bytes from the body.long
transferTo(WritableByteChannel target)
Transfers the specified chunk of bytes from this body to the specified channel.
-
-
-
Constructor Detail
-
MultipartBody
public MultipartBody(List<MultipartPart<? extends Part>> parts, String contentType, byte[] boundary)
-
-
Method Detail
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getContentLength
public long getContentLength()
Description copied from interface:Body
Gets the length of the body.- Specified by:
getContentLength
in interfaceBody
- Returns:
- The length of the body in bytes, or negative if unknown.
-
getContentType
public String getContentType()
-
getBoundary
public byte[] getBoundary()
-
transferTo
public Body.BodyState transferTo(io.netty.buffer.ByteBuf target) throws IOException
Description copied from interface:Body
Reads the next chunk of bytes from the body.- Specified by:
transferTo
in interfaceBody
- Parameters:
target
- The buffer to store the chunk in, must not benull
.- Returns:
- The state.
- Throws:
IOException
- If the chunk could not be read.
-
transferTo
public long transferTo(WritableByteChannel target) throws IOException
Description copied from interface:RandomAccessBody
Transfers the specified chunk of bytes from this body to the specified channel.- Specified by:
transferTo
in interfaceRandomAccessBody
- Parameters:
target
- The destination channel to transfer the body chunk to, must not benull
.- Returns:
- The non-negative number of bytes actually transferred.
- Throws:
IOException
- If the body chunk could not be transferred.
-
-