Charlie API Reference

CharlieException() .global

Summary

This object is used for error propagation from actions.

Syntax

       CharlieException()

Example

       ex = new CharlieException();
       ex.code = 1234;
       ex.msg = "bad event";
       throw ex;

Notes

Set different properties to see them in the report log.

See Also

Groups [ .global ]

DOMDocument DOMDocument

Summary

This object allows to access the internal Sablotron structures using the subset of DOM level 1 calls. It may be used as a factory for new documents or as an wrapper around DOM documents returned from modules. This object extends the Node object.

Syntax

       new DOMDocument([handle])
NameTypeDescription
handlePerlValuethe internal document handle returned form the module - optional

Example

       doc = new DOMDocument();
       root = doc.createElement("root");
       doc.appendChild(root);

See Also

Groups [ DOMDocument ]
Entries [ Node ]

DOMDocument.autodispose() DOMDocument

Summary

set.get the autodispose flag of the document. If this flag is set, the resources allocated by Sablotron are disposed, when the JS variable gets out of its scope. The default is true.

Syntax

       autodispose([flag])
NameTypeDescription
flagboolenthe flag - optional

Example

       doc.autodispose(0);

Notes

You usually don't need change the default value.

See Also

Groups [ DOMDocument ]
Entries [ Node ]

DOMDocument.cloneNode() DOMDocument

Summary

Clone given Node and set itself as the owning document. Deep copy is supported.

Syntax

       cloneNode(node, deep)
NameTypeDescription
nodeNodethe node to be cloned
deepbooleanindicates whether the subtree is to be cloned

Example

       root = doc1.cloneNode(doc2.getFirstChild());
       doc1.appendChild(root); //copy the whole document

See Also

Groups [ DOMDocument ]
Entries [ Node ]

DOMDocument.createCDATASection() DOMDocument

Summary

Create new CDATA section node. It works exactly like DOMDocument.createTextNode(); the only difference is serialization of this node.

Syntax

       createCDATASection(value)
NameTypeDescription
valuestringthe node content

Example

       doc.createCDATASection("my data");

See Also

Groups [ DOMDocument ]
Entries [ DOMDocument.createTextNode() | Node ]

DOMDocument.createComment() DOMDocument

Summary

Create new comment node.

Syntax

       createComment(value)
NameTypeDescription
valuestringthe node content

Example

       doc.createComment("the reason is this and that");

See Also

Groups [ DOMDocument ]
Entries [ Node ]

DOMDocument.createElement() DOMDocument

Summary

Create new Element of given name.

Syntax

       createElement(name)
NameTypeDescription
namestringthe new element name

Example

       e = doc.createElement("book");

See Also

Groups [ DOMDocument ]
Entries [ Element | Node ]

DOMDocument.createProcessingInstruction() DOMDocument

Summary

Create new processing instruction node.

Syntax

       createProcessingInstruction(target, data)
NameTypeDescription
targetstringthe target application
datastringthe PI data

Example

       doc.createProcessingInstruction("myapp", "mydata");

See Also

Groups [ DOMDocument ]
Entries [ Node ]

DOMDocument.createTextNode() DOMDocument

Summary

Create new text node of given content.

Syntax

       createTextNode(value)
NameTypeDescription
valuestringthe node content

Example

       doc.createTextNode("my data");

See Also

Groups [ DOMDocument ]
Entries [ Node ]

DOMDocument.docToString() DOMDocument

Summary

Serialize the document.

Syntax

       docToString()

Example

       str = doc.docToString();

Notes

Many functions accepting the XML documents as a parameter accept the DOMDocument directly.

See Also

Groups [ DOMDocument ]
Entries [ Node ]

DOMDocument.freeDocument() DOMDocument

Summary

Free the document immediately.

Syntax

       freeDocument()

Example

       doc.freeDocument();

Notes

Do it for HUGE documents only to. All documents are disposed at the end of the action by default.

