Soup.MultipartInputStream¶
- Subclasses:
None
Methods¶
- Inherited:
Gio.FilterInputStream (3), Gio.InputStream (19), GObject.Object (37), Gio.PollableInputStream (4)
- Structs:
class |
|
|
|
|
|
|
|
|
Virtual Methods¶
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w/co |
The |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Soup.MultipartInputStream(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Handles streams of multipart messages.
This adds support for the multipart responses. For handling the multiple parts the user needs to wrap the [class`Gio`.InputStream] obtained by sending the request with a [class`MultipartInputStream`] and use [method`MultipartInputStream`.next_part] before reading. Responses which are not wrapped will be treated like non-multipart responses.
Note that although
Soup.MultipartInputStreamis a [class`Gio`.InputStream], you should not read directly from it, and the results are undefined if you do.- classmethod new(msg, base_stream)¶
- Parameters:
msg (
Soup.Message) – theSoup.Messagethe response is related to.base_stream (
Gio.InputStream) – theGio.InputStreamreturned by sending the request.
- Returns:
- Return type:
Creates a new
Soup.MultipartInputStreamthat wraps the [class`Gio`.InputStream] obtained by sending the [class`Message`].Reads should not be done directly through this object, use the input streams returned by [method`MultipartInputStream`.next_part] or its async counterpart instead.
- get_headers()¶
- Returns:
a
Soup.MessageHeaderscontaining the headers for the part currently being processed orNoneif the headers failed to parse.- Return type:
Obtains the headers for the part currently being processed.
Note that the [struct`MessageHeaders`] that are returned are owned by the
Soup.MultipartInputStreamand will be replaced when a call is made to [method`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 [struct`MessageHeaders`] will be returned.
- next_part(cancellable)¶
- Parameters:
cancellable (
Gio.CancellableorNone) – aGio.Cancellable- Raises:
- Returns:
a new
Gio.InputStream, orNoneif there are no more parts- Return type:
Obtains an input stream for the next part.
When dealing with a multipart response the input stream needs to be wrapped in a
Soup.MultipartInputStreamand this function or its async counterpart need to be called to obtain the first part for reading.After calling this function, [method`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,
Noneis a valid return value otherwise.
- next_part_async(io_priority, cancellable, callback, *data)¶
- Parameters:
io_priority (
int) – the I/O priority for the request.cancellable (
Gio.CancellableorNone) – aGio.Cancellable.callback (
Gio.AsyncReadyCallbackorNone) – callback to call when request is satisfied.
Obtains a [class`Gio`.InputStream] for the next request.
See [method`MultipartInputStream`.next_part] for details on the workflow.
- next_part_finish(result)¶
- Parameters:
result (
Gio.AsyncResult) – aGio.AsyncResult.- Raises:
- Returns:
a newly created [class`Gio`.InputStream] for reading the next part or
Noneif there are no more parts.- Return type:
Finishes an asynchronous request for the next part.
Property Details¶
- Soup.MultipartInputStream.props.message¶
- Name:
message- Type:
- Default Value:
- Flags:
The [class`Message`].