{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A request to retrieve a particular URI.
-- 
-- /Since: 2.42/

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Soup.Objects.Request
    ( 

-- * Exported types
    Request(..)                             ,
    IsRequest                               ,
    toRequest                               ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [init]("GI.Gio.Interfaces.Initable#g:method:init"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [send]("GI.Soup.Objects.Request#g:method:send"), [sendAsync]("GI.Soup.Objects.Request#g:method:sendAsync"), [sendFinish]("GI.Soup.Objects.Request#g:method:sendFinish"), [stealData]("GI.GObject.Objects.Object#g:method:stealData"), [stealQdata]("GI.GObject.Objects.Object#g:method:stealQdata"), [thawNotify]("GI.GObject.Objects.Object#g:method:thawNotify"), [unref]("GI.GObject.Objects.Object#g:method:unref"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure").
-- 
-- ==== Getters
-- [getContentLength]("GI.Soup.Objects.Request#g:method:getContentLength"), [getContentType]("GI.Soup.Objects.Request#g:method:getContentType"), [getData]("GI.GObject.Objects.Object#g:method:getData"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata"), [getSession]("GI.Soup.Objects.Request#g:method:getSession"), [getUri]("GI.Soup.Objects.Request#g:method:getUri").
-- 
-- ==== Setters
-- [setData]("GI.GObject.Objects.Object#g:method:setData"), [setDataFull]("GI.GObject.Objects.Object#g:method:setDataFull"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty").

#if defined(ENABLE_OVERLOADING)
    ResolveRequestMethod                    ,
#endif

-- ** getContentLength #method:getContentLength#

#if defined(ENABLE_OVERLOADING)
    RequestGetContentLengthMethodInfo       ,
#endif
    requestGetContentLength                 ,


-- ** getContentType #method:getContentType#

#if defined(ENABLE_OVERLOADING)
    RequestGetContentTypeMethodInfo         ,
#endif
    requestGetContentType                   ,


-- ** getSession #method:getSession#

#if defined(ENABLE_OVERLOADING)
    RequestGetSessionMethodInfo             ,
#endif
    requestGetSession                       ,


-- ** getUri #method:getUri#

#if defined(ENABLE_OVERLOADING)
    RequestGetUriMethodInfo                 ,
#endif
    requestGetUri                           ,


-- ** send #method:send#

#if defined(ENABLE_OVERLOADING)
    RequestSendMethodInfo                   ,
#endif
    requestSend                             ,


-- ** sendAsync #method:sendAsync#

#if defined(ENABLE_OVERLOADING)
    RequestSendAsyncMethodInfo              ,
#endif
    requestSendAsync                        ,


-- ** sendFinish #method:sendFinish#

#if defined(ENABLE_OVERLOADING)
    RequestSendFinishMethodInfo             ,
#endif
    requestSendFinish                       ,




 -- * Properties


-- ** session #attr:session#
-- | The request\'s t'GI.Soup.Objects.Session.Session'.
-- 
-- /Since: 2.42/

#if defined(ENABLE_OVERLOADING)
    RequestSessionPropertyInfo              ,
#endif
    constructRequestSession                 ,
    getRequestSession                       ,
#if defined(ENABLE_OVERLOADING)
    requestSession                          ,
#endif


-- ** uri #attr:uri#
-- | The request URI.
-- 
-- /Since: 2.42/

#if defined(ENABLE_OVERLOADING)
    RequestUriPropertyInfo                  ,
#endif
    constructRequestUri                     ,
    getRequestUri                           ,
#if defined(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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
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.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
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 GHC.Records as R

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 (SP.ManagedPtr Request)
    deriving (Request -> Request -> Bool
(Request -> Request -> Bool)
-> (Request -> Request -> Bool) -> Eq Request
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Request -> Request -> Bool
$c/= :: Request -> Request -> Bool
== :: Request -> Request -> Bool
$c== :: Request -> Request -> Bool
Eq)

instance SP.ManagedPtrNewtype Request where
    toManagedPtr :: Request -> ManagedPtr Request
toManagedPtr (Request ManagedPtr Request
p) = ManagedPtr Request
p

foreign import ccall "soup_request_get_type"
    c_soup_request_get_type :: IO B.Types.GType

instance B.Types.TypedObject Request where
    glibType :: IO GType
glibType = IO GType
c_soup_request_get_type

instance B.Types.GObject Request

-- | Type class for types which can be safely cast to `Request`, for instance with `toRequest`.
class (SP.GObject o, O.IsDescendantOf Request o) => IsRequest o
instance (SP.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 :: (MIO.MonadIO m, IsRequest o) => o -> m Request
toRequest :: forall (m :: * -> *) o. (MonadIO m, IsRequest o) => o -> m Request
toRequest = IO Request -> m Request
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Request -> m Request) -> (o -> IO Request) -> o -> m Request
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Request -> Request) -> o -> IO Request
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr Request -> Request
Request

-- | Convert 'Request' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe Request) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_soup_request_get_type
    gvalueSet_ :: Ptr GValue -> Maybe Request -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Request
P.Nothing = Ptr GValue -> Ptr Request -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr Request
forall a. Ptr a
FP.nullPtr :: FP.Ptr Request)
    gvalueSet_ Ptr GValue
gv (P.Just Request
obj) = Request -> (Ptr Request -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Request
obj (Ptr GValue -> Ptr Request -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe Request)
gvalueGet_ Ptr GValue
gv = do
        Ptr Request
ptr <- Ptr GValue -> IO (Ptr Request)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr Request)
        if Ptr Request
ptr Ptr Request -> Ptr Request -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr Request
forall a. Ptr a
FP.nullPtr
        then Request -> Maybe Request
forall a. a -> Maybe a
P.Just (Request -> Maybe Request) -> IO Request -> IO (Maybe Request)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr Request -> Request) -> Ptr Request -> IO Request
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Request -> Request
Request Ptr Request
ptr
        else Maybe Request -> IO (Maybe Request)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Request
forall a. Maybe a
P.Nothing
        
    

#if defined(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 "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveRequestMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveRequestMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveRequestMethod t Request, O.OverloadedMethod info Request p) => OL.IsLabel t (Request -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveRequestMethod t Request, O.OverloadedMethod info Request p, R.HasField t Request p) => R.HasField t Request p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveRequestMethod t Request, O.OverloadedMethodInfo info Request) => OL.IsLabel t (O.MethodProxy info Request) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#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 :: forall (m :: * -> *) o. (MonadIO m, IsRequest o) => o -> m Session
getRequestSession o
obj = IO Session -> m Session
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Session -> m Session) -> IO Session -> m Session
forall a b. (a -> b) -> a -> b
$ Text -> IO (Maybe Session) -> IO Session
forall a. HasCallStack => Text -> IO (Maybe a) -> IO a
checkUnexpectedNothing Text
"getRequestSession" (IO (Maybe Session) -> IO Session)
-> IO (Maybe Session) -> IO Session
forall a b. (a -> b) -> a -> b
$ o
-> String -> (ManagedPtr Session -> Session) -> IO (Maybe Session)
forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
B.Properties.getObjectPropertyObject o
obj String
"session" ManagedPtr Session -> 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, MIO.MonadIO m, Soup.Session.IsSession a) => a -> m (GValueConstruct o)
constructRequestSession :: forall o (m :: * -> *) a.
(IsRequest o, MonadIO m, IsSession a) =>
a -> m (GValueConstruct o)
constructRequestSession a
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyObject String
"session" (a -> Maybe a
forall a. a -> Maybe a
P.Just a
val)