See Also

Groups [ DOMDocument ]
Entries [ Node ]

Element Element

Summary

Object for element node representation. Extends the Node object, adds some attribute handling methods.

Syntax

       Element(handle)
NameTypeDescription
handlePerlValuethe internal perl handle of the node

Example

       element = new Element(handle);

Notes

Never use this contstructor directly! Use the factory methods of the DOMDocument object.

See Also

Groups [ Element ]
Entries [ DOMDocument | Node ]

Element.getAttribute() Element

Summary

Get the value of the specified attribute.

Syntax

       getAttribute(name)
NameTypeDescription
namestringthe name of the attribute

Example

       value = element.getAttribute("href");

See Also

Groups [ Element ]
Entries [ Element.removeAttribute() | Element.setAttribute() | Node ]

Element.removeAttribute() Element

Summary

Remove the specified attribute the element.

Syntax

       removeAttribute(name)
NameTypeDescription
namestringthe name of the attribute

Example

       element.removeAttribute("href");

See Also

Groups [ Element ]
Entries [ Element.getAttribute() | Element.setAttribute() | Node ]

Element.setAttribute() Element

Summary

Set the attribute of the element node.

Syntax

       setAttribute(name, value)
NameTypeDescription
namestringthe name of the attribute
valuestringthe value if the attribute

Example

       element.setAttribute("href", "mydoc.xml");

See Also

Groups [ Element ]
Entries [ Element.getAttribute() | Element.removeAttribute() | Node ]

FormData FormData

Summary

This object represents a part of MultipartFormData.

Description

This object represents a part of MultipartFormData. The MultipartFormData is Request.parsedContent() of a request that delivers POSTed "multipart/form-data" encrypted HTML form. This form setting is used for files upload.

FormData is similar to MessagePart, except it is strictly read only and its interface is enriched by some methods specific to HTTP form posting and file uploads.

Field metadata details can be accessed using FormData.name(), FormData.header(), FormData.filename() and FormData.size() methods.

Field value can be read out by FormData.value() or FormData.read() method.

Big data (like big uploaded file) manipulation can be easier with knowing of FormData.storageFilename().

See Also

Groups [ FormData ]
Entries [ FormData.filename() | FormData.header() | FormData.name() | FormData.read() | FormData.size() | FormData.storageFilename() | FormData.value() | MessagePart | MultipartFormData | Request.parsedContent() ]

FormData.filename() FormData

Summary

Gets name of uploaded file.

Syntax

       filename()

Description

Multipart/form-data form is used for files uploading. When FormData represents the uploaded file, this method returns the file original name, otherwise, it returns nothing.

Example

       // action responds to a POSTED multipart/form-data form
       var mfd = request.parsedContent();
       var file = mfd.field("file1");
       var origFileName = file.filename();

See Also

Groups [ FormData ]
Entries [ FormData ]

FormData.header() FormData

Summary

Gets field header value.

Syntax

       header(name);
NameTypeDescription
namestringname of header field

Description

Read-only access to form field header. Header field names are case-insensitive. See RFC 2388 and RFC 1867 for details.

Example

       // action responds to a POSTED multipart/form-data form
       var mfd = request.parsedContent();
       var name = mfd.field("name");
       var cte = name.header("Content-Transfer-Encoding");

See Also

Groups [ FormData ]

FormData.name() FormData

Summary

Gets field name.

Syntax

       name();    

Description

Multipart/form-data form may contain several fields with the same name. In this case, the fields must be accessed by their indexes. Name of a particular form data field is then available by calling this method.

Example

       // action responds to a POSTED multipart/form-data form
       var mfd = request.parsedContent();
       for (i=0; i < 0; i++) {
            var field = mfd.fieldIdx(i);
            var name = field.name();
            ....
       };

See Also

Groups [ FormData ]

FormData.read() FormData

Summary

Reads part of field data.

Syntax

       read([size])
