Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Handles streams of multipart messages.
This adds support for the multipart responses. For handling the
multiple parts the user needs to wrap the InputStream
obtained by
sending the request with a [classmultipartInputStream
] and use
[methodmultipartInputStream
.next_part] before reading. Responses
which are not wrapped will be treated like non-multipart responses.
Note that although MultipartInputStream
is a InputStream
,
you should not read directly from it, and the results are undefined
if you do.
Synopsis
- newtype MultipartInputStream = MultipartInputStream (ManagedPtr MultipartInputStream)
- class (GObject o, IsDescendantOf MultipartInputStream o) => IsMultipartInputStream o
- toMultipartInputStream :: (MonadIO m, IsMultipartInputStream o) => o -> m MultipartInputStream
- multipartInputStreamGetHeaders :: (HasCallStack, MonadIO m, IsMultipartInputStream a) => a -> m (Maybe MessageHeaders)
- multipartInputStreamNew :: (HasCallStack, MonadIO m, IsMessage a, IsInputStream b) => a -> b -> m MultipartInputStream
- multipartInputStreamNextPart :: (HasCallStack, MonadIO m, IsMultipartInputStream a, IsCancellable b) => a -> Maybe b -> m (Maybe InputStream)
- multipartInputStreamNextPartAsync :: (HasCallStack, MonadIO m, IsMultipartInputStream a, IsCancellable b) => a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- multipartInputStreamNextPartFinish :: (HasCallStack, MonadIO m, IsMultipartInputStream a, IsAsyncResult b) => a -> b -> m (Maybe InputStream)
- constructMultipartInputStreamMessage :: (IsMultipartInputStream o, MonadIO m, IsMessage a) => a -> m (GValueConstruct o)
- getMultipartInputStreamMessage :: (MonadIO m, IsMultipartInputStream o) => o -> m (Maybe Message)
Exported types
newtype MultipartInputStream Source #
Memory-managed wrapper type.
MultipartInputStream (ManagedPtr MultipartInputStream) |
Instances
class (GObject o, IsDescendantOf MultipartInputStream o) => IsMultipartInputStream o Source #
Type class for types which can be safely cast to MultipartInputStream
, for instance with toMultipartInputStream
.
Instances
(GObject o, IsDescendantOf MultipartInputStream o) => IsMultipartInputStream o Source # | |
Defined in GI.Soup.Objects.MultipartInputStream |
toMultipartInputStream :: (MonadIO m, IsMultipartInputStream o) => o -> m MultipartInputStream Source #
Cast to MultipartInputStream
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, canPoll, clearPending, close, closeAsync, closeFinish, createSource, forceFloating, freezeNotify, getv, hasPending, isClosed, isFloating, isReadable, nextPart, nextPartAsync, nextPartFinish, notify, notifyByPspec, read, readAll, readAllAsync, readAllFinish, readAsync, readBytes, readBytesAsync, readBytesFinish, readFinish, readNonblocking, ref, refSink, runDispose, skip, skipAsync, skipFinish, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getBaseStream, getCloseBaseStream, getData, getHeaders, getProperty, getQdata.
Setters
setCloseBaseStream, setData, setDataFull, setPending, setProperty.
getHeaders
multipartInputStreamGetHeaders Source #
:: (HasCallStack, MonadIO m, IsMultipartInputStream a) | |
=> a |
|
-> m (Maybe MessageHeaders) | Returns: a |
Obtains the headers for the part currently being processed.
Note that the [structmessageHeaders
] that are returned are owned by the
MultipartInputStream
and will be replaced when a call is made to
[methodmultipartInputStream
.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 [structmessageHeaders
]
will be returned.
new
multipartInputStreamNew Source #
:: (HasCallStack, MonadIO m, IsMessage a, IsInputStream b) | |
=> a |
|
-> b |
|
-> m MultipartInputStream | Returns: a new |
Creates a new MultipartInputStream
that wraps the
InputStream
obtained by sending the [classmessage
].
Reads should not be done directly through this object, use the input streams
returned by [methodmultipartInputStream
.next_part] or its async
counterpart instead.
nextPart
multipartInputStreamNextPart Source #
:: (HasCallStack, MonadIO m, IsMultipartInputStream a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m (Maybe InputStream) | Returns: a new |
Obtains an input stream for the next part.
When dealing with a multipart response the input stream needs to be wrapped
in a MultipartInputStream
and this function or its async counterpart
need to be called to obtain the first part for reading.
After calling this function,
[methodmultipartInputStream
.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.
nextPartAsync
multipartInputStreamNextPartAsync Source #
:: (HasCallStack, MonadIO m, IsMultipartInputStream a, IsCancellable b) | |
=> a |
|
-> Int32 |
|
-> Maybe b |
|
-> Maybe AsyncReadyCallback |
|
-> m () |
Obtains a InputStream
for the next request.
See [methodmultipartInputStream
.next_part] for details on the workflow.
nextPartFinish
multipartInputStreamNextPartFinish Source #
:: (HasCallStack, MonadIO m, IsMultipartInputStream a, IsAsyncResult b) | |
=> a |
|
-> b |
|
-> m (Maybe InputStream) | Returns: a newly created
|
Finishes an asynchronous request for the next part.
Properties
message
The [classmessage
].
constructMultipartInputStreamMessage :: (IsMultipartInputStream o, MonadIO m, IsMessage a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “message
” property. This is rarely needed directly, but it is used by new
.
getMultipartInputStreamMessage :: (MonadIO m, IsMultipartInputStream o) => o -> m (Maybe Message) Source #
Get the value of the “message
” property.
When overloading is enabled, this is equivalent to
get
multipartInputStream #message