## SoupMultipart

SoupMultipart — multipart HTTP message bodies

## Functions

SoupMultipart * | soup_multipart_new ()
SoupMultipart * | soup_multipart_new_from_message ()
void | soup_multipart_free ()
int | soup_multipart_get_length ()
gboolean | soup_multipart_get_part ()
void | soup_multipart_append_part ()
void | soup_multipart_append_form_string ()
void | soup_multipart_append_form_file ()
void | soup_multipart_to_message ()

## Types and Values

typedef | SoupMultipart

## Object Hierarchy

        GBoxed
        ╰── SoupMultipart

## Includes

    #include <libsoup/soup.h>

## Description

## Functions

### soup_multipart_new ()

    SoupMultipart *
    soup_multipart_new (const char *mime_type);

Creates a new empty SoupMultipart with a randomly-generated boundary string. Note that `mime_type` must be the full MIME type, including "multipart/".

#### Parameters

mime_type | the MIME type of the multipart to create. |

#### Returns

a new empty SoupMultipart of the given `mime_type`

Since: 2.26

### soup_multipart_new_from_message ()

    SoupMultipart *
    soup_multipart_new_from_message (SoupMessageHeaders *headers,
                                     SoupMessageBody *body);

Parses `headers` and `body` to form a new SoupMultipart

#### Parameters

headers | the headers of the HTTP message to parse |
body | the body of the HTTP message to parse |

#### Returns

a new SoupMultipart (or `NULL` if the message couldn't be parsed or wasn't multipart).

[nullable]

Since: 2.26

### soup_multipart_free ()

    void
    soup_multipart_free (SoupMultipart *multipart);

Frees `multipart`

#### Parameters

multipart | a SoupMultipart |

Since: 2.26

### soup_multipart_get_length ()

    int
    soup_multipart_get_length (SoupMultipart *multipart);

Gets the number of body parts in `multipart`

#### Parameters

multipart | a SoupMultipart |

#### Returns

the number of body parts in `multipart`

Since: 2.26

### soup_multipart_get_part ()

    gboolean
    soup_multipart_get_part (SoupMultipart *multipart,
                             int part,
                             SoupMessageHeaders **headers,
                             SoupBuffer **body);

Gets the indicated body part from `multipart` .

#### Parameters

multipart | a SoupMultipart |
part | the part number to get (counting from 0) |
headers | return location for the MIME part headers. | [out][transfer none]
body | return location for the MIME part body. | [out][transfer none]

#### Returns

`TRUE` on success, `FALSE` if `part` is out of range (in which case `headers` and `body` won't be set)

Since: 2.26

### soup_multipart_append_part ()

    void
    soup_multipart_append_part (SoupMultipart *multipart,
                                SoupMessageHeaders *headers,
                                SoupBuffer *body);

Adds a new MIME part to `multipart` 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.)

#### Parameters

multipart | a SoupMultipart |
headers | the MIME part headers |
body | the MIME part body |

Since: 2.26

### soup_multipart_append_form_string ()

    void
    soup_multipart_append_form_string (SoupMultipart *multipart,
                                       const char *control_name,
                                       const char *data);

Adds a new MIME part containing `data` to `multipart` , using "Content-Disposition: form-data", as per the HTML forms specification. See `soup_form_request_new_from_multipart()` for more details.

#### Parameters

multipart | a multipart (presumably of type "multipart/form-data") |
control_name | the name of the control associated with `data` |
data | the body data |

Since: 2.26

### soup_multipart_append_form_file ()

    void
    soup_multipart_append_form_file (SoupMultipart *multipart,
                                     const char *control_name,
                                     const char *filename,
                                     const char *content_type,
                                     SoupBuffer *body);

Adds a new MIME part containing `body` to `multipart` , using "Content-Disposition: form-data", as per the HTML forms specification. See `soup_form_request_new_from_multipart()` for more details.

#### Parameters

multipart | a multipart (presumably of type "multipart/form-data") |
control_name | the name of the control associated with this file |
filename | the name of the file, or `NULL` if not known |
content_type | the MIME type of the file, or `NULL` if not known |
body | the file data |

Since: 2.26

### soup_multipart_to_message ()

    void
    soup_multipart_to_message (SoupMultipart *multipart,
                               SoupMessageHeaders *dest_headers,
                               SoupMessageBody *dest_body);

Serializes `multipart` to `dest_headers` and `dest_body` .

#### Parameters

multipart | a SoupMultipart |
dest_headers | the headers of the HTTP message to serialize `multipart` to |
dest_body | the body of the HTTP message to serialize `multipart` to |

Since: 2.26

## Types and Values

### SoupMultipart

    typedef struct SoupMultipart 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 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.

Since: 2.26

## See Also

SoupMessageBody, SoupMessageHeaders