NameTypeDescription
sizenumber [bytes]size of data to be read out, in bytes - optional

Description

See MessagePart.value() and MessagePart.read().

Example

       // action responds to a POSTED multipart/form-data form
       var mfd = request.parsedContent();
       var file = mfd.field("file1");
       var buff = file.read(1024);
       while (buff) {
            // do something with the buffer
            buff = file.read(1024);
       };
       ...
       or
       ...
       var mfd = request.parsedContent();
       var file = mfd.field("file1");
       var data = file.read(); // the same as file.value()

See Also

Groups [ FormData ]
Entries [ MessagePart.read() | MessagePart.value() ]

FormData.size() FormData

Summary

Gets size of data in the field.

Syntax

       size();

Description

Gets size of data in the field. Size of field headers is not included.

Example

       // action responds to a POSTED multipart/form-data form
       var mfd = request.parsedContent();
       var file = mfd.field("file1");
       var size = file.size();

See Also

Groups [ FormData ]

FormData.storageFilename() FormData

Summary

Gets name of the temporary file used to store field data.

Syntax

       storageFilename();

Description

See discussions to RawContent.tempFilename() and MessagePart.storageFilename().

Example

       // action responds to a POSTED multipart/form-data form
       var mfd = request.parsedContent();
       var file = mfd.field("file1");
       var origFileName = file.filename();
       var tempFilename = file.storageFilename();

See Also

Groups [ FormData ]
Entries [ MessagePart.storageFilename() | RawContent.tempFilename() ]

FormData.value() FormData

Summary

Gets field value.

Syntax

       value();

Description

See MessagePart.value() and MessagePart.read().

Example

       // action responds to a POSTED multipart/form-data form
       var mfd = request.parsedContent();
       for (i=0; i < 0; i++) {
            var field = mfd.fieldIdx(i);
            var name = field.name();
            var value = field.value();
            ....
       };

See Also

Groups [ FormData ]
Entries [ MessagePart.read() | MessagePart.value() ]

Introduction .description

Summary

Actions, short JavaScript programs launched as a response to an incoming request are basic building stones of Charlie mosaic.

Description

In Charlie actions, you may use all the constructs defined by the ECMA language specifications, as their are implemented in Mozilla's JavaScript engine version 1.5.
To interact with the Charlie engine, XSLT or DOM processor, etc. there are several global objects available in the JS context. These objects offer either the Charlie engine (core) services or miscellaneous tools useful when designing actions.
In addition to the standard Charlie features, you are allowed to plug your own libraries in Perl or JavaScript in and to create your own API extensions to be called from actions.

Notes

The standard objects are:
Request
Response
URI
Query
Sablotron
DOMDocument
Element
Node
Mail
RawContent
MultipartMessage, MessagePart
MultipartFormData, FormData

See Also

Groups [ .description ]
Entries [ DOMDocument | Element | FormData | Mail | MessagePart | MultipartFormData | MultipartMessage | Node | Query | RawContent | Request | Response | Sablotron | URI ]

Mail Mail

Summary

E-mail sender object representation.

Syntax

       Mail()

Example

       mail = new Mail();
       mail.from("sender@domain.com");
       mail.to("receiver@domain.com");
       mail.subject("Good News");
       mail.send("This mail is generated by Charlie");

Notes

The underlaying code attempts to send a message using a mailer deamon (sendmail by default, see Mail.mailer()). If not successful, it looks for Net::SMTP perl module (see Mail.host()). If still not successful, an error is issued.

See Also

Groups [ Mail ]
Entries [ Mail.host() | Mail.mailer() ]

Mail.addBody() Mail

Summary

Add a line of text to the message to be send.

Syntax

       addBody(txt)
NameTypeDescription
textstringmessage text

Example

       mail.addBody("This mail is generated by Charlie");

Notes

Strings added with addBody method will be separated by a newline character.

See Also

