SoupMultipartInputStream

## SoupMultipartInputStream SoupMultipartInputStream — Multipart input handling stream |

## Synopsis

    #include <libsoup/soup.h>

    struct              SoupMultipartInputStream;
    SoupMultipartInputStream * soup_multipart_input_stream_new
                                                            (SoupMessage *msg,
                                                             GInputStream *base_stream);

    SoupMessageHeaders * soup_multipart_input_stream_get_headers
                                                            (SoupMultipartInputStream *multipart);
    GInputStream *      soup_multipart_input_stream_next_part
                                                            (SoupMultipartInputStream *multipart,
                                                             GCancellable *cancellable,
                                                             GError **error);
    void                soup_multipart_input_stream_next_part_async
                                                            (SoupMultipartInputStream *multipart,
                                                             int io_priority,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer data);
    GInputStream *      soup_multipart_input_stream_next_part_finish
                                                            (SoupMultipartInputStream *multipart,
                                                             GAsyncResult *result,
                                                             GError **error);

## Object Hierarchy

      GObject
       +----GInputStream
             +----GFilterInputStream
                   +----SoupMultipartInputStream

## Implemented Interfaces

SoupMultipartInputStream implements GPollableInputStream.

## Properties

      "message"                  SoupMessage*          : Read / Write / Construct Only

## Description

This adds support for the multipart responses. For handling the multiple parts the user needs to wrap the GInputStream obtained by sending the request with a SoupMultipartInputStream and use `soup_multipart_input_stream_next_part()` before reading. Responses which are not wrapped will be treated like non-multipart responses.

Note that although SoupMultipartInputStream is a GInputStream, you should not read directly from it, and the results are undefined if you do.

## Details

### struct SoupMultipartInputStream

    struct SoupMultipartInputStream;

### soup_multipart_input_stream_new ()

    SoupMultipartInputStream * soup_multipart_input_stream_new
                                                            (SoupMessage *msg,
                                                             GInputStream *base_stream);

Creates a new SoupMultipartInputStream that wraps the GInputStream obtained by sending the SoupRequest. Reads should not be done directly through this object, use the input streams returned by `soup_multipart_input_stream_next_part()` or its async counterpart instead.

`msg` : | the SoupMessage the response is related to.
`base_stream` : | the GInputStream returned by sending the request.
Returns : | a new SoupMultipartInputStream

Since 2.40

### soup_multipart_input_stream_get_headers ()

    SoupMessageHeaders * soup_multipart_input_stream_get_headers
                                                            (SoupMultipartInputStream *multipart);

Obtains the headers for the part currently being processed. Note that the SoupMessageHeaders that are returned are owned by the SoupMultipartInputStream and will be replaced when a call is made to `soup_multipart_input_stream_next_part()` or its async counterpart, so if keeping the headers is required, a copy must be made.

Note that if a part had no headers at all an empty SoupMessageHeaders will be returned.

`multipart` : | a SoupMultipartInputStream.
Returns : | a SoupMessageHeaders containing the headers for the part currently being processed or `NULL` if the headers failed to parse. [transfer none]

Since 2.40

### soup_multipart_input_stream_next_part ()

    GInputStream *      soup_multipart_input_stream_next_part
                                                            (SoupMultipartInputStream *multipart,
                                                             GCancellable *cancellable,
                                                             GError **error);

Obtains an input stream for the next part. When dealing with a multipart response the input stream needs to be wrapped in a SoupMultipartInputStream and this function or its async counterpart need to be called to obtain the first part for reading.

After calling this function, `soup_multipart_input_stream_get_headers()` can be used to obtain the headers for the first part. A read of 0 bytes indicates the end of the part; a new call to this function should be done at that point, to obtain the next part.

`multipart` : | the SoupMultipartInputStream
`cancellable` : | a GCancellable
`error` : | a GError
Returns : | a new GInputStream, or `NULL` if there are no more parts. [transfer full]

Since 2.40

### soup_multipart_input_stream_next_part_async ()

    void                soup_multipart_input_stream_next_part_async
                                                            (SoupMultipartInputStream *multipart,
                                                             int io_priority,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer data);

Obtains a GInputStream for the next request. See `soup_multipart_input_stream_next_part()` for details on the workflow.

`multipart` : | the SoupMultipartInputStream.
`io_priority` : | the I/O priority for the request.
`cancellable` : | a GCancellable.
`callback` : | callback to call when request is satisfied.

Since 2.40

### soup_multipart_input_stream_next_part_finish ()

    GInputStream *      soup_multipart_input_stream_next_part_finish
                                                            (SoupMultipartInputStream *multipart,
                                                             GAsyncResult *result,
                                                             GError **error);

Finishes an asynchronous request for the next part.

`multipart` : | a SoupMultipartInputStream.
`result` : | a GAsyncResult.
`error` : | a GError location to store any error, or NULL to ignore.
Returns : | a newly created GInputStream for reading the next part or `NULL` if there are no more parts. [transfer full]

Since 2.40

## Property Details

### The `"message"` property

      "message"                  SoupMessage*          : Read / Write / Construct Only

The SoupMessage.