public class Multipart extends Object implements Writable
MultipartMessage can have multiple parts within it; each of these
parts is represented by Multipart. A Multipart contains
headers and body. Headers are stored in a Map and miltipart body is
held in a Content| Modifier and Type | Field and Description |
|---|---|
static String |
CONTENT_LENGTH |
static String |
CONTENT_TYPE |
static byte |
CR |
static byte |
LF |
static ByteBuffer |
LINE_FEED_BUFFER |
protected static byte[] |
LINE_FEED_BYTES |
static String |
NAME |
| Constructor and Description |
|---|
Multipart() |
Multipart(Map<String,String> headers,
byte[] content) |
Multipart(String name) |
Multipart(String name,
Content content) |
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(String key,
String value) |
void |
addHeaders(Map<String,String> headers) |
protected byte[] |
generateHeaderBytes()
Append headers to a String and generate bytes using
StandardCharsets.US_ASCII encoding. |
Content |
getContent() |
int |
getContentLength() |
ContentSource |
getContentSource() |
String |
getContentType() |
String |
getHeader(String key) |
byte[] |
getHeaderBytes() |
Map<String,String> |
getHeaders() |
long |
getMultipartLength()
Calculate the length of this multipart object.
|
String |
getName() |
void |
setContent(Content content) |
long |
writeTo(OutputStream os)
Write to an
OutputStream |
long |
writeTo(Socket socket)
Write this entity to a network socket.
|
long |
writeTo(SocketChannel socketChannel)
Write this entity to a
SocketChannel |
public static final byte LF
public static final byte CR
public static final String NAME
public static final String CONTENT_TYPE
public static final String CONTENT_LENGTH
protected static final byte[] LINE_FEED_BYTES
public static final ByteBuffer LINE_FEED_BUFFER
public Multipart()
public Multipart(String name)
public Content getContent()
public void setContent(Content content)
public ContentSource getContentSource()
public int getContentLength()
public String getName()
protected byte[] generateHeaderBytes()
StandardCharsets.US_ASCII encoding.public byte[] getHeaderBytes()
public String getContentType()
Multipartpublic long getMultipartLength()
public long writeTo(Socket socket) throws IOException
WritablewriteTo in interface Writablesocket - network socket on which bytes will be writtenIOException - if any IO error occurredpublic long writeTo(OutputStream os) throws IOException
WritableOutputStreamwriteTo in interface Writableos - OutputStream insatnceIOException - if IO error occurrspublic long writeTo(SocketChannel socketChannel) throws IOException
WritableSocketChannelwriteTo in interface WritablesocketChannel - network socket channelIOException - if any IO error occurred while writing bytesCopyright © 2019. All rights reserved.