Groups [ Mail ]
Entries [ Mail.removeBody() | Mail.send() ]

Mail.addHeader() Mail

Summary

Set the specified header of the message.

Syntax

       addHeader(field, value)
NameTypeDescription
fieldstringthe specified field
valuestringthe value of the specified field

Example

       mail.addHeader("Content-type","text/plain; charset=UTF-8");

Notes

There are shortcuts defined for the most common headers (From, Subject, To, Cc, Bcc)

See Also

Groups [ Mail ]
Entries [ Mail.bcc() | Mail.cc() | Mail.from() | Mail.subject() | Mail.to() ]

Mail.bcc() Mail

Summary

Set the Bcc header of the message.

Syntax

       bcc(value)
NameTypeDescription
valuestringthe value of the Bcc field

Example

       mail.bcc("receiver@domain.com");

See Also

Groups [ Mail ]
Entries [ Mail.addHeader() | Mail.removeHeader() ]

Mail.cc() Mail

Summary

Set the CC header of the message.

Syntax

       cc(value)
NameTypeDescription
valuestringthe value of the CC field

Example

       mail.cc("receiver@domain.com");

See Also

Groups [ Mail ]
Entries [ Mail.addHeader() | Mail.removeHeader() ]

Mail.from() Mail

Summary

Set the From header of the message.

Syntax

       from(value)
NameTypeDescription
valuestringthe value of the From field

Example

       mail.from("sender@domain.com");

See Also

Groups [ Mail ]
Entries [ Mail.addHeader() | Mail.removeHeader() ]

Mail.host() Mail

Summary

Sets a SMTP (remote) host to contacted by Net::SMTP.

Syntax

       host(hostname)
NameTypeDescription
hostnamestringSMTP host

Example

       mail.host('mail.domain.com');

Notes

The default value is 'localhost'.

Make sure the specified host relay for your 'From' domain.

See Also

Groups [ Mail ]
Entries [ Mail ]

Mail.mailer() Mail

Summary

Sets a mailer program the formatted message is passed to.

Syntax

       mailer(program)
NameTypeDescription
programstringmailer program name

Example

       mail.mailer('/usr/sbin/sendmail');

Notes

The default value is '/usr/sbin/sendmail'.

Use mail.mailer('') to send mails via Net::SMTP explicitly.

See Also

Groups [ Mail ]
Entries [ Mail ]

Mail.removeBody() Mail

Summary

Removes all text from the message body.

Syntax

       removeBody()

Example

       mail.removeBody();

See Also

Groups [ Mail ]
Entries [ Mail.addBody() | Mail.send() ]

Mail.removeHeader() Mail

Summary

Removes the specified header of the message.

Syntax

       removeHeader(field)
NameTypeDescription
fieldstringthe specified field

Example

       mail.removeHeader("Content-type");

See Also

Groups [ Mail ]
Entries [ Mail.addHeader() ]

Mail.send() Mail

Summary

Sends a message formatted by other methods of this object.

Syntax

       send(txt)
NameTypeDescription
textstringmessage text

Example

       mail.send("This mail is generated by Charlie");

Notes

The string passed to this method is appended to other body text inserted with Mail.addBody() method before. The addBody method can be omitted at all for short messages.

See Also

Groups [ Mail ]
Entries [ Mail.addBody() | Mail.addBody() | Mail.addHeader() | Mail.bcc() | Mail.cc() | Mail.from() | Mail.subject() | Mail.to() ]

Mail.subject() Mail

Summary

Set the Subject header of the message.

Syntax

       subject(value)
NameTypeDescription
valuestringthe value of the Subject field

Example

       mail.subject("Good News");

See Also

Groups [ Mail ]
Entries [ Mail.addHeader() | Mail.removeHeader() ]

Mail.to() Mail

Summary

Set the To header of the message.

Syntax

       to(value)
NameTypeDescription
valuestringthe value of the To field

Example

       mail.to("receiver@domain.com");

