gi-soup-2.4.18: GI/Soup/Objects/Request.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
A request to retrieve a particular URI.
/Since: 2.42/
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Soup.Objects.Request
(
-- * Exported types
Request(..) ,
IsRequest ,
toRequest ,
noRequest ,
-- * Methods
-- ** getContentLength #method:getContentLength#
#if ENABLE_OVERLOADING
RequestGetContentLengthMethodInfo ,
#endif
requestGetContentLength ,
-- ** getContentType #method:getContentType#
#if ENABLE_OVERLOADING
RequestGetContentTypeMethodInfo ,
#endif
requestGetContentType ,
-- ** getSession #method:getSession#
#if ENABLE_OVERLOADING
RequestGetSessionMethodInfo ,
#endif
requestGetSession ,
-- ** getUri #method:getUri#
#if ENABLE_OVERLOADING
RequestGetUriMethodInfo ,
#endif
requestGetUri ,
-- ** send #method:send#
#if ENABLE_OVERLOADING
RequestSendMethodInfo ,
#endif
requestSend ,
-- ** sendAsync #method:sendAsync#
#if ENABLE_OVERLOADING
RequestSendAsyncMethodInfo ,
#endif
requestSendAsync ,
-- ** sendFinish #method:sendFinish#
#if ENABLE_OVERLOADING
RequestSendFinishMethodInfo ,
#endif
requestSendFinish ,
-- * Properties
-- ** session #attr:session#
{- | The request\'s 'GI.Soup.Objects.Session.Session'.
/Since: 2.42/
-}
#if ENABLE_OVERLOADING
RequestSessionPropertyInfo ,
#endif
constructRequestSession ,
getRequestSession ,
#if ENABLE_OVERLOADING
requestSession ,
#endif
-- ** uri #attr:uri#
{- | The request URI.
/Since: 2.42/
-}
#if ENABLE_OVERLOADING
RequestUriPropertyInfo ,
#endif
constructRequestUri ,
getRequestUri ,
#if ENABLE_OVERLOADING
requestUri ,
#endif
) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Interfaces.Initable as Gio.Initable
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Gio.Objects.InputStream as Gio.InputStream
import {-# SOURCE #-} qualified GI.Soup.Objects.Session as Soup.Session
import {-# SOURCE #-} qualified GI.Soup.Structs.URI as Soup.URI
-- | Memory-managed wrapper type.
newtype Request = Request (ManagedPtr Request)
foreign import ccall "soup_request_get_type"
c_soup_request_get_type :: IO GType
instance GObject Request where
gobjectType = c_soup_request_get_type
-- | Type class for types which can be safely cast to `Request`, for instance with `toRequest`.
class (GObject o, O.IsDescendantOf Request o) => IsRequest o
instance (GObject o, O.IsDescendantOf Request o) => IsRequest o
instance O.HasParentTypes Request
type instance O.ParentTypes Request = '[GObject.Object.Object, Gio.Initable.Initable]
-- | Cast to `Request`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toRequest :: (MonadIO m, IsRequest o) => o -> m Request
toRequest = liftIO . unsafeCastTo Request
-- | A convenience alias for `Nothing` :: `Maybe` `Request`.
noRequest :: Maybe Request
noRequest = Nothing
#if ENABLE_OVERLOADING
type family ResolveRequestMethod (t :: Symbol) (o :: *) :: * where
ResolveRequestMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveRequestMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveRequestMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveRequestMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveRequestMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveRequestMethod "init" o = Gio.Initable.InitableInitMethodInfo
ResolveRequestMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveRequestMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveRequestMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveRequestMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveRequestMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveRequestMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveRequestMethod "send" o = RequestSendMethodInfo
ResolveRequestMethod "sendAsync" o = RequestSendAsyncMethodInfo
ResolveRequestMethod "sendFinish" o = RequestSendFinishMethodInfo
ResolveRequestMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveRequestMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveRequestMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveRequestMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveRequestMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveRequestMethod "getContentLength" o = RequestGetContentLengthMethodInfo
ResolveRequestMethod "getContentType" o = RequestGetContentTypeMethodInfo
ResolveRequestMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveRequestMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveRequestMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveRequestMethod "getSession" o = RequestGetSessionMethodInfo
ResolveRequestMethod "getUri" o = RequestGetUriMethodInfo
ResolveRequestMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveRequestMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveRequestMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveRequestMethod t Request, O.MethodInfo info Request p) => OL.IsLabel t (Request -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif
-- VVV Prop "session"
-- Type: TInterface (Name {namespace = "Soup", name = "Session"})
-- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
-- Nullable: (Just False,Nothing)
{- |
Get the value of the “@session@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' request #session
@
-}
getRequestSession :: (MonadIO m, IsRequest o) => o -> m Soup.Session.Session
getRequestSession obj = liftIO $ checkUnexpectedNothing "getRequestSession" $ B.Properties.getObjectPropertyObject obj "session" Soup.Session.Session
{- |
Construct a `GValueConstruct` with valid value for the “@session@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructRequestSession :: (IsRequest o, Soup.Session.IsSession a) => a -> IO (GValueConstruct o)
constructRequestSession val = B.Properties.constructObjectPropertyObject "session" (Just val)
#if ENABLE_OVERLOADING
data RequestSessionPropertyInfo
instance AttrInfo RequestSessionPropertyInfo where
type AttrAllowedOps RequestSessionPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint RequestSessionPropertyInfo = Soup.Session.IsSession
type AttrBaseTypeConstraint RequestSessionPropertyInfo = IsRequest
type AttrGetType RequestSessionPropertyInfo = Soup.Session.Session
type AttrLabel RequestSessionPropertyInfo = "session"
type AttrOrigin RequestSessionPropertyInfo = Request
attrGet _ = getRequestSession
attrSet _ = undefined
attrConstruct _ = constructRequestSession
attrClear _ = undefined
#endif
-- VVV Prop "uri"
-- Type: TInterface (Name {namespace = "Soup", name = "URI"})
-- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
-- Nullable: (Just False,Nothing)
{- |
Get the value of the “@uri@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
@
'Data.GI.Base.Attributes.get' request #uri
@
-}
getRequestUri :: (MonadIO m, IsRequest o) => o -> m Soup.URI.URI
getRequestUri obj = liftIO $ checkUnexpectedNothing "getRequestUri" $ B.Properties.getObjectPropertyBoxed obj "uri" Soup.URI.URI
{- |
Construct a `GValueConstruct` with valid value for the “@uri@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructRequestUri :: (IsRequest o) => Soup.URI.URI -> IO (GValueConstruct o)
constructRequestUri val = B.Properties.constructObjectPropertyBoxed "uri" (Just val)
#if ENABLE_OVERLOADING
data RequestUriPropertyInfo
instance AttrInfo RequestUriPropertyInfo where
type AttrAllowedOps RequestUriPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint RequestUriPropertyInfo = (~) Soup.URI.URI
type AttrBaseTypeConstraint RequestUriPropertyInfo = IsRequest
type AttrGetType RequestUriPropertyInfo = Soup.URI.URI
type AttrLabel RequestUriPropertyInfo = "uri"
type AttrOrigin RequestUriPropertyInfo = Request
attrGet _ = getRequestUri
attrSet _ = undefined
attrConstruct _ = constructRequestUri
attrClear _ = undefined
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList Request
type instance O.AttributeList Request = RequestAttributeList
type RequestAttributeList = ('[ '("session", RequestSessionPropertyInfo), '("uri", RequestUriPropertyInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
requestSession :: AttrLabelProxy "session"
requestSession = AttrLabelProxy
requestUri :: AttrLabelProxy "uri"
requestUri = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
type instance O.SignalList Request = RequestSignalList
type RequestSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
-- method Request::get_content_length
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "request", argType = TInterface (Name {namespace = "Soup", name = "Request"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupRequest", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt64)
-- throws : False
-- Skip return : False
foreign import ccall "soup_request_get_content_length" soup_request_get_content_length ::
Ptr Request -> -- request : TInterface (Name {namespace = "Soup", name = "Request"})
IO Int64
{- |
Gets the length of the data represented by /@request@/. For most
request types, this will not be known until after you call
'GI.Soup.Objects.Request.requestSend' or 'GI.Soup.Objects.Request.requestSendFinish'.
/Since: 2.42/
-}
requestGetContentLength ::
(B.CallStack.HasCallStack, MonadIO m, IsRequest a) =>
a
{- ^ /@request@/: a 'GI.Soup.Objects.Request.Request' -}
-> m Int64
{- ^ __Returns:__ the length of the data represented by /@request@/,
or -1 if not known. -}
requestGetContentLength request = liftIO $ do
request' <- unsafeManagedPtrCastPtr request
result <- soup_request_get_content_length request'
touchManagedPtr request
return result
#if ENABLE_OVERLOADING
data RequestGetContentLengthMethodInfo
instance (signature ~ (m Int64), MonadIO m, IsRequest a) => O.MethodInfo RequestGetContentLengthMethodInfo a signature where
overloadedMethod _ = requestGetContentLength
#endif
-- method Request::get_content_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "request", argType = TInterface (Name {namespace = "Soup", name = "Request"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupRequest", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False
foreign import ccall "soup_request_get_content_type" soup_request_get_content_type ::
Ptr Request -> -- request : TInterface (Name {namespace = "Soup", name = "Request"})
IO CString
{- |
Gets the type of the data represented by /@request@/. For most request
types, this will not be known until after you call
'GI.Soup.Objects.Request.requestSend' or 'GI.Soup.Objects.Request.requestSendFinish'.
As in the HTTP Content-Type header, this may include parameters
after the MIME type.
/Since: 2.42/
-}
requestGetContentType ::
(B.CallStack.HasCallStack, MonadIO m, IsRequest a) =>
a
{- ^ /@request@/: a 'GI.Soup.Objects.Request.Request' -}
-> m (Maybe T.Text)
{- ^ __Returns:__ the type of the data represented by
/@request@/, or 'Nothing' if not known. -}
requestGetContentType request = liftIO $ do
request' <- unsafeManagedPtrCastPtr request
result <- soup_request_get_content_type request'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- cstringToText result'
return result''
touchManagedPtr request
return maybeResult
#if ENABLE_OVERLOADING
data RequestGetContentTypeMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsRequest a) => O.MethodInfo RequestGetContentTypeMethodInfo a signature where
overloadedMethod _ = requestGetContentType
#endif
-- method Request::get_session
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "request", argType = TInterface (Name {namespace = "Soup", name = "Request"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupRequest", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "Session"}))
-- throws : False
-- Skip return : False
foreign import ccall "soup_request_get_session" soup_request_get_session ::
Ptr Request -> -- request : TInterface (Name {namespace = "Soup", name = "Request"})
IO (Ptr Soup.Session.Session)
{- |
Gets /@request@/\'s 'GI.Soup.Objects.Session.Session'
/Since: 2.42/
-}
requestGetSession ::
(B.CallStack.HasCallStack, MonadIO m, IsRequest a) =>
a
{- ^ /@request@/: a 'GI.Soup.Objects.Request.Request' -}
-> m Soup.Session.Session
{- ^ __Returns:__ /@request@/\'s 'GI.Soup.Objects.Session.Session' -}
requestGetSession request = liftIO $ do
request' <- unsafeManagedPtrCastPtr request
result <- soup_request_get_session request'
checkUnexpectedReturnNULL "requestGetSession" result
result' <- (newObject Soup.Session.Session) result
touchManagedPtr request
return result'
#if ENABLE_OVERLOADING
data RequestGetSessionMethodInfo
instance (signature ~ (m Soup.Session.Session), MonadIO m, IsRequest a) => O.MethodInfo RequestGetSessionMethodInfo a signature where
overloadedMethod _ = requestGetSession
#endif
-- method Request::get_uri
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "request", argType = TInterface (Name {namespace = "Soup", name = "Request"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupRequest", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "URI"}))
-- throws : False
-- Skip return : False
foreign import ccall "soup_request_get_uri" soup_request_get_uri ::
Ptr Request -> -- request : TInterface (Name {namespace = "Soup", name = "Request"})
IO (Ptr Soup.URI.URI)
{- |
Gets /@request@/\'s URI
/Since: 2.42/
-}
requestGetUri ::
(B.CallStack.HasCallStack, MonadIO m, IsRequest a) =>
a
{- ^ /@request@/: a 'GI.Soup.Objects.Request.Request' -}
-> m Soup.URI.URI
{- ^ __Returns:__ /@request@/\'s URI -}
requestGetUri request = liftIO $ do
request' <- unsafeManagedPtrCastPtr request
result <- soup_request_get_uri request'
checkUnexpectedReturnNULL "requestGetUri" result
result' <- (newBoxed Soup.URI.URI) result
touchManagedPtr request
return result'
#if ENABLE_OVERLOADING
data RequestGetUriMethodInfo
instance (signature ~ (m Soup.URI.URI), MonadIO m, IsRequest a) => O.MethodInfo RequestGetUriMethodInfo a signature where
overloadedMethod _ = requestGetUri
#endif
-- method Request::send
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "request", argType = TInterface (Name {namespace = "Soup", name = "Request"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupRequest", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "InputStream"}))
-- throws : True
-- Skip return : False
foreign import ccall "soup_request_send" soup_request_send ::
Ptr Request -> -- request : TInterface (Name {namespace = "Soup", name = "Request"})
Ptr Gio.Cancellable.Cancellable -> -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
Ptr (Ptr GError) -> -- error
IO (Ptr Gio.InputStream.InputStream)
{- |
Synchronously requests the URI pointed to by /@request@/, and returns
a 'GI.Gio.Objects.InputStream.InputStream' that can be used to read its contents.
Note that you cannot use this method with @/SoupRequests/@ attached to
a 'GI.Soup.Objects.SessionAsync.SessionAsync'.
/Since: 2.42/
-}
requestSend ::
(B.CallStack.HasCallStack, MonadIO m, IsRequest a, Gio.Cancellable.IsCancellable b) =>
a
{- ^ /@request@/: a 'GI.Soup.Objects.Request.Request' -}
-> Maybe (b)
{- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable' or 'Nothing' -}
-> m Gio.InputStream.InputStream
{- ^ __Returns:__ a 'GI.Gio.Objects.InputStream.InputStream' that can be used to
read from the URI pointed to by /@request@/. /(Can throw 'Data.GI.Base.GError.GError')/ -}
requestSend request cancellable = liftIO $ do
request' <- unsafeManagedPtrCastPtr request
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
onException (do
result <- propagateGError $ soup_request_send request' maybeCancellable
checkUnexpectedReturnNULL "requestSend" result
result' <- (wrapObject Gio.InputStream.InputStream) result
touchManagedPtr request
whenJust cancellable touchManagedPtr
return result'
) (do
return ()
)
#if ENABLE_OVERLOADING
data RequestSendMethodInfo
instance (signature ~ (Maybe (b) -> m Gio.InputStream.InputStream), MonadIO m, IsRequest a, Gio.Cancellable.IsCancellable b) => O.MethodInfo RequestSendMethodInfo a signature where
overloadedMethod _ = requestSend
#endif
-- method Request::send_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "request", argType = TInterface (Name {namespace = "Soup", name = "Request"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupRequest", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data passed to @callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "soup_request_send_async" soup_request_send_async ::
Ptr Request -> -- request : TInterface (Name {namespace = "Soup", name = "Request"})
Ptr Gio.Cancellable.Cancellable -> -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
Ptr () -> -- user_data : TBasicType TPtr
IO ()
{- |
Begins an asynchronously request for the URI pointed to by
/@request@/.
Note that you cannot use this method with @/SoupRequests/@ attached to
a 'GI.Soup.Objects.SessionSync.SessionSync'.
/Since: 2.42/
-}
requestSendAsync ::
(B.CallStack.HasCallStack, MonadIO m, IsRequest a, Gio.Cancellable.IsCancellable b) =>
a
{- ^ /@request@/: a 'GI.Soup.Objects.Request.Request' -}
-> Maybe (b)
{- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable' or 'Nothing' -}
-> Maybe (Gio.Callbacks.AsyncReadyCallback)
{- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' -}
-> m ()
requestSendAsync request cancellable callback = liftIO $ do
request' <- unsafeManagedPtrCastPtr request
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
maybeCallback <- case callback of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jCallback -> do
ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
poke ptrcallback jCallback'
return jCallback'
let userData = nullPtr
soup_request_send_async request' maybeCancellable maybeCallback userData
touchManagedPtr request
whenJust cancellable touchManagedPtr
return ()
#if ENABLE_OVERLOADING
data RequestSendAsyncMethodInfo
instance (signature ~ (Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsRequest a, Gio.Cancellable.IsCancellable b) => O.MethodInfo RequestSendAsyncMethodInfo a signature where
overloadedMethod _ = requestSendAsync
#endif
-- method Request::send_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "request", argType = TInterface (Name {namespace = "Soup", name = "Request"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupRequest", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "InputStream"}))
-- throws : True
-- Skip return : False
foreign import ccall "soup_request_send_finish" soup_request_send_finish ::
Ptr Request -> -- request : TInterface (Name {namespace = "Soup", name = "Request"})
Ptr Gio.AsyncResult.AsyncResult -> -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
Ptr (Ptr GError) -> -- error
IO (Ptr Gio.InputStream.InputStream)
{- |
Gets the result of a 'GI.Soup.Objects.Request.requestSendAsync'.
/Since: 2.42/
-}
requestSendFinish ::
(B.CallStack.HasCallStack, MonadIO m, IsRequest a, Gio.AsyncResult.IsAsyncResult b) =>
a
{- ^ /@request@/: a 'GI.Soup.Objects.Request.Request' -}
-> b
{- ^ /@result@/: the 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
-> m Gio.InputStream.InputStream
{- ^ __Returns:__ a 'GI.Gio.Objects.InputStream.InputStream' that can be used to
read from the URI pointed to by /@request@/. /(Can throw 'Data.GI.Base.GError.GError')/ -}
requestSendFinish request result_ = liftIO $ do
request' <- unsafeManagedPtrCastPtr request
result_' <- unsafeManagedPtrCastPtr result_
onException (do
result <- propagateGError $ soup_request_send_finish request' result_'
checkUnexpectedReturnNULL "requestSendFinish" result
result' <- (wrapObject Gio.InputStream.InputStream) result
touchManagedPtr request
touchManagedPtr result_
return result'
) (do
return ()
)
#if ENABLE_OVERLOADING
data RequestSendFinishMethodInfo
instance (signature ~ (b -> m Gio.InputStream.InputStream), MonadIO m, IsRequest a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo RequestSendFinishMethodInfo a signature where
overloadedMethod _ = requestSendFinish
#endif