public class MultipartContent extends AbstractHttpContent
By default the media type is "multipart/related; boundary=__END_OF_PART__", but this may be customized by calling setMediaType(HttpMediaType), AbstractHttpContent, or setBoundary(String).
Implementation is not thread-safe.
| Modifier and Type | Class and Description |
|---|---|
static class |
MultipartContent
Single part of a multi-part request.
|
| Constructor and Description |
|---|
MultipartContent()
|
| Modifier and Type | Method and Description |
|---|---|
MultipartContent |
addPart(MultipartContent
Adds an HTTP multipart part.
|
String |
getBoundary()
Returns the boundary string to use.
|
Collection |
getParts()
Returns an unmodifiable view of the parts of the HTTP multipart request.
|
boolean |
retrySupported()
Default implementation returns
true, but subclasses may override.
|
MultipartContent |
setBoundary(String
Sets the boundary string to use.
|
MultipartContent |
setContentParts(Collection
Sets the HTTP content parts of the HTTP multipart request, where each part is assumed to have no HTTP headers and no encoding.
|
MultipartContent |
setMediaType(HttpMediaType
Sets the media type to use for the Content-Type header, or
null if unspecified.
|
MultipartContent |
setParts(Collection
Sets the parts of the HTTP multipart request.
|
void |
writeTo(OutputStream
Writes the byte content to the given output stream.
|
computeLength, computeLength, getCharset, getLength, getMediaType, getTypepublic void writeTo(OutputStreamout) throws IOException
StreamingContent
Implementations must not close the output stream, and instead should flush the output stream. Some callers may assume that the the output stream has not been closed, and will fail to work if it has been closed.
out - output stream
IOException
public boolean retrySupported()
AbstractHttpContent
true, but subclasses may override.
public MultipartContentsetMediaType(HttpMediaType mediaType)
AbstractHttpContent
null if unspecified.
This will also overwrite any previously set parameter of the media type (for example "charset"), and therefore might change other properties as well.
public final Collection<MultipartContent .Part > getParts()
public MultipartContentaddPart(MultipartContent .Part part)
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
public MultipartContentsetParts(Collection <MultipartContent .Part > parts)
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
public MultipartContentsetContentParts(Collection <? extends HttpContent > contentParts)
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
public final StringgetBoundary()
public MultipartContentsetBoundary(String boundary)
Defaults to "END_OF_PART".
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.