See Also

Groups [ Mail ]
Entries [ Mail.addHeader() | Mail.removeHeader() ]

MessagePart MessagePart

Summary

This object represents part of MultipartMessage.

Syntax

       new MessagePart();

Description

MessagePart represents a part of a MultipartMessage. Since MultipartMessage represents a MIME message, MessagePart represents a part of such a message. As such, the object consists of a set of headers and a body.

For manipulation with headers, use MessagePart.header() method.

MessagePart body is controlled by MessagePart.write(), MessagePart.read() and MessagePart.value() methods. Size of stored data can be get by MessagePart.size().

Internally, data are stored in a structure similar to RawContent object, see its reference for understanding read and write methods. As in the case of RawContent, data are stored in memory or in a temporary file. Object is transparent in this respect. You can read name of temporary file using MessagePart.storageFilename() method, but there is no way how to control storage in a way similar to RawContent.memoryLimit().

See Also

Groups [ MessagePart ]
Entries [ MessagePart.header() | MessagePart.read() | MessagePart.size() | MessagePart.storageFilename() | MessagePart.value() | MessagePart.write() | MultipartMessage | RawContent | RawContent.memoryLimit() ]

MessagePart.header() MessagePart

Summary

Get/set message part header.

Syntax

       header(name, [value])
NameTypeDescription
namestringname of the accessed MessagePart header
valuestringthe new value of the MessagePart header - optional

Description

MessagePart has its own set of headers. Typically, they include Content-type for MIME type of stored data. According to MIME specification (RFC 1521) default value for this header is "text/plain; charset=us-ascii". Header names are case-insensitive.

Use MessagePart.header() method to set, alter or read header values.

