DIME::Tools(3pm)

DIME::Tools3pm

Modules for parsing and generate dime messages

Usage

Generating DIME messages

                my $payload = DIME::Payload->new();
                $payload->attach(Path => "/mydata/index.html",
                                 MIMEType => 'text/html',
                                 Dynamic => 1);
                my $payload2 = DIME::Payload->new();
                $payload2->attach( Data => "HELLO WORLD!!!",
                                   MIMEType => 'text/plain' );
                my $message = DIME::Message->new();
        my $payload = DIME::Payload->new();
        $payload->attach(Path => "/mydata/index.html",
                         MIMEType => 'text/html',
                         Dynamic => 1);
                $message->add_payload($payload);
                $message->add_payload($payload2);
                # Print the encoded message to STDOUT
                $message->print(\*STDOUT);

Parsing DIME messages

        my $parser = DIME::Parser->new();
                # Open a file with a dime encoded message
        $f = IO::File->new("dime.message","r");
        my $message = $parser->parse($f);
        $f->close();
                # Print the content of each payload to STDOUT
        for my $i ($message->payloads())
        {
                print $i->print_content(\*STDOUT);
        }

Overview

DIME-tools is a collection of DIME:: modules for parsing and generating DIME encoded messages (Direct Internet Message Encapsulation). DIME-tools support single-record and chunked payloads for sending big attachments.

This distribution hasn't been actively developed since 2004. Subsequent releases have been to get the distribution following CPAN conventions, as there is one distribution depending on it

Generating messages

For any content you want to send in a message, you have to create a Payload object:

        my $payload = DIME::Payload->new();
        $payload->attach(Path => "/mydata/index.html",
                         MIMEType => 'text/html',
                         Dynamic => 1);

With the attach method you can specify the next keys:

Path:

the name of the file you want to attach to the payload object. If the data you want to attach isn't in a file, you can use the Data key.

Data:

it's the reference to a scalar in which you store the data you want to attach.

Dynamic:

if Path is declared, the data is not loaded fully in memory. The only that you attach to the payload object is the name of the file of the Path key, not the content itself.

Chunked:

if it's declared, it represents the size of the chunk records in bytes. If you don't declare it, the message will not be chunked.

MIMEType:

the type of the payload. It must be a string with a MIME standard type. Other possibility is to use URIType.

URIType:

specifies an URI that defines that type of the content.

Attach a payload to a message

        my $message = DIME::Message->new();
        $message->add_payload($payload);

Parsing messages

All you have to do is create a DIME::Parser object and call the parse method with a IO::Handle to a DIME message. Then you can iterate over the $message->payloads() array to get the contents of the message:

        my $parser = DIME::Parser->new();
        $f = IO::File->new("dime.message","r");
        my $message = $parser->parse($f);
        $f->close();
        for my $i ($message->payloads())
        {
                print $i->print_content(\*STDOUTs);
        }

You can also call to parse_data if you have a DIME message in a scalar variable:

        my $dime_message;
        my $message = $parser->parse_data(\$dime_message);

And call print_content_data if what you want is to get a reference to the content-data.

Releases

6 releases since Debian 8 (Jessie); the text changed 2 times.

  1. 8
  2. 9–10
  3. 11–13

Author

Domingo Alcazar Larrea, <[email protected]>

From libdime-tools-perl 0.05-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.