Loading...
Searching...
No Matches
Mime::MultiPartFormDataMessage Class Reference

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

Inheritance diagram for Mime::MultiPartFormDataMessage:
[legend]

## Public Member Functions

| addPart (data mime_data, string name, *hash hdr)
| adds a message part to the end of the list More...
| addPart (data mime_data, string name, string filename, string content_type, *hash hdr)
| adds a message part to the end of the list More...
| addPart (hash< FormDataMessageInfo > h)
| adds a message part to the end of the list More...
| constructor (string boundary=MultiPartMessage::getBoundary())
| creates the object More...
hash< MessageInfo > | getMsgAndHeaders ()
| returns a hash of the message More...
| splicePart (data mime_data, string name, *hash hdr)
| adds a message part to the start of the list More...
| splicePart (data mime_data, string name, string filename, string content_type, *hash hdr)
| adds a message part to the start of the list More...
| splicePart (hash< FormDataMessageInfo > h)
| adds a message part to the start of the list More...
Public Member Functions inherited from Mime::MultiPartMessage
| constructor (string mptype, string boundary=MultiPartMessage::getBoundary())
| creates the object More...
string | getBoundary ()
| returns the message boundary string used More...
abstract hash< MessageInfo > | getMsgAndHeaders ()
| returns a hash of the message More...
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 More...
int | size ()
| returns the number of parts in the message More...

## Static Public Member Functions

static MultiPartFormDataMessage | makeMessage (hash< string, hash< FormDataMessageInfo > > parts)
| creates a multipart/form-data message from a hash of FormDataMessageInfo hashes keyed by part name More...
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 More...
static hash< string, hash< FormDataMessageInfo > > | parseMessage (string content, string body)
| parses a multipart/form-data encoded message and returns a hash of its ContentTransEnc7Bit More...
Static Public Member Functions 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 More...
static hash< MessageInfo > | parseBody (string boundary, data body, bool decode=True)
| returns a hash representing a parsed multipart message body from a boundary string and body arguments More...
static binary | serializeHeaders (hash hdr)
| serializes a header hash to a binary object More...

## Protected Member Functions

| 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 hdr)
| builds the header for the part

## Protected 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_data | the data for the part
  name | the unique name for the part
  hdr | an optional hash of headers for the part

Exceptions

  MULTIPART-FORMDATA-ERROR | the 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_data | the data for the part
  name | the unique name for the part
  filename | the filename for the part
  content_type | the content_type for the part
  hdr | an optional hash of headers for the part

Exceptions

  MULTIPART-FORMDATA-ERROR | the 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

  h | the information for this part

Exceptions

  MULTIPART-FORMDATA-ERROR | the 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

  boundary | the boundary to use between parts

## getMsgAndHeaders()

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

virtual

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

Implements Mime::MultiPartMessage.

## 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

  parts | a 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

  parts | a 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

  content | the message `Content-Type` string which must contain the message boundary string
  body | the message body to parse

Returns
  a hash of FormDataMessageInfo hashes keyed by part name

Exceptions

  MULTIPART-FORMDATA-MESSAGE-ERROR | cannot 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_data | the data for the part
  name | the unique name for the part
  hdr | an optional hash of headers for the part

Exceptions

  MULTIPART-FORMDATA-ERROR | the 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_data | the data for the part
  name | the unique name for the part
  filename | the filename for the part
  content_type | the content_type for the part
  hdr | an optional hash of headers for the part

Exceptions

  MULTIPART-FORMDATA-ERROR | the 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

  h | the information for this part

Exceptions

  MULTIPART-FORMDATA-ERROR | the name parameter is empty or conflicts with an existing part name; empty filename or content_type arguments