Example

       var mp = new MessagePart();
       mp.header("Content-Type") = "text/plain; charset=utf-8";
       .....
       or
       .....
       var mm = request.parsedContent();  // request posted a MIME data
       var mp = mm.getPart(1);            
       var ct1 = mp.header("Content-Type");
       if (ct1 == "image/jpeg") {    .....

See Also

Groups [ MessagePart ]
Entries [ MessagePart ]

MessagePart.read() MessagePart

Summary

Reads data stored in object body.

Syntax

       read([size])
NameTypeDescription
sizenumber [bytes]size of buffer to be read out - optional

Description

Usage of this method is similar to that of RawContent.read(), except there is no equivalent of RawContent.resetRead() here. To get all body data, use MessagePart.value() method.

Example

       var mm = request.parsedContent();  // request posted a MIME data
       var mp = mm.getPart(1);            
       var buff = mp.read(1024);
       while (buff) {
            // do something with the buffer
            buff = mp.read(1024);
       };
       ...
       or
       ...
       var data = mp.read(); // the same as mp.value();

See Also

Groups [ MessagePart ]
Entries [ MessagePart.value() | RawContent.read() | RawContent.resetRead() ]

MessagePart.size() MessagePart

Summary

Returns actual size of message part body size.

Syntax

       size()

Description

Returns actual size of message part body size, i.e. without size of string representation of headers.

Example

       var mm = request.parsedContent();  // request posted a MIME data
       var mp = mm.getPart(1);            
       var dataSize = mp.size();

See Also

Groups [ MessagePart ]

MessagePart.storageFilename() MessagePart

Summary

Name of temporary file that contains object body.

Syntax

       storageFilename();
NameTypeDescription
ctstringthe new value of the MessagePart content type - optional

Description

For big data (bigger than 4096 bytes), a temporary file is created (see MessagePart.write() for details). This method returns name of such a file.

Example

       var mm = request.parsedContent();  // request posted a MIME data
       var mp = mm.getPart(1);            
       var fileName = mp.storageFilename();

See Also

Groups [ MessagePart ]
Entries [ MessagePart.write() ]

MessagePart.toString() MessagePart

Summary

Returns string representation of the object.

Syntax

       toString()

Description

String representation of a MessagePart consists of headers and body, formated according to MIME specification (RFC 1521).

Example

       var mm = request.parsedContent();  // request posted a MIME data
       var mp = mm.getPart(1);         
       // returning message part as plain string for debugging purposes
       response.content(mp.toString());

See Also

Groups [ MessagePart ]
Entries [ MessagePart ]

MessagePart.value() MessagePart

Summary

Read body of the object.

Syntax

       value()

Description

See MessagePart.read().

Example

       var mm = request.parsedContent();  // request posted a MIME data
       var mp = mm.getPart(1);            
       var data = mp.value(); // the same as mp.read();

See Also

Groups [ MessagePart ]
Entries [ MessagePart.read() ]

MessagePart.write() MessagePart

Summary

Adds data to end of objects body.

Syntax

       write(data)
NameTypeDescription
datastringdata to be added to end of message part body

Description

This method is used in the same way as RawContent.write() method, except that there is no way how to control actual data storage; memory limit is fixed to 4096 bytes (see RawContent.memoryLimit too).

Example

       var mp = new MessagePart();
       mp.header("Content-Type") = "text/plain; charset=utf-8";
       mp.write("HELLO UNICODE WORLD\n");

See Also

Groups [ MessagePart ]
Entries [ RawContent.write() ]

MultipartFormData MultipartFormData

Summary

MultipartFormData is a wrapper of POSTed "multipart/form-data" encrypted HTML form.

Description

The MultipartFormData is return value of Request.parsedContent() in the case of POSTed "multipart/form-data" encrypted HTML form. This form setting is used for files upload.

Technically, it is a special case of MultipartMessage object. The object has only three methods. All of them interfaces access to the posted form fields: MultipartFormData.field(), MultipartFormData.fieldIdx() and MultipartFormData.count().

Example

       // action responds to a POSTED multipart/form-data form
       my mfd = request.parsedContent();

See Also

Groups [ MultipartFormData ]
Entries [ MultipartFormData.count() | MultipartFormData.field() | MultipartFormData.fieldIdx() | MultipartMessage | Request.parsedContent() ]

MultipartFormData.count() MultipartFormData

Summary

Number of form fields.

Syntax

       count();

Example

       // action responds to a POSTED multipart/form-data form
       var mfd = request.parsedContent();
       for (i=0; i < 0; i++) {
            var field = mfd.fieldIdx(i);
            ....
       };

See Also

Groups [ MultipartFormData ]

MultipartFormData.field() MultipartFormData

Summary

Gets form field by name.

Syntax

       field(name)
NameTypeDescription
namestringname of the accessed field

Description

This method returns fields by their names.

Note, that when a form has more than one field with the same name, only first of these fields is returned with this method. To access all of these fields, use MultipartFormData.fieldIdx() method.

Returned object is of FormData type.

Example

       // action responds to a POSTED multipart/form-data form
       var mfd = request.parsedContent();
       var file = mfd.field("file1");

See Also

Groups [ MultipartFormData ]
Entries [ FormData | MultipartFormData.fieldIdx() ]

MultipartFormData.fieldIdx() MultipartFormData

Summary

Gets form field by the part index.

Syntax

       fieldIdx(index);
NameTypeDescription
indexnumber [0, ..]accessed field index, indexing starts from 0

Description

It is sometimes useful access form fields not by their names, but by their index, e.g. when a HTML form contains more than one field with the same name. This method servers such a task.

Indexing starts by 0. Overall fields count is provided by MultipartFormData.count() method. Returned object is of FormData type.

See also MultipartMessage.getPart(), which is implemented in the same way.

Example

       // action responds to a POSTED multipart/form-data form
       var mfd = request.parsedContent();
       for (i=0; i < 0; i++) {
            var field = mfd.fieldIdx(i);
            ....
       };

See Also

Groups [ MultipartFormData ]
Entries [ FormData | MultipartFormData.count() | MultipartMessage.getPart() ]

MultipartMessage MultipartMessage

Summary

This object represents MIME message as defined by RFC 1521.

Syntax

       new MultipartMessage();

Description

MultipartMessage is an interface to MIME message. There are two ways how this object appears in Charlie actions:

* it can be returned as Request.parsedContent() or Response.parsedContent(). See documentation of these two methods for details.
* you can create it by calling its constructor (see syntax).

MIME message consists of set of headers and multipart body.

Headers are manipulated by MultipartMessage.header(), MultipartMessage.contentType() and MultipartMessage.boundary() methods.

Particular body parts are represented by MessagePart objects. They can be added by MultipartMessage.addPart() method and accessed by MultipartMessage.getPart() method. MultipartMessage.count() gets message parts count.

In addition, you can use MultipartMessage.size() to get overall size of the object data and MultipartMessage.toString() method to get its string representation.

The MultipartMessage object itself is used by Response and Request objects to hold structured data (both accepted or prepared for delivery). See Request.parsedContent() or Response.parsedContent() methods for details.

See Also

Groups [ MultipartMessage ]
Entries [ MessagePart | MultipartMessage.addPart() | MultipartMessage.boundary() | MultipartMessage.contentType() | MultipartMessage.count() | MultipartMessage.getPart() | MultipartMessage.header() | MultipartMessage.size() | MultipartMessage.toString() | Request | Request.parsedContent() | Request.parsedContent() | Response | Response.parsedContent() | Response.parsedContent() ]

MultipartMessage.addPart() MultipartMessage

Summary

Adds a new part to the multipart object.

Syntax

       addPart(value);
NameTypeDescription
valueMessagePartmessage part to be added

Description

Use this method to add a new part (object of MessagePart type) to multipart message.

Example

       var mm = new MultipartMessage();
       var mp = new MessagePart();
       mp.write("HELLO WORLD");
       ....
       mm.addPart(mp);

See Also

Groups [ MultipartMessage ]
Entries [ MessagePart ]

MultipartMessage.boundary() MultipartMessage

Summary

Get/set MIME boundary.

Syntax

       boundary([value])
NameTypeDescription
valuestringnew value of MIME boundary - optional

Description

Particular MultipartMessage parts are detached by a boundary (see RFC 1521 for details).

Boundary is defined as part of message content type header (see MultipartMessage.contentType(), MultipartMessage.header()). Using this method, you can get or change boundary used in the object. It is not necessary to set boundary manually, object constructor generates a random boundary itself upon object creation.

Example

       var mm = new MultipartMessage();
       mm.boundary("my_superunique_boundary");
       .....
       or
       .....
       var mm = request.ParsedContent();
       var bnd = mm.boundary();

See Also

Groups [ MultipartMessage ]
Entries [ MultipartMessage | MultipartMessage.contentType() | MultipartMessage.header() ]

MultipartMessage.contentType() MultipartMessage

Summary

Get/set object content type.

Syntax

       contentType([value])
NameTypeDescription
valuestringnew content type, must contain boundary definition - optional

Description

Use this method to get or change multipart message content type. Multipart message content type is set to
"multipart/mixed; boundary="RandomUniqueBoundary"
by defaults.

When setting a content type, you must supply a boundary definition as part of it! Otherwise, the object couldn't be serialized. Also, if you specify different that "multipart" MIME type, other party may not work with the data properly. See also MultipartMessage.boundary()

For general unstructured data use RawContent object.

Example

       var mm = new MultipartMessage();
       mm.contentType("multipart/x-special; boundary=\"" + mm.boundary() + "\"");

See Also

Groups [ MultipartMessage ]
Entries [ MultipartMessage.boundary() | RawContent ]

MultipartMessage.count() MultipartMessage

Summary

Number of message parts that constitute the multipart message.

Syntax

       count()

Description

Function gets number of message parts that constitute the multipart message. To get a particular message part, use MultipartMessage.getPart().

Example

       var mm = request.parsedContent();
       for (i=0; i < mm.count(); i++) {
             var part = mm.getPart(i);      
             // do something with the part
       };

See Also

Groups [ MultipartMessage ]
Entries [ MultipartMessage.getPart() ]

MultipartMessage.getPart() MultipartMessage

Summary

Gets a part of multipart message.

Syntax

       getPart(index)
NameTypeDescription
indexnumber [0, ..]part index, indexing starts from 0

Description

Message parts are stored in an array and are accessible be their indexes that correspond to adding order. Parts indexing starts from 0.

Example

       var mm = request.parsedContent();
       var firstPart = mm.getPart(0);

See Also

Groups [ MultipartMessage ]

MultipartMessage.header() MultipartMessage

Summary

Get/set multipart message header.

Syntax

       header(name, [value])
NameTypeDescription
namestringname of the accessed header field
valuestringnew value of the accessed header field - optional

Description

Using this method, you can get or change a multipart message header. When a multipart message is provided as a Request or Response parsed content, its headers are synchronized with its provider. The synchronization occurs upon parsing the incoming or departing the outgoing Request or Response.

Special care has to be taken to "content type" header; see MultipartMessage.contentType() reference for details.

By default, a new multipart message has set
Content-Type header to "multipart/mixed; boundary="RandomUniqueBoundary" and
Content-Transfer-Encoding header to "binary".

Header names are case-insensitive.

Example

       var mm = request.parsedContent();
       var xh = mm.header("X-Super-Header");

See Also

Groups [ MultipartMessage ]
Entries [ MultipartMessage.contentType() | Request | Response ]

MultipartMessage.size() MultipartMessage

Summary

Gets overall size of the multipart message.

Syntax

       size();

Description

This function gets overall size of the multipart message, excluding global headers length, but including headers length of message parts and length of boundaries that borders message parts and, of course, sizes of message part bodies.

Compare with MessagePart.size().

Example

       var mm = request.parsedContent();
       var s = mm.size();

See Also

Groups [ MultipartMessage ]
Entries [ MessagePart.size() ]

MultipartMessage.toString() MultipartMessage

Summary

Gets string representation of the object.

Syntax

       toString();

Description

Use this function to get string representation of the multipart message for debug purposes. This function returns the message content in the same manner as MultipartMessage.size() uses it to compute message size.

Do not use this method when feeding Request or Response objects with content method; use parsedContent() method there to get optimal performance and headers synchronization.

Example

       var mm = request.parsedContent();
       // custom method log_it stored its parameter to debug log
       log_it(mm.toString());

See Also

Groups [ MultipartMessage ]
Entries [ MultipartMessage.size() | Request | Response ]

Node Node

Summary

General node object. Used as an ancestor for all node types.

Syntax

       Node(handle)
NameTypeDescription
handlePerlValuethe internal perl handle of the node

Example

       node = new Node(handle);

Notes

Never use this contstructor directly! Use the factory methods of the DOMDocument object.

See Also

Groups [ Node ]
Entries [ DOMDocument ]

Node.appendChild() Node

Summary

Append the node to the list of children of the node.

Syntax

       appendChild(newnode)
NameTypeDescription
newnodeNodethe new (appended) node

Example

       root = doc.createElement("root");
       doc.appendChild(root);

See Also

Groups [ Node ]
Entries [ Node | Node.insertBefore() ]

Node.equals() Node

Summary

Test whether then node is equal to other one (represents exactly the same node).

Syntax

       equals(other)
NameTypeDescription
otherNodethe node to be compared to

Example

       //test whether node is the root node
       node.equals(doc.getFirstChild());

See Also

Groups [ Node ]
Entries [ Node ]

Node.getFirstChild() Node

Summary

Get the forst child of the node.

Syntax

       getFirstChild

Example

       child = node.getFirstChild();

See Also

Groups [