Qore Mime Module Reference 1.6
Loading...
Searching...
No Matches
Mime::MultiPartFormDataMessage Class Reference

implements the MultiPartFormDataMessage class, a specialization of MultiPartMessage More...

#include <Mime.qm.dox.h>

Inheritance diagram for Mime::MultiPartFormDataMessage:
[legend]

Public Member Methods

 addPart (data mime_data, string name, *hash hdr)
 adds a message part to the end of the list
 
 addPart (data mime_data, string name, string filename, string content_type, *hash hdr)
 adds a message part to the end of the list
 
 addPart (hash< FormDataMessageInfo > h)
 adds a message part to the end of the list
 
 constructor (string boundary=MultiPartMessage::getBoundary())
 creates the object
 
hash< MessageInfogetMsgAndHeaders ()
 returns a hash of the message
 
 splicePart (data mime_data, string name, *hash hdr)
 adds a message part to the start of the list
 
 splicePart (data mime_data, string name, string filename, string content_type, *hash hdr)
 adds a message part to the start of the list
 
 splicePart (hash< FormDataMessageInfo > h)
 adds a message part to the start of the list
 
- Public Member Methods inherited from Mime::MultiPartMessage
 constructor (string mptype, string boundary=MultiPartMessage::getBoundary())
 creates the object
 
string getBoundary ()
 returns the message boundary string used
 
abstract hash< MessageInfogetMsgAndHeaders ()
 returns a hash of the message
 
binary serialize ()
 serializes the message with the Content-Type header first and returns a binary object ready to send over a socket
 
binary serializeBody ()
 serializes the message body only and returns a binary object ready to send over a socket
 
int size ()
 returns the number of parts in the message
 

Static Public Member Methods

static MultiPartFormDataMessage makeMessage (hash< string, hash< FormDataMessageInfo > > parts)
 creates a multipart/form-data message from a hash of FormDataMessageInfo hashes keyed by part name
 
static binary makeMessageBody (hash< string, hash< FormDataMessageInfo > > parts)
 creates a multipart/form-data message body from a hash of FormDataMessageInfo hashes keyed by part name
 
static hash< string, hash< FormDataMessageInfo > > parseMessage (string content, string body)
 parses a multipart/form-data encoded message and returns a hash of its ContentTransEnc7Bit
 
- Static Public Member Methods inherited from Mime::MultiPartMessage
static string getBoundary ()
 returns a string embedded with the current timestamp designed to be used as MultiPart boundary string
 
static string getRandomString (int len)
 returns a string of random characters
 
static hash< MessageInfoparseBody (string boundary, data body, bool decode=True)
 returns a hash representing a parsed multipart message body from a boundary string and body arguments
 
static binary serializeHeaders (hash hdr)
 serializes a header hash to a binary object
 

Private Member Methods

 checkPartName (string name)
 check for unique part names and adds the part to the unique name hash
 
hash getPartHeader (string name, *string filename, *string content_type, *hash< auto > hdr)
 builds the header for the part
 

Private Attributes

hash parts
 hash of part names to ensure uniqueness
 

Detailed Description

implements the MultiPartFormDataMessage class, a specialization of MultiPartMessage

Since
Mime 1.4

Member Function Documentation

◆ addPart() [1/3]

Mime::MultiPartFormDataMessage::addPart ( data  mime_data,
string  name,
*hash  hdr 
)

adds a message part to the end of the list

Parameters
mime_datathe data for the part
namethe unique name for the part
hdran optional hash of headers for the part
Exceptions
MULTIPART-FORMDATA-ERRORthe name parameter is empty or conflicts with an existing part name

◆ addPart() [2/3]

Mime::MultiPartFormDataMessage::addPart ( data  mime_data,
string  name,
string  filename,
string  content_type,
*hash  hdr 
)

adds a message part to the end of the list

Parameters
mime_datathe data for the part
namethe unique name for the part
filenamethe filename for the part
content_typethe content_type for the part
hdran optional hash of headers for the part
Exceptions
MULTIPART-FORMDATA-ERRORthe name parameter is empty or conflicts with an existing part name; empty filename or content_type arguments

◆ addPart() [3/3]

Mime::MultiPartFormDataMessage::addPart ( hash< FormDataMessageInfo h)

adds a message part to the end of the list

Parameters
hthe information for this part
Exceptions
MULTIPART-FORMDATA-ERRORthe name parameter is empty or conflicts with an existing part name; empty filename or content_type arguments

◆ constructor()

Mime::MultiPartFormDataMessage::constructor ( string  boundary = MultiPartMessage::getBoundary())

creates the object

Parameters
boundarythe boundary to use between parts

◆ getMsgAndHeaders()

hash< MessageInfo > Mime::MultiPartFormDataMessage::getMsgAndHeaders ( )

returns a hash of the message

Returns
a hash of the message with the following keys:
  • hdr: a hash of header information
  • body: a binary object of serialized message parts

◆ makeMessage()

static MultiPartFormDataMessage Mime::MultiPartFormDataMessage::makeMessage ( hash< string, hash< FormDataMessageInfo > >  parts)
static

creates a multipart/form-data message from a hash of FormDataMessageInfo hashes keyed by part name

Parameters
partsa hash of FormDataMessageInfo hashes keyed by part name
Returns
the message object corresponding to the arguments

◆ makeMessageBody()

static binary Mime::MultiPartFormDataMessage::makeMessageBody ( hash< string, hash< FormDataMessageInfo > >  parts)
static

creates a multipart/form-data message body from a hash of FormDataMessageInfo hashes keyed by part name

Parameters
partsa hash of FormDataMessageInfo hashes keyed by part name
Returns
the serialized message body corresponding to the arguments

◆ parseMessage()

static hash< string, hash< FormDataMessageInfo > > Mime::MultiPartFormDataMessage::parseMessage ( string  content,
string  body 
)
static

parses a multipart/form-data encoded message and returns a hash of its ContentTransEnc7Bit

Parameters
contentthe message Content-Type string which must contain the message boundary string
bodythe message body to parse
Returns
a hash of FormDataMessageInfo hashes keyed by part name
Exceptions
MULTIPART-FORMDATA-MESSAGE-ERRORcannot find message boundary string; invalid form-data part data
Since
Mime 1.4

◆ splicePart() [1/3]

Mime::MultiPartFormDataMessage::splicePart ( data  mime_data,
string  name,
*hash  hdr 
)

adds a message part to the start of the list

Parameters
mime_datathe data for the part
namethe unique name for the part
hdran optional hash of headers for the part
Exceptions
MULTIPART-FORMDATA-ERRORthe name parameter is empty or conflicts with an existing part name

◆ splicePart() [2/3]

Mime::MultiPartFormDataMessage::splicePart ( data  mime_data,
string  name,
string  filename,
string  content_type,
*hash  hdr 
)

adds a message part to the start of the list

Parameters
mime_datathe data for the part
namethe unique name for the part
filenamethe filename for the part
content_typethe content_type for the part
hdran optional hash of headers for the part
Exceptions
MULTIPART-FORMDATA-ERRORthe name parameter is empty or conflicts with an existing part name; empty filename or content_type arguments

◆ splicePart() [3/3]

Mime::MultiPartFormDataMessage::splicePart ( hash< FormDataMessageInfo h)

adds a message part to the start of the list

Parameters
hthe information for this part
Exceptions
MULTIPART-FORMDATA-ERRORthe name parameter is empty or conflicts with an existing part name; empty filename or content_type arguments