gi-soup-3.0.2: Libsoup bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Soup.Structs.Multipart

Description

Represents a multipart HTTP message body, parsed according to the syntax of RFC 2046.

Of particular interest to HTTP are multipart/byte-ranges and multipart/form-data,

Although the headers of a Multipart body part will contain the full headers from that body part, libsoup does not interpret them according to MIME rules. For example, each body part is assumed to have "binary" Content-Transfer-Encoding, even if its headers explicitly state otherwise. In other words, don't try to use Multipart for handling real MIME multiparts.

Synopsis

Exported types

newtype Multipart Source #

Memory-managed wrapper type.

Constructors

Multipart (ManagedPtr Multipart) 

Instances

Instances details
Eq Multipart Source # 
Instance details

Defined in GI.Soup.Structs.Multipart

GBoxed Multipart Source # 
Instance details

Defined in GI.Soup.Structs.Multipart

ManagedPtrNewtype Multipart Source # 
Instance details

Defined in GI.Soup.Structs.Multipart

Methods

toManagedPtr :: Multipart -> ManagedPtr Multipart

TypedObject Multipart Source # 
Instance details

Defined in GI.Soup.Structs.Multipart

Methods

glibType :: IO GType

HasParentTypes Multipart Source # 
Instance details

Defined in GI.Soup.Structs.Multipart

IsGValue (Maybe Multipart) Source #

Convert Multipart to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Soup.Structs.Multipart

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe Multipart -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe Multipart)

type ParentTypes Multipart Source # 
Instance details

Defined in GI.Soup.Structs.Multipart

type ParentTypes Multipart = '[] :: [Type]

Methods

Click to display all available methods, including inherited ones

Expand

Methods

appendFormFile, appendFormString, appendPart, free, toMessage.

Getters

getLength, getPart.

Setters

None.

appendFormFile

multipartAppendFormFile Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Multipart

multipart: a multipart (presumably of type "multipart/form-data")

-> Text

controlName: the name of the control associated with this file

-> Maybe Text

filename: the name of the file, or Nothing if not known

-> Maybe Text

contentType: the MIME type of the file, or Nothing if not known

-> Bytes

body: the file data

-> m () 

Adds a new MIME part containing body to multipart

Uses "Content-Disposition: form-data", as per the HTML forms specification.

appendFormString

multipartAppendFormString Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Multipart

multipart: a multipart (presumably of type "multipart/form-data")

-> Text

controlName: the name of the control associated with data

-> Text

data: the body data

-> m () 

Adds a new MIME part containing data to multipart.

Uses "Content-Disposition: form-data", as per the HTML forms specification.

appendPart

multipartAppendPart Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Multipart

multipart: a Multipart

-> MessageHeaders

headers: the MIME part headers

-> Bytes

body: the MIME part body

-> m () 

Adds a new MIME part to multipart with the given headers and body.

(The multipart will make its own copies of headers and body, so you should free your copies if you are not using them for anything else.)

free

multipartFree Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Multipart

multipart: a Multipart

-> m () 

Frees multipart.

getLength

multipartGetLength Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Multipart

multipart: a Multipart

-> m Int32

Returns: the number of body parts in multipart

Gets the number of body parts in multipart.

getPart

multipartGetPart Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Multipart

multipart: a Multipart

-> Int32

part: the part number to get (counting from 0)

-> m (Bool, MessageHeaders, Bytes)

Returns: True on success, False if part is out of range (in which case headers and body won't be set)

Gets the indicated body part from multipart.

new

multipartNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

mimeType: the MIME type of the multipart to create.

-> m Multipart

Returns: a new empty Multipart of the given mimeType

Creates a new empty Multipart with a randomly-generated boundary string.

Note that mimeType must be the full MIME type, including "multipart/".

See also: [ctormessage.new_from_multipart].

newFromMessage

multipartNewFromMessage Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> MessageHeaders

headers: the headers of the HTTP message to parse

-> Bytes

body: the body of the HTTP message to parse

-> m (Maybe Multipart)

Returns: a new Multipart (or Nothing if the message couldn't be parsed or wasn't multipart).

Parses headers and body to form a new Multipart

toMessage

multipartToMessage Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Multipart

multipart: a Multipart

-> MessageHeaders

destHeaders: the headers of the HTTP message to serialize multipart to

-> m Bytes 

Serializes multipart to destHeaders and destBody.