3.6 <SoupMultipart>

Structure: <SoupMultipart>

Represents a multipart HTTP message body, parsed according to the syntax of RFC 2046.

Of particular interest to HTTP are multipart/byte-ranges and multipart/form-data,

Although the headers of a Multipart 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 Multipart for handling real MIME multiparts.

Procedures

Method: multipart:append-form-file self control-name filename content-type body
Method: append-form-file self control-name filename content-type body

Adds a new MIME part containing body to self

Uses "Content-Disposition: form-data", as per the HTML forms specification.

self

Passed: a <SoupMultipart>.

a multipart (presumably of type "multipart/form-data")

control-name

Passed: a string.

the name of the control associated with this file

filename

Passed: a string, or #f.

the name of the file, or #f if not known

content-type

Passed: a string, or #f.

the MIME type of the file, or #f if not known

body

Passed: a <GBytes>.

the file data

Method: multipart:append-form-string self control-name data
Method: append-form-string self control-name data

Adds a new MIME part containing data to self.

Uses "Content-Disposition: form-data", as per the HTML forms specification.

self

Passed: a <SoupMultipart>.

a multipart (presumably of type "multipart/form-data")

control-name

Passed: a string.

the name of the control associated with data

data

Passed: a string.

the body data

Method: multipart:append-part self headers body
Method: append-part self headers body

Adds a new MIME part to self with the given headers and body.

(The multipart will make its own copies of headers and body, so you should free your copies if you are not using them for anything else.)

self

Passed: a <SoupMultipart>.

a <SoupMultipart>

headers

Passed: a <SoupMessageHeaders>.

the MIME part headers

body

Passed: a <GBytes>.

the MIME part body

Method: multipart:free self
Method: free self

Frees self.

self

Passed: a <SoupMultipart>.

a <SoupMultipart>

Method: multipart:get-length self ⇒ %return
Method: get-length self ⇒ %return

Gets the number of body parts in self.

self

Passed: a <SoupMultipart>.

a <SoupMultipart>

%return

Returned: a 32-bit integer.

the number of body parts in self

Method: multipart:get-part self part ⇒ %return headers body
Method: get-part self part ⇒ %return headers body

Gets the indicated body part from self.

self

Passed: a <SoupMultipart>.

a <SoupMultipart>

part

Passed: a 32-bit integer.

the part number to get (counting from 0)

%return

Returned: a boolean.

#t on success, #f if part is out of range (in which case headers and body won’t be set)

headers

Returned: a <SoupMessageHeaders>.

return location for the MIME part headers

body

Returned: a <GBytes>.

return location for the MIME part body

Procedure: multipart:new mime-type ⇒ %return

Creates a new empty Multipart with a randomly-generated boundary string.

Note that mime-type must be the full MIME type, including "multipart/".

See also: Message.new_from_multipart.

mime-type

Passed: a string.

the MIME type of the multipart to create.

%return

Returned: a <SoupMultipart>.

a new empty <SoupMultipart> of the given mime-type

Procedure: multipart:new-from-message headers body ⇒ %return

Parses headers and body to form a new Multipart

headers

Passed: a <SoupMessageHeaders>.

the headers of the HTTP message to parse

body

Passed: a <GBytes>.

the body of the HTTP message to parse

%return

Returned: a <SoupMultipart>, or #f.

a new <SoupMultipart> (or #f if the message couldn’t be parsed or wasn’t multipart).

Method: multipart:to-message self dest-headers ⇒ dest-body
Method: to-message self dest-headers ⇒ dest-body

Serializes self to dest-headers and dest-body.

self

Passed: a <SoupMultipart>.

a <SoupMultipart>

dest-headers

Passed: a <SoupMessageHeaders>.

the headers of the HTTP message to serialize self to

dest-body

Returned: a <GBytes>.

the body of the HTTP message to serialize self to