#if defined(ENABLE_OVERLOADING)
data RequestSessionPropertyInfo
instance AttrInfo RequestSessionPropertyInfo where
    type AttrAllowedOps RequestSessionPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint RequestSessionPropertyInfo = IsRequest
    type AttrSetTypeConstraint RequestSessionPropertyInfo = Soup.Session.IsSession
    type AttrTransferTypeConstraint RequestSessionPropertyInfo = Soup.Session.IsSession
    type AttrTransferType RequestSessionPropertyInfo = Soup.Session.Session
    type AttrGetType RequestSessionPropertyInfo = Soup.Session.Session
    type AttrLabel RequestSessionPropertyInfo = "session"
    type AttrOrigin RequestSessionPropertyInfo = Request
    attrGet = getRequestSession
    attrSet = undefined
    attrTransfer _ v = do
        unsafeCastTo Soup.Session.Session v
    attrConstruct = constructRequestSession
    attrClear = undefined
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Objects.Request.session"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-2.4.25/docs/GI-Soup-Objects-Request.html#g:attr:session"
        })
#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 :: forall (m :: * -> *) o. (MonadIO m, IsRequest o) => o -> m URI
getRequestUri o
obj = IO URI -> m URI
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO URI -> m URI) -> IO URI -> m URI
forall a b. (a -> b) -> a -> b
$ Text -> IO (Maybe URI) -> IO URI
forall a. HasCallStack => Text -> IO (Maybe a) -> IO a
checkUnexpectedNothing Text
"getRequestUri" (IO (Maybe URI) -> IO URI) -> IO (Maybe URI) -> IO URI
forall a b. (a -> b) -> a -> b
$ o -> String -> (ManagedPtr URI -> URI) -> IO (Maybe URI)
forall a b.
(GObject a, GBoxed b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
B.Properties.getObjectPropertyBoxed o
obj String
"uri" ManagedPtr URI -> 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, MIO.MonadIO m) => Soup.URI.URI -> m (GValueConstruct o)
constructRequestUri :: forall o (m :: * -> *).
(IsRequest o, MonadIO m) =>
URI -> m (GValueConstruct o)
constructRequestUri URI
val = IO (GValueConstruct o) -> m (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> m (GValueConstruct o))
-> IO (GValueConstruct o) -> m (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ do
    IO (GValueConstruct o) -> IO (GValueConstruct o)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO (GValueConstruct o) -> IO (GValueConstruct o))
