{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) The HTTP message headers associated with a request or response. -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.Soup.Structs.MessageHeaders ( -- * Exported types MessageHeaders(..) , noMessageHeaders , -- * Methods -- ** append #method:append# #if ENABLE_OVERLOADING MessageHeadersAppendMethodInfo , #endif messageHeadersAppend , -- ** cleanConnectionHeaders #method:cleanConnectionHeaders# #if ENABLE_OVERLOADING MessageHeadersCleanConnectionHeadersMethodInfo, #endif messageHeadersCleanConnectionHeaders , -- ** clear #method:clear# #if ENABLE_OVERLOADING MessageHeadersClearMethodInfo , #endif messageHeadersClear , -- ** foreach #method:foreach# #if ENABLE_OVERLOADING MessageHeadersForeachMethodInfo , #endif messageHeadersForeach , -- ** free #method:free# #if ENABLE_OVERLOADING MessageHeadersFreeMethodInfo , #endif messageHeadersFree , -- ** freeRanges #method:freeRanges# #if ENABLE_OVERLOADING MessageHeadersFreeRangesMethodInfo , #endif messageHeadersFreeRanges , -- ** get #method:get# #if ENABLE_OVERLOADING MessageHeadersGetMethodInfo , #endif messageHeadersGet , -- ** getContentDisposition #method:getContentDisposition# #if ENABLE_OVERLOADING MessageHeadersGetContentDispositionMethodInfo, #endif messageHeadersGetContentDisposition , -- ** getContentLength #method:getContentLength# #if ENABLE_OVERLOADING MessageHeadersGetContentLengthMethodInfo, #endif messageHeadersGetContentLength , -- ** getContentRange #method:getContentRange# #if ENABLE_OVERLOADING MessageHeadersGetContentRangeMethodInfo , #endif messageHeadersGetContentRange , -- ** getContentType #method:getContentType# #if ENABLE_OVERLOADING MessageHeadersGetContentTypeMethodInfo , #endif messageHeadersGetContentType , -- ** getEncoding #method:getEncoding# #if ENABLE_OVERLOADING MessageHeadersGetEncodingMethodInfo , #endif messageHeadersGetEncoding , -- ** getExpectations #method:getExpectations# #if ENABLE_OVERLOADING MessageHeadersGetExpectationsMethodInfo , #endif messageHeadersGetExpectations , -- ** getHeadersType #method:getHeadersType# #if ENABLE_OVERLOADING MessageHeadersGetHeadersTypeMethodInfo , #endif messageHeadersGetHeadersType , -- ** getList #method:getList# #if ENABLE_OVERLOADING MessageHeadersGetListMethodInfo , #endif messageHeadersGetList , -- ** getOne #method:getOne# #if ENABLE_OVERLOADING MessageHeadersGetOneMethodInfo , #endif messageHeadersGetOne , -- ** getRanges #method:getRanges# #if ENABLE_OVERLOADING MessageHeadersGetRangesMethodInfo , #endif messageHeadersGetRanges , -- ** headerContains #method:headerContains# #if ENABLE_OVERLOADING MessageHeadersHeaderContainsMethodInfo , #endif messageHeadersHeaderContains , -- ** headerEquals #method:headerEquals# #if ENABLE_OVERLOADING MessageHeadersHeaderEqualsMethodInfo , #endif messageHeadersHeaderEquals , -- ** new #method:new# messageHeadersNew , -- ** remove #method:remove# #if ENABLE_OVERLOADING MessageHeadersRemoveMethodInfo , #endif messageHeadersRemove , -- ** replace #method:replace# #if ENABLE_OVERLOADING MessageHeadersReplaceMethodInfo , #endif messageHeadersReplace , -- ** setContentDisposition #method:setContentDisposition# #if ENABLE_OVERLOADING MessageHeadersSetContentDispositionMethodInfo, #endif messageHeadersSetContentDisposition , -- ** setContentLength #method:setContentLength# #if ENABLE_OVERLOADING MessageHeadersSetContentLengthMethodInfo, #endif messageHeadersSetContentLength , -- ** setContentRange #method:setContentRange# #if ENABLE_OVERLOADING MessageHeadersSetContentRangeMethodInfo , #endif messageHeadersSetContentRange , -- ** setContentType #method:setContentType# #if ENABLE_OVERLOADING MessageHeadersSetContentTypeMethodInfo , #endif messageHeadersSetContentType , -- ** setEncoding #method:setEncoding# #if ENABLE_OVERLOADING MessageHeadersSetEncodingMethodInfo , #endif messageHeadersSetEncoding , -- ** setExpectations #method:setExpectations# #if ENABLE_OVERLOADING MessageHeadersSetExpectationsMethodInfo , #endif messageHeadersSetExpectations , -- ** setRange #method:setRange# #if ENABLE_OVERLOADING MessageHeadersSetRangeMethodInfo , #endif messageHeadersSetRange , -- ** setRanges #method:setRanges# #if ENABLE_OVERLOADING MessageHeadersSetRangesMethodInfo , #endif messageHeadersSetRanges , ) 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.Soup.Callbacks as Soup.Callbacks import {-# SOURCE #-} qualified GI.Soup.Enums as Soup.Enums import {-# SOURCE #-} qualified GI.Soup.Flags as Soup.Flags import {-# SOURCE #-} qualified GI.Soup.Structs.Range as Soup.Range -- | Memory-managed wrapper type. newtype MessageHeaders = MessageHeaders (ManagedPtr MessageHeaders) foreign import ccall "soup_message_headers_get_type" c_soup_message_headers_get_type :: IO GType instance BoxedObject MessageHeaders where boxedType _ = c_soup_message_headers_get_type -- | A convenience alias for `Nothing` :: `Maybe` `MessageHeaders`. noMessageHeaders :: Maybe MessageHeaders noMessageHeaders = Nothing #if ENABLE_OVERLOADING instance O.HasAttributeList MessageHeaders type instance O.AttributeList MessageHeaders = MessageHeadersAttributeList type MessageHeadersAttributeList = ('[ ] :: [(Symbol, *)]) #endif -- method MessageHeaders::new -- method type : Constructor -- Args : [Arg {argCName = "type", argType = TInterface (Name {namespace = "Soup", name = "MessageHeadersType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the type of headers", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Soup", name = "MessageHeaders"})) -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_new" soup_message_headers_new :: CUInt -> -- type : TInterface (Name {namespace = "Soup", name = "MessageHeadersType"}) IO (Ptr MessageHeaders) {- | Creates a 'GI.Soup.Structs.MessageHeaders.MessageHeaders'. ('GI.Soup.Objects.Message.Message' does this automatically for its own headers. You would only need to use this method if you are manually parsing or generating message headers.) -} messageHeadersNew :: (B.CallStack.HasCallStack, MonadIO m) => Soup.Enums.MessageHeadersType {- ^ /@type@/: the type of headers -} -> m MessageHeaders {- ^ __Returns:__ a new 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} messageHeadersNew type_ = liftIO $ do let type_' = (fromIntegral . fromEnum) type_ result <- soup_message_headers_new type_' checkUnexpectedReturnNULL "messageHeadersNew" result result' <- (wrapBoxed MessageHeaders) result return result' #if ENABLE_OVERLOADING #endif -- method MessageHeaders::append -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the header name to add", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new value of @name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_append" soup_message_headers_append :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) CString -> -- name : TBasicType TUTF8 CString -> -- value : TBasicType TUTF8 IO () {- | Appends a new header with name /@name@/ and value /@value@/ to /@hdrs@/. (If there is an existing header with name /@name@/, then this creates a second one, which is only allowed for list-valued headers; see also 'GI.Soup.Structs.MessageHeaders.messageHeadersReplace'.) The caller is expected to make sure that /@name@/ and /@value@/ are syntactically correct. -} messageHeadersAppend :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> T.Text {- ^ /@name@/: the header name to add -} -> T.Text {- ^ /@value@/: the new value of /@name@/ -} -> m () messageHeadersAppend hdrs name value = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs name' <- textToCString name value' <- textToCString value soup_message_headers_append hdrs' name' value' touchManagedPtr hdrs freeMem name' freeMem value' return () #if ENABLE_OVERLOADING data MessageHeadersAppendMethodInfo instance (signature ~ (T.Text -> T.Text -> m ()), MonadIO m) => O.MethodInfo MessageHeadersAppendMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersAppend #endif -- method MessageHeaders::clean_connection_headers -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_clean_connection_headers" soup_message_headers_clean_connection_headers :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) IO () {- | Removes all the headers listed in the Connection header. /Since: 2.36/ -} messageHeadersCleanConnectionHeaders :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> m () messageHeadersCleanConnectionHeaders hdrs = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs soup_message_headers_clean_connection_headers hdrs' touchManagedPtr hdrs return () #if ENABLE_OVERLOADING data MessageHeadersCleanConnectionHeadersMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo MessageHeadersCleanConnectionHeadersMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersCleanConnectionHeaders #endif -- method MessageHeaders::clear -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_clear" soup_message_headers_clear :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) IO () {- | Clears /@hdrs@/. -} messageHeadersClear :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> m () messageHeadersClear hdrs = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs soup_message_headers_clear hdrs' touchManagedPtr hdrs return () #if ENABLE_OVERLOADING data MessageHeadersClearMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo MessageHeadersClearMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersClear #endif -- method MessageHeaders::foreach -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "func", argType = TInterface (Name {namespace = "Soup", name = "MessageHeadersForeachFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "callback function to run for each header", sinceVersion = Nothing}, argScope = ScopeTypeCall, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to pass to @func", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_foreach" soup_message_headers_foreach :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) FunPtr Soup.Callbacks.C_MessageHeadersForeachFunc -> -- func : TInterface (Name {namespace = "Soup", name = "MessageHeadersForeachFunc"}) Ptr () -> -- user_data : TBasicType TPtr IO () {- | Calls /@func@/ once for each header value in /@hdrs@/. Beware that unlike 'GI.Soup.Structs.MessageHeaders.messageHeadersGet', this processes the headers in exactly the way they were added, rather than concatenating multiple same-named headers into a single value. (This is intentional; it ensures that if you call 'GI.Soup.Structs.MessageHeaders.messageHeadersAppend' multiple times with the same name, then the I\/O code will output multiple copies of the header when sending the message to the remote implementation, which may be required for interoperability in some cases.) You may not modify the headers from /@func@/. -} messageHeadersForeach :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> Soup.Callbacks.MessageHeadersForeachFunc {- ^ /@func@/: callback function to run for each header -} -> m () messageHeadersForeach hdrs func = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs func' <- Soup.Callbacks.mk_MessageHeadersForeachFunc (Soup.Callbacks.wrap_MessageHeadersForeachFunc Nothing (Soup.Callbacks.drop_closures_MessageHeadersForeachFunc func)) let userData = nullPtr soup_message_headers_foreach hdrs' func' userData safeFreeFunPtr $ castFunPtrToPtr func' touchManagedPtr hdrs return () #if ENABLE_OVERLOADING data MessageHeadersForeachMethodInfo instance (signature ~ (Soup.Callbacks.MessageHeadersForeachFunc -> m ()), MonadIO m) => O.MethodInfo MessageHeadersForeachMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersForeach #endif -- method MessageHeaders::free -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_free" soup_message_headers_free :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) IO () {- | Frees /@hdrs@/. -} messageHeadersFree :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> m () messageHeadersFree hdrs = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs soup_message_headers_free hdrs' touchManagedPtr hdrs return () #if ENABLE_OVERLOADING data MessageHeadersFreeMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo MessageHeadersFreeMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersFree #endif -- method MessageHeaders::free_ranges -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ranges", argType = TInterface (Name {namespace = "Soup", name = "Range"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an array of #SoupRange", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_free_ranges" soup_message_headers_free_ranges :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) Ptr Soup.Range.Range -> -- ranges : TInterface (Name {namespace = "Soup", name = "Range"}) IO () {- | Frees the array of ranges returned from 'GI.Soup.Structs.MessageHeaders.messageHeadersGetRanges'. /Since: 2.26/ -} messageHeadersFreeRanges :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> Soup.Range.Range {- ^ /@ranges@/: an array of 'GI.Soup.Structs.Range.Range' -} -> m () messageHeadersFreeRanges hdrs ranges = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs ranges' <- unsafeManagedPtrGetPtr ranges soup_message_headers_free_ranges hdrs' ranges' touchManagedPtr hdrs touchManagedPtr ranges return () #if ENABLE_OVERLOADING data MessageHeadersFreeRangesMethodInfo instance (signature ~ (Soup.Range.Range -> m ()), MonadIO m) => O.MethodInfo MessageHeadersFreeRangesMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersFreeRanges #endif -- method MessageHeaders::get -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "header name", 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_message_headers_get" soup_message_headers_get :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) CString -> -- name : TBasicType TUTF8 IO CString {-# DEPRECATED messageHeadersGet ["Use 'GI.Soup.Structs.MessageHeaders.messageHeadersGetOne' or","'GI.Soup.Structs.MessageHeaders.messageHeadersGetList' instead."] #-} {- | Gets the value of header /@name@/ in /@hdrs@/. This method was supposed to work correctly for both single-valued and list-valued headers, but because some HTTP clients\/servers mistakenly send multiple copies of headers that are supposed to be single-valued, it sometimes returns incorrect results. To fix this, the methods 'GI.Soup.Structs.MessageHeaders.messageHeadersGetOne' and 'GI.Soup.Structs.MessageHeaders.messageHeadersGetList' were introduced, so callers can explicitly state which behavior they are expecting. -} messageHeadersGet :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> T.Text {- ^ /@name@/: header name -} -> m (Maybe T.Text) {- ^ __Returns:__ as with 'GI.Soup.Structs.MessageHeaders.messageHeadersGetList'. -} messageHeadersGet hdrs name = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs name' <- textToCString name result <- soup_message_headers_get hdrs' name' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- cstringToText result' return result'' touchManagedPtr hdrs freeMem name' return maybeResult #if ENABLE_OVERLOADING data MessageHeadersGetMethodInfo instance (signature ~ (T.Text -> m (Maybe T.Text)), MonadIO m) => O.MethodInfo MessageHeadersGetMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersGet #endif -- method MessageHeaders::get_content_disposition -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "disposition", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the\ndisposition-type, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "params", argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return\nlocation for the Content-Disposition parameters, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_get_content_disposition" soup_message_headers_get_content_disposition :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) Ptr CString -> -- disposition : TBasicType TUTF8 Ptr (Ptr (GHashTable CString CString)) -> -- params : TGHash (TBasicType TUTF8) (TBasicType TUTF8) IO CInt {- | Looks up the \"Content-Disposition\" header in /@hdrs@/, parses it, and returns its value in */@disposition@/ and */@params@/. /@params@/ can be 'Nothing' if you are only interested in the disposition-type. In HTTP, the most common use of this header is to set a disposition-type of \"attachment\", to suggest to the browser that a response should be saved to disk rather than displayed in the browser. If /@params@/ contains a \"filename\" parameter, this is a suggestion of a filename to use. (If the parameter value in the header contains an absolute or relative path, libsoup will truncate it down to just the final path component, so you do not need to test this yourself.) Content-Disposition is also used in \"multipart\/form-data\", however this is handled automatically by 'GI.Soup.Structs.Multipart.Multipart' and the associated form methods. /Since: 2.26/ -} messageHeadersGetContentDisposition :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> m ((Bool, T.Text, Map.Map T.Text T.Text)) {- ^ __Returns:__ 'True' if /@hdrs@/ contains a \"Content-Disposition\" header, 'False' if not (in which case */@disposition@/ and */@params@/ will be unchanged). -} messageHeadersGetContentDisposition hdrs = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs disposition <- allocMem :: IO (Ptr CString) params <- allocMem :: IO (Ptr (Ptr (GHashTable CString CString))) result <- soup_message_headers_get_content_disposition hdrs' disposition params let result' = (/= 0) result disposition' <- peek disposition disposition'' <- cstringToText disposition' freeMem disposition' params' <- peek params params'' <- unpackGHashTable params' let params''' = mapFirst cstringUnpackPtr params'' params'''' <- mapFirstA cstringToText params''' let params''''' = mapSecond cstringUnpackPtr params'''' params'''''' <- mapSecondA cstringToText params''''' let params''''''' = Map.fromList params'''''' unrefGHashTable params' touchManagedPtr hdrs freeMem disposition freeMem params return (result', disposition'', params''''''') #if ENABLE_OVERLOADING data MessageHeadersGetContentDispositionMethodInfo instance (signature ~ (m ((Bool, T.Text, Map.Map T.Text T.Text))), MonadIO m) => O.MethodInfo MessageHeadersGetContentDispositionMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersGetContentDisposition #endif -- method MessageHeaders::get_content_length -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", 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_message_headers_get_content_length" soup_message_headers_get_content_length :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) IO Int64 {- | Gets the message body length that /@hdrs@/ declare. This will only be non-0 if 'GI.Soup.Structs.MessageHeaders.messageHeadersGetEncoding' returns 'GI.Soup.Enums.EncodingContentLength'. -} messageHeadersGetContentLength :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> m Int64 {- ^ __Returns:__ the message body length declared by /@hdrs@/. -} messageHeadersGetContentLength hdrs = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs result <- soup_message_headers_get_content_length hdrs' touchManagedPtr hdrs return result #if ENABLE_OVERLOADING data MessageHeadersGetContentLengthMethodInfo instance (signature ~ (m Int64), MonadIO m) => O.MethodInfo MessageHeadersGetContentLengthMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersGetContentLength #endif -- method MessageHeaders::get_content_range -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start", argType = TBasicType TInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return value for the start of the range", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "end", argType = TBasicType TInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return value for the end of the range", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "total_length", argType = TBasicType TInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return value for the total length of the\nresource, or %NULL if you don't care.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_get_content_range" soup_message_headers_get_content_range :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) Ptr Int64 -> -- start : TBasicType TInt64 Ptr Int64 -> -- end : TBasicType TInt64 Ptr Int64 -> -- total_length : TBasicType TInt64 IO CInt {- | Parses /@hdrs@/\'s Content-Range header and returns it in /@start@/, /@end@/, and /@totalLength@/. If the total length field in the header was specified as \"*\", then /@totalLength@/ will be set to -1. /Since: 2.26/ -} messageHeadersGetContentRange :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> m ((Bool, Int64, Int64, Int64)) {- ^ __Returns:__ 'True' if /@hdrs@/ contained a \"Content-Range\" header containing a byte range which could be parsed, 'False' otherwise. -} messageHeadersGetContentRange hdrs = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs start <- allocMem :: IO (Ptr Int64) end <- allocMem :: IO (Ptr Int64) totalLength <- allocMem :: IO (Ptr Int64) result <- soup_message_headers_get_content_range hdrs' start end totalLength let result' = (/= 0) result start' <- peek start end' <- peek end totalLength' <- peek totalLength touchManagedPtr hdrs freeMem start freeMem end freeMem totalLength return (result', start', end', totalLength') #if ENABLE_OVERLOADING data MessageHeadersGetContentRangeMethodInfo instance (signature ~ (m ((Bool, Int64, Int64, Int64))), MonadIO m) => O.MethodInfo MessageHeadersGetContentRangeMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersGetContentRange #endif -- method MessageHeaders::get_content_type -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "params", argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "\n return location for the Content-Type parameters (eg, \"charset\"), or\n %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_get_content_type" soup_message_headers_get_content_type :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) Ptr (Ptr (GHashTable CString CString)) -> -- params : TGHash (TBasicType TUTF8) (TBasicType TUTF8) IO CString {- | Looks up the \"Content-Type\" header in /@hdrs@/, parses it, and returns its value in */@contentType@/ and */@params@/. /@params@/ can be 'Nothing' if you are only interested in the content type itself. /Since: 2.26/ -} messageHeadersGetContentType :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> m ((Maybe T.Text, Map.Map T.Text T.Text)) {- ^ __Returns:__ a string with the value of the \"Content-Type\" header or 'Nothing' if /@hdrs@/ does not contain that header or it cannot be parsed (in which case */@params@/ will be unchanged). -} messageHeadersGetContentType hdrs = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs params <- allocMem :: IO (Ptr (Ptr (GHashTable CString CString))) result <- soup_message_headers_get_content_type hdrs' params maybeResult <- convertIfNonNull result $ \result' -> do result'' <- cstringToText result' return result'' params' <- peek params params'' <- unpackGHashTable params' let params''' = mapFirst cstringUnpackPtr params'' params'''' <- mapFirstA cstringToText params''' let params''''' = mapSecond cstringUnpackPtr params'''' params'''''' <- mapSecondA cstringToText params''''' let params''''''' = Map.fromList params'''''' unrefGHashTable params' touchManagedPtr hdrs freeMem params return (maybeResult, params''''''') #if ENABLE_OVERLOADING data MessageHeadersGetContentTypeMethodInfo instance (signature ~ (m ((Maybe T.Text, Map.Map T.Text T.Text))), MonadIO m) => O.MethodInfo MessageHeadersGetContentTypeMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersGetContentType #endif -- method MessageHeaders::get_encoding -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Soup", name = "Encoding"})) -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_get_encoding" soup_message_headers_get_encoding :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) IO CUInt {- | Gets the message body encoding that /@hdrs@/ declare. This may not always correspond to the encoding used on the wire; eg, a HEAD response may declare a Content-Length or Transfer-Encoding, but it will never actually include a body. -} messageHeadersGetEncoding :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> m Soup.Enums.Encoding {- ^ __Returns:__ the encoding declared by /@hdrs@/. -} messageHeadersGetEncoding hdrs = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs result <- soup_message_headers_get_encoding hdrs' let result' = (toEnum . fromIntegral) result touchManagedPtr hdrs return result' #if ENABLE_OVERLOADING data MessageHeadersGetEncodingMethodInfo instance (signature ~ (m Soup.Enums.Encoding), MonadIO m) => O.MethodInfo MessageHeadersGetEncodingMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersGetEncoding #endif -- method MessageHeaders::get_expectations -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Soup", name = "Expectation"})) -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_get_expectations" soup_message_headers_get_expectations :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) IO CUInt {- | Gets the expectations declared by /@hdrs@/\'s \"Expect\" header. Currently this will either be 'GI.Soup.Flags.ExpectationContinue' or 'GI.Soup.Flags.ExpectationUnrecognized'. -} messageHeadersGetExpectations :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> m [Soup.Flags.Expectation] {- ^ __Returns:__ the contents of /@hdrs@/\'s \"Expect\" header -} messageHeadersGetExpectations hdrs = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs result <- soup_message_headers_get_expectations hdrs' let result' = wordToGFlags result touchManagedPtr hdrs return result' #if ENABLE_OVERLOADING data MessageHeadersGetExpectationsMethodInfo instance (signature ~ (m [Soup.Flags.Expectation]), MonadIO m) => O.MethodInfo MessageHeadersGetExpectationsMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersGetExpectations #endif -- method MessageHeaders::get_headers_type -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Soup", name = "MessageHeadersType"})) -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_get_headers_type" soup_message_headers_get_headers_type :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) IO CUInt {- | Gets the type of headers. /Since: 2.50/ -} messageHeadersGetHeadersType :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> m Soup.Enums.MessageHeadersType {- ^ __Returns:__ the header\'s type. -} messageHeadersGetHeadersType hdrs = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs result <- soup_message_headers_get_headers_type hdrs' let result' = (toEnum . fromIntegral) result touchManagedPtr hdrs return result' #if ENABLE_OVERLOADING data MessageHeadersGetHeadersTypeMethodInfo instance (signature ~ (m Soup.Enums.MessageHeadersType), MonadIO m) => O.MethodInfo MessageHeadersGetHeadersTypeMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersGetHeadersType #endif -- method MessageHeaders::get_list -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "header name", 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_message_headers_get_list" soup_message_headers_get_list :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) CString -> -- name : TBasicType TUTF8 IO CString {- | Gets the value of header /@name@/ in /@hdrs@/. Use this for headers whose values are comma-delimited lists, and which are therefore allowed to appear multiple times in the headers. For non-list-valued headers, use 'GI.Soup.Structs.MessageHeaders.messageHeadersGetOne'. If /@name@/ appears multiple times in /@hdrs@/, 'GI.Soup.Structs.MessageHeaders.messageHeadersGetList' will concatenate all of the values together, separated by commas. This is sometimes awkward to parse (eg, WWW-Authenticate, Set-Cookie), but you have to be able to deal with it anyway, because the HTTP spec explicitly states that this transformation is allowed, and so an upstream proxy could do the same thing. /Since: 2.28/ -} messageHeadersGetList :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> T.Text {- ^ /@name@/: header name -} -> m (Maybe T.Text) {- ^ __Returns:__ the header\'s value or 'Nothing' if not found. -} messageHeadersGetList hdrs name = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs name' <- textToCString name result <- soup_message_headers_get_list hdrs' name' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- cstringToText result' return result'' touchManagedPtr hdrs freeMem name' return maybeResult #if ENABLE_OVERLOADING data MessageHeadersGetListMethodInfo instance (signature ~ (T.Text -> m (Maybe T.Text)), MonadIO m) => O.MethodInfo MessageHeadersGetListMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersGetList #endif -- method MessageHeaders::get_one -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "header name", 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_message_headers_get_one" soup_message_headers_get_one :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) CString -> -- name : TBasicType TUTF8 IO CString {- | Gets the value of header /@name@/ in /@hdrs@/. Use this for headers whose values are \not\<\/emphasis> comma-delimited lists, and which therefore can only appear at most once in the headers. For list-valued headers, use 'GI.Soup.Structs.MessageHeaders.messageHeadersGetList'. If /@hdrs@/ does erroneously contain multiple copies of the header, it is not defined which one will be returned. (Ideally, it will return whichever one makes libsoup most compatible with other HTTP implementations.) /Since: 2.28/ -} messageHeadersGetOne :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> T.Text {- ^ /@name@/: header name -} -> m (Maybe T.Text) {- ^ __Returns:__ the header\'s value or 'Nothing' if not found. -} messageHeadersGetOne hdrs name = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs name' <- textToCString name result <- soup_message_headers_get_one hdrs' name' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- cstringToText result' return result'' touchManagedPtr hdrs freeMem name' return maybeResult #if ENABLE_OVERLOADING data MessageHeadersGetOneMethodInfo instance (signature ~ (T.Text -> m (Maybe T.Text)), MonadIO m) => O.MethodInfo MessageHeadersGetOneMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersGetOne #endif -- method MessageHeaders::get_ranges -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "total_length", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the total_length of the response body", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ranges", argType = TCArray False (-1) 3 (TInterface (Name {namespace = "Soup", name = "Range"})), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for an array\nof #SoupRange", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "length", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the returned array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- Lengths : [Arg {argCName = "length", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the returned array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_get_ranges" soup_message_headers_get_ranges :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) Int64 -> -- total_length : TBasicType TInt64 Ptr (Ptr Soup.Range.Range) -> -- ranges : TCArray False (-1) 3 (TInterface (Name {namespace = "Soup", name = "Range"})) Ptr Int32 -> -- length : TBasicType TInt IO CInt {- | Parses /@hdrs@/\'s Range header and returns an array of the requested byte ranges. The returned array must be freed with 'GI.Soup.Structs.MessageHeaders.messageHeadersFreeRanges'. If /@totalLength@/ is non-0, its value will be used to adjust the returned ranges to have explicit start and end values, and the returned ranges will be sorted and non-overlapping. If /@totalLength@/ is 0, then some ranges may have an end value of -1, as described under 'GI.Soup.Structs.Range.Range', and some of the ranges may be redundant. Beware that even if given a /@totalLength@/, this function does not check that the ranges are satisfiable. \\ 'GI.Soup.Objects.Server.Server' has built-in handling for range requests. If your server handler returns a 'GI.Soup.Enums.StatusOk' response containing the complete response body (rather than pausing the message and returning some of the response body later), and there is a Range header in the request, then libsoup will automatically convert the response to a 'GI.Soup.Enums.StatusPartialContent' response containing only the range(s) requested by the client. The only time you need to process the Range header yourself is if either you need to stream the response body rather than returning it all at once, or you do not already have the complete response body available, and only want to generate the parts that were actually requested by the client. \<\/para>\<\/note> /Since: 2.26/ -} messageHeadersGetRanges :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> Int64 {- ^ /@totalLength@/: the total_length of the response body -} -> m ((Bool, [Soup.Range.Range])) {- ^ __Returns:__ 'True' if /@hdrs@/ contained a syntactically-valid \"Range\" header, 'False' otherwise (in which case /@range@/ and /@length@/ will not be set). -} messageHeadersGetRanges hdrs totalLength = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs ranges <- allocMem :: IO (Ptr (Ptr Soup.Range.Range)) length_ <- allocMem :: IO (Ptr Int32) result <- soup_message_headers_get_ranges hdrs' totalLength ranges length_ length_' <- peek length_ let result' = (/= 0) result ranges' <- peek ranges ranges'' <- (unpackBlockArrayWithLength 16 length_') ranges' ranges''' <- mapM (wrapPtr Soup.Range.Range) ranges'' freeMem ranges' touchManagedPtr hdrs freeMem ranges freeMem length_ return (result', ranges''') #if ENABLE_OVERLOADING data MessageHeadersGetRangesMethodInfo instance (signature ~ (Int64 -> m ((Bool, [Soup.Range.Range]))), MonadIO m) => O.MethodInfo MessageHeadersGetRangesMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersGetRanges #endif -- method MessageHeaders::header_contains -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "header name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "token", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "token to look for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_header_contains" soup_message_headers_header_contains :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) CString -> -- name : TBasicType TUTF8 CString -> -- token : TBasicType TUTF8 IO CInt {- | Checks whether the list-valued header /@name@/ is present in /@hdrs@/, and contains a case-insensitive match for /@token@/. (If /@name@/ is present in /@hdrs@/, then this is equivalent to calling 'GI.Soup.Functions.headerContains' on its value.) /Since: 2.50/ -} messageHeadersHeaderContains :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> T.Text {- ^ /@name@/: header name -} -> T.Text {- ^ /@token@/: token to look for -} -> m Bool {- ^ __Returns:__ 'True' if the header is present and contains /@token@/, 'False' otherwise. -} messageHeadersHeaderContains hdrs name token = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs name' <- textToCString name token' <- textToCString token result <- soup_message_headers_header_contains hdrs' name' token' let result' = (/= 0) result touchManagedPtr hdrs freeMem name' freeMem token' return result' #if ENABLE_OVERLOADING data MessageHeadersHeaderContainsMethodInfo instance (signature ~ (T.Text -> T.Text -> m Bool), MonadIO m) => O.MethodInfo MessageHeadersHeaderContainsMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersHeaderContains #endif -- method MessageHeaders::header_equals -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "header name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "expected value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TBoolean) -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_header_equals" soup_message_headers_header_equals :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) CString -> -- name : TBasicType TUTF8 CString -> -- value : TBasicType TUTF8 IO CInt {- | Checks whether the header /@name@/ is present in /@hdrs@/ and is (case-insensitively) equal to /@value@/. /Since: 2.50/ -} messageHeadersHeaderEquals :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> T.Text {- ^ /@name@/: header name -} -> T.Text {- ^ /@value@/: expected value -} -> m Bool {- ^ __Returns:__ 'True' if the header is present and its value is /@value@/, 'False' otherwise. -} messageHeadersHeaderEquals hdrs name value = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs name' <- textToCString name value' <- textToCString value result <- soup_message_headers_header_equals hdrs' name' value' let result' = (/= 0) result touchManagedPtr hdrs freeMem name' freeMem value' return result' #if ENABLE_OVERLOADING data MessageHeadersHeaderEqualsMethodInfo instance (signature ~ (T.Text -> T.Text -> m Bool), MonadIO m) => O.MethodInfo MessageHeadersHeaderEqualsMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersHeaderEquals #endif -- method MessageHeaders::remove -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the header name to remove", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_remove" soup_message_headers_remove :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) CString -> -- name : TBasicType TUTF8 IO () {- | Removes /@name@/ from /@hdrs@/. If there are multiple values for /@name@/, they are all removed. -} messageHeadersRemove :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> T.Text {- ^ /@name@/: the header name to remove -} -> m () messageHeadersRemove hdrs name = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs name' <- textToCString name soup_message_headers_remove hdrs' name' touchManagedPtr hdrs freeMem name' return () #if ENABLE_OVERLOADING data MessageHeadersRemoveMethodInfo instance (signature ~ (T.Text -> m ()), MonadIO m) => O.MethodInfo MessageHeadersRemoveMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersRemove #endif -- method MessageHeaders::replace -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the header name to replace", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new value of @name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_replace" soup_message_headers_replace :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) CString -> -- name : TBasicType TUTF8 CString -> -- value : TBasicType TUTF8 IO () {- | Replaces the value of the header /@name@/ in /@hdrs@/ with /@value@/. (See also 'GI.Soup.Structs.MessageHeaders.messageHeadersAppend'.) The caller is expected to make sure that /@name@/ and /@value@/ are syntactically correct. -} messageHeadersReplace :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> T.Text {- ^ /@name@/: the header name to replace -} -> T.Text {- ^ /@value@/: the new value of /@name@/ -} -> m () messageHeadersReplace hdrs name value = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs name' <- textToCString name value' <- textToCString value soup_message_headers_replace hdrs' name' value' touchManagedPtr hdrs freeMem name' freeMem value' return () #if ENABLE_OVERLOADING data MessageHeadersReplaceMethodInfo instance (signature ~ (T.Text -> T.Text -> m ()), MonadIO m) => O.MethodInfo MessageHeadersReplaceMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersReplace #endif -- method MessageHeaders::set_content_disposition -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "disposition", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the disposition-type", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "params", argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "additional\nparameters, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_set_content_disposition" soup_message_headers_set_content_disposition :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) CString -> -- disposition : TBasicType TUTF8 Ptr (GHashTable CString CString) -> -- params : TGHash (TBasicType TUTF8) (TBasicType TUTF8) IO () {- | Sets the \"Content-Disposition\" header in /@hdrs@/ to /@disposition@/, optionally with additional parameters specified in /@params@/. See 'GI.Soup.Structs.MessageHeaders.messageHeadersGetContentDisposition' for a discussion of how Content-Disposition is used in HTTP. /Since: 2.26/ -} messageHeadersSetContentDisposition :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> T.Text {- ^ /@disposition@/: the disposition-type -} -> Maybe (Map.Map T.Text T.Text) {- ^ /@params@/: additional parameters, or 'Nothing' -} -> m () messageHeadersSetContentDisposition hdrs disposition params = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs disposition' <- textToCString disposition maybeParams <- case params of Nothing -> return nullPtr Just jParams -> do let jParams' = Map.toList jParams jParams'' <- mapFirstA textToCString jParams' jParams''' <- mapSecondA textToCString jParams'' let jParams'''' = mapFirst cstringPackPtr jParams''' let jParams''''' = mapSecond cstringPackPtr jParams'''' jParams'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) jParams''''' return jParams'''''' soup_message_headers_set_content_disposition hdrs' disposition' maybeParams touchManagedPtr hdrs freeMem disposition' unrefGHashTable maybeParams return () #if ENABLE_OVERLOADING data MessageHeadersSetContentDispositionMethodInfo instance (signature ~ (T.Text -> Maybe (Map.Map T.Text T.Text) -> m ()), MonadIO m) => O.MethodInfo MessageHeadersSetContentDispositionMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersSetContentDisposition #endif -- method MessageHeaders::set_content_length -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "content_length", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message body length", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_set_content_length" soup_message_headers_set_content_length :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) Int64 -> -- content_length : TBasicType TInt64 IO () {- | Sets the message body length that /@hdrs@/ will declare, and sets /@hdrs@/\'s encoding to 'GI.Soup.Enums.EncodingContentLength'. You do not normally need to call this; if /@hdrs@/ is set to use Content-Length encoding, libsoup will automatically set its Content-Length header for you immediately before sending the headers. One situation in which this method is useful is when generating the response to a HEAD request; Calling 'GI.Soup.Structs.MessageHeaders.messageHeadersSetContentLength' allows you to put the correct content length into the response without needing to waste memory by filling in a response body which won\'t actually be sent. -} messageHeadersSetContentLength :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> Int64 {- ^ /@contentLength@/: the message body length -} -> m () messageHeadersSetContentLength hdrs contentLength = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs soup_message_headers_set_content_length hdrs' contentLength touchManagedPtr hdrs return () #if ENABLE_OVERLOADING data MessageHeadersSetContentLengthMethodInfo instance (signature ~ (Int64 -> m ()), MonadIO m) => O.MethodInfo MessageHeadersSetContentLengthMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersSetContentLength #endif -- method MessageHeaders::set_content_range -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the start of the range", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "end", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the end of the range", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "total_length", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the total length of the resource, or -1 if unknown", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_set_content_range" soup_message_headers_set_content_range :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) Int64 -> -- start : TBasicType TInt64 Int64 -> -- end : TBasicType TInt64 Int64 -> -- total_length : TBasicType TInt64 IO () {- | Sets /@hdrs@/\'s Content-Range header according to the given values. (Note that /@totalLength@/ is the total length of the entire resource that this is a range of, not simply /@end@/ - /@start@/ + 1.) \\ 'GI.Soup.Objects.Server.Server' has built-in handling for range requests, and you do not normally need to call this function youself. See 'GI.Soup.Structs.MessageHeaders.messageHeadersGetRanges' for more details. \<\/para>\<\/note> /Since: 2.26/ -} messageHeadersSetContentRange :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> Int64 {- ^ /@start@/: the start of the range -} -> Int64 {- ^ /@end@/: the end of the range -} -> Int64 {- ^ /@totalLength@/: the total length of the resource, or -1 if unknown -} -> m () messageHeadersSetContentRange hdrs start end totalLength = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs soup_message_headers_set_content_range hdrs' start end totalLength touchManagedPtr hdrs return () #if ENABLE_OVERLOADING data MessageHeadersSetContentRangeMethodInfo instance (signature ~ (Int64 -> Int64 -> Int64 -> m ()), MonadIO m) => O.MethodInfo MessageHeadersSetContentRangeMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersSetContentRange #endif -- method MessageHeaders::set_content_type -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "content_type", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the MIME type", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "params", argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "additional\nparameters, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_set_content_type" soup_message_headers_set_content_type :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) CString -> -- content_type : TBasicType TUTF8 Ptr (GHashTable CString CString) -> -- params : TGHash (TBasicType TUTF8) (TBasicType TUTF8) IO () {- | Sets the \"Content-Type\" header in /@hdrs@/ to /@contentType@/, optionally with additional parameters specified in /@params@/. /Since: 2.26/ -} messageHeadersSetContentType :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> T.Text {- ^ /@contentType@/: the MIME type -} -> Maybe (Map.Map T.Text T.Text) {- ^ /@params@/: additional parameters, or 'Nothing' -} -> m () messageHeadersSetContentType hdrs contentType params = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs contentType' <- textToCString contentType maybeParams <- case params of Nothing -> return nullPtr Just jParams -> do let jParams' = Map.toList jParams jParams'' <- mapFirstA textToCString jParams' jParams''' <- mapSecondA textToCString jParams'' let jParams'''' = mapFirst cstringPackPtr jParams''' let jParams''''' = mapSecond cstringPackPtr jParams'''' jParams'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) jParams''''' return jParams'''''' soup_message_headers_set_content_type hdrs' contentType' maybeParams touchManagedPtr hdrs freeMem contentType' unrefGHashTable maybeParams return () #if ENABLE_OVERLOADING data MessageHeadersSetContentTypeMethodInfo instance (signature ~ (T.Text -> Maybe (Map.Map T.Text T.Text) -> m ()), MonadIO m) => O.MethodInfo MessageHeadersSetContentTypeMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersSetContentType #endif -- method MessageHeaders::set_encoding -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "encoding", argType = TInterface (Name {namespace = "Soup", name = "Encoding"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupEncoding", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_set_encoding" soup_message_headers_set_encoding :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) CUInt -> -- encoding : TInterface (Name {namespace = "Soup", name = "Encoding"}) IO () {- | Sets the message body encoding that /@hdrs@/ will declare. In particular, you should use this if you are going to send a request or response in chunked encoding. -} messageHeadersSetEncoding :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> Soup.Enums.Encoding {- ^ /@encoding@/: a 'GI.Soup.Enums.Encoding' -} -> m () messageHeadersSetEncoding hdrs encoding = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs let encoding' = (fromIntegral . fromEnum) encoding soup_message_headers_set_encoding hdrs' encoding' touchManagedPtr hdrs return () #if ENABLE_OVERLOADING data MessageHeadersSetEncodingMethodInfo instance (signature ~ (Soup.Enums.Encoding -> m ()), MonadIO m) => O.MethodInfo MessageHeadersSetEncodingMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersSetEncoding #endif -- method MessageHeaders::set_expectations -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "expectations", argType = TInterface (Name {namespace = "Soup", name = "Expectation"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the expectations to set", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_set_expectations" soup_message_headers_set_expectations :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) CUInt -> -- expectations : TInterface (Name {namespace = "Soup", name = "Expectation"}) IO () {- | Sets /@hdrs@/\'s \"Expect\" header according to /@expectations@/. Currently 'GI.Soup.Flags.ExpectationContinue' is the only known expectation value. You should set this value on a request if you are sending a large message body (eg, via POST or PUT), and want to give the server a chance to reject the request after seeing just the headers (eg, because it will require authentication before allowing you to post, or because you\'re POSTing to a URL that doesn\'t exist). This saves you from having to transmit the large request body when the server is just going to ignore it anyway. -} messageHeadersSetExpectations :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> [Soup.Flags.Expectation] {- ^ /@expectations@/: the expectations to set -} -> m () messageHeadersSetExpectations hdrs expectations = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs let expectations' = gflagsToWord expectations soup_message_headers_set_expectations hdrs' expectations' touchManagedPtr hdrs return () #if ENABLE_OVERLOADING data MessageHeadersSetExpectationsMethodInfo instance (signature ~ ([Soup.Flags.Expectation] -> m ()), MonadIO m) => O.MethodInfo MessageHeadersSetExpectationsMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersSetExpectations #endif -- method MessageHeaders::set_range -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the start of the range to request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "end", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the end of the range to request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_set_range" soup_message_headers_set_range :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) Int64 -> -- start : TBasicType TInt64 Int64 -> -- end : TBasicType TInt64 IO () {- | Sets /@hdrs@/\'s Range header to request the indicated range. /@start@/ and /@end@/ are interpreted as in a 'GI.Soup.Structs.Range.Range'. If you need to request multiple ranges, use 'GI.Soup.Structs.MessageHeaders.messageHeadersSetRanges'. /Since: 2.26/ -} messageHeadersSetRange :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> Int64 {- ^ /@start@/: the start of the range to request -} -> Int64 {- ^ /@end@/: the end of the range to request -} -> m () messageHeadersSetRange hdrs start end = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs soup_message_headers_set_range hdrs' start end touchManagedPtr hdrs return () #if ENABLE_OVERLOADING data MessageHeadersSetRangeMethodInfo instance (signature ~ (Int64 -> Int64 -> m ()), MonadIO m) => O.MethodInfo MessageHeadersSetRangeMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersSetRange #endif -- method MessageHeaders::set_ranges -- method type : OrdinaryMethod -- Args : [Arg {argCName = "hdrs", argType = TInterface (Name {namespace = "Soup", name = "MessageHeaders"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessageHeaders", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ranges", argType = TInterface (Name {namespace = "Soup", name = "Range"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an array of #SoupRange", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of @range", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_message_headers_set_ranges" soup_message_headers_set_ranges :: Ptr MessageHeaders -> -- hdrs : TInterface (Name {namespace = "Soup", name = "MessageHeaders"}) Ptr Soup.Range.Range -> -- ranges : TInterface (Name {namespace = "Soup", name = "Range"}) Int32 -> -- length : TBasicType TInt IO () {- | Sets /@hdrs@/\'s Range header to request the indicated ranges. (If you only want to request a single range, you can use 'GI.Soup.Structs.MessageHeaders.messageHeadersSetRange'.) /Since: 2.26/ -} messageHeadersSetRanges :: (B.CallStack.HasCallStack, MonadIO m) => MessageHeaders {- ^ /@hdrs@/: a 'GI.Soup.Structs.MessageHeaders.MessageHeaders' -} -> Soup.Range.Range {- ^ /@ranges@/: an array of 'GI.Soup.Structs.Range.Range' -} -> Int32 {- ^ /@length@/: the length of /@range@/ -} -> m () messageHeadersSetRanges hdrs ranges length_ = liftIO $ do hdrs' <- unsafeManagedPtrGetPtr hdrs ranges' <- unsafeManagedPtrGetPtr ranges soup_message_headers_set_ranges hdrs' ranges' length_ touchManagedPtr hdrs touchManagedPtr ranges return () #if ENABLE_OVERLOADING data MessageHeadersSetRangesMethodInfo instance (signature ~ (Soup.Range.Range -> Int32 -> m ()), MonadIO m) => O.MethodInfo MessageHeadersSetRangesMethodInfo MessageHeaders signature where overloadedMethod _ = messageHeadersSetRanges #endif #if ENABLE_OVERLOADING type family ResolveMessageHeadersMethod (t :: Symbol) (o :: *) :: * where ResolveMessageHeadersMethod "append" o = MessageHeadersAppendMethodInfo ResolveMessageHeadersMethod "cleanConnectionHeaders" o = MessageHeadersCleanConnectionHeadersMethodInfo ResolveMessageHeadersMethod "clear" o = MessageHeadersClearMethodInfo ResolveMessageHeadersMethod "foreach" o = MessageHeadersForeachMethodInfo ResolveMessageHeadersMethod "free" o = MessageHeadersFreeMethodInfo ResolveMessageHeadersMethod "freeRanges" o = MessageHeadersFreeRangesMethodInfo ResolveMessageHeadersMethod "get" o = MessageHeadersGetMethodInfo ResolveMessageHeadersMethod "headerContains" o = MessageHeadersHeaderContainsMethodInfo ResolveMessageHeadersMethod "headerEquals" o = MessageHeadersHeaderEqualsMethodInfo ResolveMessageHeadersMethod "remove" o = MessageHeadersRemoveMethodInfo ResolveMessageHeadersMethod "replace" o = MessageHeadersReplaceMethodInfo ResolveMessageHeadersMethod "getContentDisposition" o = MessageHeadersGetContentDispositionMethodInfo ResolveMessageHeadersMethod "getContentLength" o = MessageHeadersGetContentLengthMethodInfo ResolveMessageHeadersMethod "getContentRange" o = MessageHeadersGetContentRangeMethodInfo ResolveMessageHeadersMethod "getContentType" o = MessageHeadersGetContentTypeMethodInfo ResolveMessageHeadersMethod "getEncoding" o = MessageHeadersGetEncodingMethodInfo ResolveMessageHeadersMethod "getExpectations" o = MessageHeadersGetExpectationsMethodInfo ResolveMessageHeadersMethod "getHeadersType" o = MessageHeadersGetHeadersTypeMethodInfo ResolveMessageHeadersMethod "getList" o = MessageHeadersGetListMethodInfo ResolveMessageHeadersMethod "getOne" o = MessageHeadersGetOneMethodInfo ResolveMessageHeadersMethod "getRanges" o = MessageHeadersGetRangesMethodInfo ResolveMessageHeadersMethod "setContentDisposition" o = MessageHeadersSetContentDispositionMethodInfo ResolveMessageHeadersMethod "setContentLength" o = MessageHeadersSetContentLengthMethodInfo ResolveMessageHeadersMethod "setContentRange" o = MessageHeadersSetContentRangeMethodInfo ResolveMessageHeadersMethod "setContentType" o = MessageHeadersSetContentTypeMethodInfo ResolveMessageHeadersMethod "setEncoding" o = MessageHeadersSetEncodingMethodInfo ResolveMessageHeadersMethod "setExpectations" o = MessageHeadersSetExpectationsMethodInfo ResolveMessageHeadersMethod "setRange" o = MessageHeadersSetRangeMethodInfo ResolveMessageHeadersMethod "setRanges" o = MessageHeadersSetRangesMethodInfo ResolveMessageHeadersMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveMessageHeadersMethod t MessageHeaders, O.MethodInfo info MessageHeaders p) => OL.IsLabel t (MessageHeaders -> 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