Class Multipart
- All Implemented Interfaces:
Proxy
Of particular interest to HTTP are multipart/byte-ranges
and
multipart/form-data
,
Although the headers of a SoupMultipart
body part will contain the
full headers from that body part, libsoup does not interpret them
according to MIME rules. For example, each body part is assumed to
have "binary" Content-Transfer-Encoding, even if its headers
explicitly state otherwise. In other words, don't try to use
SoupMultipart
for handling real MIME multiparts.
-
Constructor Summary
ConstructorDescriptionMultipart
(MemorySegment address) Create a Multipart proxy instance for the provided memory address.Creates a new emptySoupMultipart
with a randomly-generated boundary string. -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendFormFile
(String controlName, @Nullable String filename, @Nullable String contentType, Bytes body) Adds a new MIME part containingbody
to this Multipartvoid
appendFormString
(String controlName, String data) Adds a new MIME part containingdata
to this Multipart.void
appendPart
(MessageHeaders headers, Bytes body) Adds a new MIME part to this Multipart with the given headers and body.void
free()
Frees this Multipart.static Multipart
fromMessage
(MessageHeaders headers, Bytes body) Parsesheaders
andbody
to form a newSoupMultipart
int
Gets the number of body parts in this Multipart.boolean
getPart
(int part, Out<MessageHeaders> headers, Out<Bytes> body) Gets the indicated body part from this Multipart.static Type
getType()
Get the GType of the Multipart classvoid
toMessage
(MessageHeaders destHeaders, Out<Bytes> destBody) Serializes this Multipart todestHeaders
anddestBody
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Multipart
Create a Multipart proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Multipart
Creates a new emptySoupMultipart
with a randomly-generated boundary string.Note that
mimeType
must be the full MIME type, including "multipart/".See also:
Message.fromMultipart(java.lang.String, org.gnome.soup.Multipart)
.- Parameters:
mimeType
- the MIME type of the multipart to create.- Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
-
Method Details
-
getType
-
fromMessage
Parsesheaders
andbody
to form a newSoupMultipart
- Parameters:
headers
- the headers of the HTTP message to parsebody
- the body of the HTTP message to parse- Returns:
- a new
SoupMultipart
(ornull
if the message couldn't be parsed or wasn't multipart). - Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
appendFormFile
public void appendFormFile(String controlName, @Nullable @Nullable String filename, @Nullable @Nullable String contentType, Bytes body) Adds a new MIME part containingbody
to this MultipartUses "Content-Disposition: form-data", as per the HTML forms specification.
- Parameters:
controlName
- the name of the control associated with this filefilename
- the name of the file, ornull
if not knowncontentType
- the MIME type of the file, ornull
if not knownbody
- the file data
-
appendFormString
-
appendPart
Adds a new MIME part to this Multipart with the given headers and body.(The multipart will make its own copies of
headers
andbody
, so you should free your copies if you are not using them for anything else.)- Parameters:
headers
- the MIME part headersbody
- the MIME part body
-
free
public void free()Frees this Multipart. -
getLength
public int getLength()Gets the number of body parts in this Multipart.- Returns:
- the number of body parts in this Multipart
-
getPart
Gets the indicated body part from this Multipart.- Parameters:
part
- the part number to get (counting from 0)headers
- return location for the MIME part headersbody
- return location for the MIME part body- Returns:
true
on success,false
ifpart
is out of range (in which caseheaders
andbody
won't be set)
-
toMessage
Serializes this Multipart todestHeaders
anddestBody
.- Parameters:
destHeaders
- the headers of the HTTP message to serialize this Multipart todestBody
- the body of the HTTP message to serialize this Multipart to
-