-> IO (GValueConstruct o) -> IO (GValueConstruct o)
forall a b. (a -> b) -> a -> b
$ String -> Maybe URI -> IO (GValueConstruct o)
forall a o. GBoxed a => String -> Maybe a -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyBoxed String
"uri" (URI -> Maybe URI
forall a. a -> Maybe a
P.Just URI
val)

#if defined(ENABLE_OVERLOADING)
data RequestUriPropertyInfo
instance AttrInfo RequestUriPropertyInfo where
    type AttrAllowedOps RequestUriPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint RequestUriPropertyInfo = IsRequest
    type AttrSetTypeConstraint RequestUriPropertyInfo = (~) Soup.URI.URI
    type AttrTransferTypeConstraint RequestUriPropertyInfo = (~) Soup.URI.URI
    type AttrTransferType RequestUriPropertyInfo = Soup.URI.URI
    type AttrGetType RequestUriPropertyInfo = Soup.URI.URI
    type AttrLabel RequestUriPropertyInfo = "uri"
    type AttrOrigin RequestUriPropertyInfo = Request
    attrGet = getRequestUri
    attrSet = undefined
    attrTransfer _ v = do
        return v
    attrConstruct = constructRequestUri
    attrClear = undefined
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Objects.Request.uri"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-2.4.25/docs/GI-Soup-Objects-Request.html#g:attr:uri"
        })
#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Request
type instance O.AttributeList Request = RequestAttributeList
type RequestAttributeList = ('[ '("session", RequestSessionPropertyInfo), '("uri", RequestUriPropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
requestSession :: AttrLabelProxy "session"
requestSession = AttrLabelProxy

requestUri :: AttrLabelProxy "uri"
requestUri = AttrLabelProxy

#endif

#if defined(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 t'GI.Soup.Objects.Request.Request'
    -> m Int64
    -- ^ __Returns:__ the length of the data represented by /@request@/,
    --   or -1 if not known.
requestGetContentLength :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsRequest a) =>
a -> m Int64
requestGetContentLength a
request = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
    Ptr Request
request' <- a -> IO (Ptr Request)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
request
    Int64
result <- Ptr Request -> IO Int64
soup_request_get_content_length Ptr Request
request'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
request
    Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
result

#if defined(ENABLE_OVERLOADING)
data RequestGetContentLengthMethodInfo
instance (signature ~ (m Int64), MonadIO m, IsRequest a) => O.OverloadedMethod RequestGetContentLengthMethodInfo a signature where
    overloadedMethod = requestGetContentLength

instance O.OverloadedMethodInfo RequestGetContentLengthMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Objects.Request.requestGetContentLength",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-2.4.25/docs/GI-Soup-Objects-Request.html#v: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 t'GI.Soup.Objects.Request.Request'
    -> m (Maybe T.Text)
    -- ^ __Returns:__ the type of the data represented by
    --   /@request@/, or 'P.Nothing' if not known.
requestGetContentType :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsRequest a) =>
a -> m (Maybe Text)
requestGetContentType a
request = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Request
request' <- a -> IO (Ptr Request)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
request
    CString
result <- Ptr Request -> IO CString
soup_request_get_content_type Ptr Request
request'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
request
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult

#if defined(ENABLE_OVERLOADING)
data RequestGetContentTypeMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsRequest a) => O.OverloadedMethod RequestGetContentTypeMethodInfo a signature where
    overloadedMethod = requestGetContentType

