:right-sidebar: True MultipartInputStream =================================================================== .. currentmodule:: gi.repository.Soup .. class:: MultipartInputStream(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gio.FilterInputStream`, :class:`~gi.repository.Gio.InputStream`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gio.PollableInputStream` Handles streams of multipart messages. This adds support for the multipart responses. For handling the multiple parts the user needs to wrap the :obj:`~gi.repository.Gio.InputStream` obtained by sending the request with a :obj:`~gi.repository.Soup.MultipartInputStream` and use :obj:`~gi.repository.MultipartInputStream.next_part` before reading. Responses which are not wrapped will be treated like non-multipart responses. Note that although :obj:`~gi.repository.Soup.MultipartInputStream` is a :obj:`~gi.repository.Gio.InputStream`\, you should not read directly from it, and the results are undefined if you do. Constructors ------------ .. rst-class:: interim-class .. class:: MultipartInputStream :no-index: .. classmethod:: new(msg: ~gi.repository.Soup.Message, base_stream: ~gi.repository.Gio.InputStream) -> ~gi.repository.Soup.MultipartInputStream Creates a new :obj:`~gi.repository.Soup.MultipartInputStream` that wraps the :obj:`~gi.repository.Gio.InputStream` obtained by sending the :obj:`~gi.repository.Soup.Message`\. Reads should not be done directly through this object, use the input streams returned by :obj:`~gi.repository.MultipartInputStream.next_part` or its async counterpart instead. :param msg: the :obj:`~gi.repository.Soup.Message` the response is related to. :param base_stream: the :obj:`~gi.repository.Gio.InputStream` returned by sending the request. Methods ------- .. rst-class:: interim-class .. class:: MultipartInputStream :no-index: .. method:: get_headers() -> ~gi.repository.Soup.MessageHeaders | None Obtains the headers for the part currently being processed. Note that the :obj:`~gi.repository.Soup.MessageHeaders` that are returned are owned by the :obj:`~gi.repository.Soup.MultipartInputStream` and will be replaced when a call is made to :obj:`~gi.repository.MultipartInputStream.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 :obj:`~gi.repository.Soup.MessageHeaders` will be returned. .. method:: next_part(cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Gio.InputStream | None Obtains an input stream for the next part. When dealing with a multipart response the input stream needs to be wrapped in a :obj:`~gi.repository.Soup.MultipartInputStream` and this function or its async counterpart need to be called to obtain the first part for reading. After calling this function, :obj:`~gi.repository.MultipartInputStream.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. ``error`` will only be set if an error happens during a read, :const:`None` is a valid return value otherwise. :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` .. method:: next_part_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, data: ~typing.Any = None) -> None Obtains a :obj:`~gi.repository.Gio.InputStream` for the next request. See :obj:`~gi.repository.MultipartInputStream.next_part` for details on the workflow. :param io_priority: the I/O priority for the request. :param cancellable: a :obj:`~gi.repository.Gio.Cancellable`\. :param callback: callback to call when request is satisfied. :param data: data for ``callback`` .. method:: next_part_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.InputStream | None Finishes an asynchronous request for the next part. :param result: a :obj:`~gi.repository.Gio.AsyncResult`\. Properties ---------- .. rst-class:: interim-class .. class:: MultipartInputStream :no-index: .. attribute:: props.message :type: ~gi.repository.Soup.Message The type of the None singleton.