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
ConstructorsConstructorDescriptionMultipart(MemorySegment address) Create a Multipart proxy instance for the provided memory address.Creates a new emptySoupMultipartwith a randomly-generated boundary string. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendFormFile(String controlName, @Nullable String filename, @Nullable String contentType, byte[] body) Adds a new MIME part containingbodyto this MultipartvoidappendFormString(String controlName, String data) Adds a new MIME part containingdatatomultipart.voidappendPart(MessageHeaders headers, byte[] body) Adds a new MIME part to this Multipart with the given headers and body.voidfree()Freesmultipart.static MultipartfromMessage(MessageHeaders headers, byte[] body) Parsesheadersandbodyto form a newSoupMultipartintGets the number of body parts inmultipart.booleangetPart(int part, Out<MessageHeaders> headers, Out<byte[]> body) Gets the indicated body part frommultipart.static @Nullable TypegetType()Get the GType of the Multipart classvoidtoMessage(MessageHeaders destHeaders, Out<byte[]> destBody) Serializes this Multipart todestHeadersanddestBody.Methods inherited from class org.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 emptySoupMultipartwith a randomly-generated boundary string.Note that
mimeTypemust 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.
-
-
Method Details
-
getType
-
fromMessage
Parsesheadersandbodyto 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(ornullif the message couldn't be parsed or wasn't multipart).
-
appendFormFile
public void appendFormFile(String controlName, @Nullable String filename, @Nullable String contentType, byte[] body) Adds a new MIME part containingbodyto 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, ornullif not knowncontentType- the MIME type of the file, ornullif 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
headersandbody,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()Freesmultipart. -
getLength
public int getLength()Gets the number of body parts inmultipart.- Returns:
- the number of body parts in this Multipart
-
getPart
Gets the indicated body part frommultipart.- 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:
trueon success,falseifpartis out of range (in which caseheadersandbodywon't be set)
-
toMessage
Serializes this Multipart todestHeadersanddestBody.- Parameters:
destHeaders- the headers of the HTTP message to serialize this Multipart todestBody- the body of the HTTP message to serialize this Multipart to
-