instance O.OverloadedMethodInfo RequestGetContentTypeMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Objects.Request.requestGetContentType",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-2.4.25/docs/GI-Soup-Objects-Request.html#v: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 t'GI.Soup.Objects.Session.Session'
-- 
-- /Since: 2.42/
requestGetSession ::
    (B.CallStack.HasCallStack, MonadIO m, IsRequest a) =>
    a
    -- ^ /@request@/: a t'GI.Soup.Objects.Request.Request'
    -> m Soup.Session.Session
    -- ^ __Returns:__ /@request@/\'s t'GI.Soup.Objects.Session.Session'
requestGetSession :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsRequest a) =>
a -> m Session
requestGetSession a
request = IO Session -> m Session
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Session -> m Session) -> IO Session -> m Session
forall a b. (a -> b) -> a -> b
$ do
    Ptr Request
request' <- a -> IO (Ptr Request)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
request
    Ptr Session
result <- Ptr Request -> IO (Ptr Session)
soup_request_get_session Ptr Request
request'
    Text -> Ptr Session -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"requestGetSession" Ptr Session
result
    Session
result' <- ((ManagedPtr Session -> Session) -> Ptr Session -> IO Session
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Session -> Session
Soup.Session.Session) Ptr Session
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
request
    Session -> IO Session
forall (m :: * -> *) a. Monad m => a -> m a
return Session
result'

#if defined(ENABLE_OVERLOADING)
data RequestGetSessionMethodInfo
instance (signature ~ (m Soup.Session.Session), MonadIO m, IsRequest a) => O.OverloadedMethod RequestGetSessionMethodInfo a signature where
    overloadedMethod = requestGetSession

instance O.OverloadedMethodInfo RequestGetSessionMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Objects.Request.requestGetSession",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-2.4.25/docs/GI-Soup-Objects-Request.html#v: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 t'GI.Soup.Objects.Request.Request'
    -> m Soup.URI.URI
    -- ^ __Returns:__ /@request@/\'s URI
requestGetUri :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsRequest a) =>
a -> m URI
requestGetUri a
request = IO URI -> m URI
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO URI -> m URI) -> IO URI -> m URI
forall a b. (a -> b) -> a -> b
$ do
    Ptr Request
request' <- a -> IO (Ptr Request)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
request
    Ptr URI
result <- Ptr Request -> IO (Ptr URI)
soup_request_get_uri Ptr Request
request'
    Text -> Ptr URI -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"requestGetUri" Ptr URI
result
    URI
result' <- ((ManagedPtr URI -> URI) -> Ptr URI -> IO URI
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr URI -> URI
Soup.URI.URI) Ptr URI
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
request
    URI -> IO URI
forall (m :: * -> *) a. Monad m => a -> m a
return URI
result'

#if defined(ENABLE_OVERLOADING)
data RequestGetUriMethodInfo
instance (signature ~ (m Soup.URI.URI), MonadIO m, IsRequest a) => O.OverloadedMethod RequestGetUriMethodInfo a signature where
    overloadedMethod = requestGetUri

instance O.OverloadedMethodInfo RequestGetUriMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Objects.Request.requestGetUri",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-2.4.25/docs/GI-Soup-Objects-Request.html#v: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 t'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 t'GI.Soup.Objects.SessionAsync.SessionAsync'.
-- 
-- /Since: 2.42/
requestSend ::
    (B.CallStack.HasCallStack, MonadIO m, IsRequest a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@request@/: a t'GI.Soup.Objects.Request.Request'
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable' or 'P.Nothing'
    -> m Gio.InputStream.InputStream
    -- ^ __Returns:__ a t'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 :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsRequest a, IsCancellable b) =>
a -> Maybe b -> m InputStream
requestSend a
request Maybe b
cancellable = IO InputStream -> m InputStream
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO InputStream -> m InputStream)
-> IO InputStream -> m InputStream
forall a b. (a -> b) -> a -> b
$ do
    Ptr Request
request' <- a -> IO (Ptr Request)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
request
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Maybe b
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO InputStream -> IO () -> IO InputStream
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr InputStream
result <- (Ptr (Ptr GError) -> IO (Ptr InputStream)) -> IO (Ptr InputStream)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr InputStream))
 -> IO (Ptr InputStream))
-> (Ptr (Ptr GError) -> IO (Ptr InputStream))
-> IO (Ptr InputStream)
forall a b. (a -> b) -> a -> b
$ Ptr Request
-> Ptr Cancellable -> Ptr (Ptr GError) -> IO (Ptr InputStream)
soup_request_send Ptr Request
request' Ptr Cancellable
maybeCancellable
        Text -> Ptr InputStream -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"requestSend" Ptr InputStream
result
        InputStream
result' <- ((ManagedPtr InputStream -> InputStream)
-> Ptr InputStream -> IO InputStream
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr InputStream -> InputStream
Gio.InputStream.InputStream) Ptr InputStream
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
request
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        InputStream -> IO InputStream
forall (m :: * -> *) a. Monad m => a -> m a
return InputStream
result'
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data RequestSendMethodInfo
instance (signature ~ (Maybe (b) -> m Gio.InputStream.InputStream), MonadIO m, IsRequest a, Gio.Cancellable.IsCancellable b) => O.OverloadedMethod RequestSendMethodInfo a signature where
    overloadedMethod = requestSend

instance O.OverloadedMethodInfo RequestSendMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Objects.Request.requestSend",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-2.4.25/docs/GI-Soup-Objects-Request.html#v: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 t'GI.Soup.Objects.SessionSync.SessionSync'.
-- 
-- /Since: 2.42/
requestSendAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsRequest a, Gio.Cancellable.IsCancellable b) =>
    a
    -- ^ /@request@/: a t'GI.Soup.Objects.Request.Request'
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable' or 'P.Nothing'
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: a t'GI.Gio.Callbacks.AsyncReadyCallback'
    -> m ()
requestSendAsync :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsRequest a, IsCancellable b) =>
a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
requestSendAsync a
request Maybe b
cancellable Maybe AsyncReadyCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Request
request' <- a -> IO (Ptr Request)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
request
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Maybe b
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Maybe AsyncReadyCallback
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Request
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
soup_request_send_async Ptr Request
request' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
request
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data RequestSendAsyncMethodInfo
instance (signature ~ (Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsRequest a, Gio.Cancellable.IsCancellable b) => O.OverloadedMethod RequestSendAsyncMethodInfo a signature where
    overloadedMethod = requestSendAsync

instance O.OverloadedMethodInfo RequestSendAsyncMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Objects.Request.requestSendAsync",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-2.4.25/docs/GI-Soup-Objects-Request.html#v: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 t'GI.Soup.Objects.Request.Request'
    -> b
    -- ^ /@result@/: the t'GI.Gio.Interfaces.AsyncResult.AsyncResult'
    -> m Gio.InputStream.InputStream
    -- ^ __Returns:__ a t'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 :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsRequest a, IsAsyncResult b) =>
a -> b -> m InputStream
requestSendFinish a
request b
result_ = IO InputStream -> m InputStream
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO InputStream -> m InputStream)
-> IO InputStream -> m InputStream
forall a b. (a -> b) -> a -> b
$ do
    Ptr Request
request' <- a -> IO (Ptr Request)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
request
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO InputStream -> IO () -> IO InputStream
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr InputStream
result <- (Ptr (Ptr GError) -> IO (Ptr InputStream)) -> IO (Ptr InputStream)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr InputStream))
 -> IO (Ptr InputStream))
-> (Ptr (Ptr GError) -> IO (Ptr InputStream))
-> IO (Ptr InputStream)
forall a b. (a -> b) -> a -> b
$ Ptr Request
-> Ptr AsyncResult -> Ptr (Ptr GError) -> IO (Ptr InputStream)
soup_request_send_finish Ptr Request
request' Ptr AsyncResult
result_'
        Text -> Ptr InputStream -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"requestSendFinish" Ptr InputStream
result
        InputStream
result' <- ((ManagedPtr InputStream -> InputStream)
-> Ptr InputStream -> IO InputStream
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr InputStream -> InputStream
Gio.InputStream.InputStream) Ptr InputStream
result
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
request
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        InputStream -> IO InputStream
forall (m :: * -> *) a. Monad m => a -> m a
return InputStream
result'
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data RequestSendFinishMethodInfo
instance (signature ~ (b -> m Gio.InputStream.InputStream), MonadIO m, IsRequest a, Gio.AsyncResult.IsAsyncResult b) => O.OverloadedMethod RequestSendFinishMethodInfo a signature where
    overloadedMethod = requestSendFinish

instance O.OverloadedMethodInfo RequestSendFinishMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Objects.Request.requestSendFinish",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-2.4.25/docs/GI-Soup-Objects-Request.html#v:requestSendFinish"
        })


#endif