| ||
SummaryThis object is used for error propagation from actions. | ||
SyntaxCharlieException() | ||
Exampleex = new CharlieException(); ex.code = 1234; ex.msg = "bad event"; throw ex; | ||
NotesSet different properties to see them in the report log. | ||
See Also
|
| ||||||
SummaryThis 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 theNode object.
| ||||||
Syntaxnew DOMDocument([handle])
| ||||||
Example doc = new DOMDocument();
root = doc.createElement("root");
doc.appendChild(root);
| ||||||
See Also
|
| ||||||
Summaryset.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. | ||||||
Syntaxautodispose([flag])
| ||||||
Exampledoc.autodispose(0); | ||||||
NotesYou usually don't need change the default value. | ||||||
See Also
|
| |||||||||
SummaryClone givenNode and set itself as the owning document. Deep
copy is supported.
| |||||||||
SyntaxcloneNode(node, deep)
| |||||||||
Exampleroot = doc1.cloneNode(doc2.getFirstChild()); doc1.appendChild(root); //copy the whole document | |||||||||
See Also
|
| ||||||
SummaryCreate new CDATA section node. It works exactly likeDOMDocument.createTextNode(); the only difference is
serialization of this node.
| ||||||
SyntaxcreateCDATASection(value)
| ||||||
Example doc.createCDATASection("my data");
| ||||||
See Also
|
| ||||||
SummaryCreate new comment node. | ||||||
SyntaxcreateComment(value)
| ||||||
Example doc.createComment("the reason is this and that");
| ||||||
See Also
|
| ||||||
SummaryCreate newElement of given name.
| ||||||
SyntaxcreateElement(name)
| ||||||
Example e = doc.createElement("book");
| ||||||
See Also
|
| |||||||||
SummaryCreate new processing instruction node. | |||||||||
SyntaxcreateProcessingInstruction(target, data)
| |||||||||
Example doc.createProcessingInstruction("myapp", "mydata");
| |||||||||
See Also
|
| ||||||
SummaryCreate new text node of given content. | ||||||
SyntaxcreateTextNode(value)
| ||||||
Example doc.createTextNode("my data");
| ||||||
See Also
|
| ||||
SummarySerialize the document. | ||||
SyntaxdocToString() | ||||
Examplestr = doc.docToString(); | ||||
NotesMany functions accepting the XML documents as a parameter accept the DOMDocument directly. | ||||
See Also
|
| ||||
SummaryFree the document immediately. | ||||
SyntaxfreeDocument() | ||||
Exampledoc.freeDocument(); | ||||
NotesDo it for HUGE documents only to. All documents are disposed at the end of the action by default. | ||||
See Also
|
| ||||||
SummaryObject for element node representation. Extends theNode
object, adds some attribute handling methods.
| ||||||
SyntaxElement(handle)
| ||||||
Exampleelement = new Element(handle); | ||||||
NotesNever use this contstructor directly! Use the factory methods of theDOMDocument object.
| ||||||
See Also
|
| ||||||
SummaryGet the value of the specified attribute. | ||||||
SyntaxgetAttribute(name)
| ||||||
Example value = element.getAttribute("href");
| ||||||
See Also
|
| ||||||
SummaryRemove the specified attribute the element. | ||||||
SyntaxremoveAttribute(name)
| ||||||
Example element.removeAttribute("href");
| ||||||
See Also
|
| |||||||||
SummarySet the attribute of the element node. | |||||||||
SyntaxsetAttribute(name, value)
| |||||||||
Example element.setAttribute("href", "mydoc.xml");
| |||||||||
See Also
|
| ||||
SummaryThis object represents a part ofMultipartFormData.
| ||||
DescriptionThis object represents a part ofMultipartFormData. 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.
Field metadata details can be accessed using
Field value can be read out by
Big data (like big uploaded file) manipulation can be easier with knowing of | ||||
See Also
|
| ||||
SummaryGets name of uploaded file. | ||||
Syntaxfilename() | ||||
DescriptionMultipart/form-data form is used for files uploading. WhenFormData 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
|
| ||||||
SummaryGets field header value. | ||||||
Syntaxheader(name);
| ||||||
DescriptionRead-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
|
| ||
SummaryGets field name. | ||
Syntaxname(); | ||
DescriptionMultipart/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
|
| ||||||
SummaryReads part of field data. | ||||||
Syntaxread([size])
| ||||||
DescriptionSeeMessagePart.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
|
| ||
SummaryGets size of data in the field. | ||
Syntaxsize(); | ||
DescriptionGets 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
|
| ||||
SummaryGets name of the temporary file used to store field data. | ||||
SyntaxstorageFilename(); | ||||
DescriptionSee discussions toRawContent.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
|
| ||||
SummaryGets field value. | ||||
Syntaxvalue(); | ||||
DescriptionSeeMessagePart.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
|
| ||||
SummaryActions, short JavaScript programs launched as a response to an incoming request are basic building stones of Charlie mosaic. | ||||
DescriptionIn 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. | ||||
NotesThe standard objects are:RequestResponseURIQuerySablotronDOMDocumentElementNodeMailRawContentMultipartMessage, MessagePartMultipartFormData, FormData | ||||
See Also
|
|
| ||||
SummaryE-mail sender object representation. | ||||
SyntaxMail() | ||||
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");
| ||||
NotesThe underlaying code attempts to send a message using a mailer deamon (sendmail by default, seeMail.mailer()). If not successful, it
looks for Net::SMTP perl module (see Mail.host()). If still not
successful, an error is issued.
| ||||
See Also
|
| ||||||
SummaryAdd a line of text to the message to be send. | ||||||
SyntaxaddBody(txt)
| ||||||
Example mail.addBody("This mail is generated by Charlie");
| ||||||
NotesStrings added with addBody method will be separated by a newline character. | ||||||
See Also
|
| |||||||||
SummarySet the specified header of the message. | |||||||||
SyntaxaddHeader(field, value)
| |||||||||
Example mail.addHeader("Content-type","text/plain; charset=UTF-8");
| |||||||||
NotesThere are shortcuts defined for the most common headers (From, Subject, To, Cc, Bcc) | |||||||||
See Also
|
| ||||||
SummarySet the Bcc header of the message. | ||||||
Syntaxbcc(value)
| ||||||
Example mail.bcc("receiver@domain.com");
| ||||||
See Also
|
| ||||||
SummarySet the CC header of the message. | ||||||
Syntaxcc(value)
| ||||||
Example mail.cc("receiver@domain.com");
| ||||||
See Also
|
| ||||||
SummarySet the From header of the message. | ||||||
Syntaxfrom(value)
| ||||||
Example mail.from("sender@domain.com");
| ||||||
See Also
|
| ||||||
SummarySets a SMTP (remote) host to contacted by Net::SMTP. | ||||||
Syntaxhost(hostname)
| ||||||
Example mail.host('mail.domain.com');
| ||||||
NotesThe default value is 'localhost'.Make sure the specified host relay for your 'From' domain. | ||||||
See Also
|
| ||||||
SummarySets a mailer program the formatted message is passed to. | ||||||
Syntaxmailer(program)
| ||||||
Example mail.mailer('/usr/sbin/sendmail');
| ||||||
NotesThe default value is '/usr/sbin/sendmail'.Use mail.mailer('') to send mails via Net::SMTP explicitly. | ||||||
See Also
|
| ||||
SummaryRemoves all text from the message body. | ||||
SyntaxremoveBody() | ||||
Examplemail.removeBody(); | ||||
See Also
|
| ||||||
SummaryRemoves the specified header of the message. | ||||||
SyntaxremoveHeader(field)
| ||||||
Example mail.removeHeader("Content-type");
| ||||||
See Also
|
| ||||||
SummarySends a message formatted by other methods of this object. | ||||||
Syntaxsend(txt)
| ||||||
Example mail.send("This mail is generated by Charlie");
| ||||||
NotesThe string passed to this method is appended to other body text inserted withMail.addBody() method before. The
addBody method can be omitted at all for short messages.
| ||||||
See Also
|
| ||||||
SummarySet the Subject header of the message. | ||||||
Syntaxsubject(value)
| ||||||
Example mail.subject("Good News");
| ||||||
See Also
|
| ||||||
SummarySet the To header of the message. | ||||||
Syntaxto(value)
| ||||||
Example mail.to("receiver@domain.com");
| ||||||
See Also
|
| ||||
SummaryThis object represents part ofMultipartMessage.
| ||||
Syntaxnew MessagePart(); | ||||
DescriptionMessagePart 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
Internally, data are stored in a structure similar to | ||||
See Also
|
| |||||||||
SummaryGet/set message part header. | |||||||||
Syntaxheader(name, [value])
| |||||||||
DescriptionMessagePart 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
| |||||||||
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
|
| ||||||
SummaryReads data stored in object body. | ||||||
Syntaxread([size])
| ||||||
DescriptionUsage of this method is similar to that ofRawContent.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
|
| ||
SummaryReturns actual size of message part body size. | ||
Syntaxsize() | ||
DescriptionReturns actual size of message part body size, i.e. without size of string representation of headers. | ||
Examplevar mm = request.parsedContent(); // request posted a MIME data var mp = mm.getPart(1); var dataSize = mp.size(); | ||
See Also
|
| ||||||
SummaryName of temporary file that contains object body. | ||||||
SyntaxstorageFilename();
| ||||||
DescriptionFor big data (bigger than 4096 bytes), a temporary file is created (seeMessagePart.write() for details). This method returns name of such a file.
| ||||||
Examplevar mm = request.parsedContent(); // request posted a MIME data var mp = mm.getPart(1); var fileName = mp.storageFilename(); | ||||||
See Also
|
| ||||
SummaryReturns string representation of the object. | ||||
SyntaxtoString() | ||||
DescriptionString representation of aMessagePart consists of headers and body, formated according to MIME specification (RFC 1521).
| ||||
Examplevar 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
|
| ||||
SummaryRead body of the object. | ||||
Syntaxvalue() | ||||
DescriptionSeeMessagePart.read().
| ||||
Examplevar mm = request.parsedContent(); // request posted a MIME data var mp = mm.getPart(1); var data = mp.value(); // the same as mp.read(); | ||||
See Also
|
| ||||||
SummaryAdds data to end of objects body. | ||||||
Syntaxwrite(data)
| ||||||
DescriptionThis method is used in the same way asRawContent.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
|
| ||||
SummaryMultipartFormData is a wrapper of POSTed "multipart/form-data" encrypted HTML form. | ||||
DescriptionTheMultipartFormData 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
| ||||
Example// action responds to a POSTED multipart/form-data form my mfd = request.parsedContent(); | ||||
See Also
|
| ||
SummaryNumber of form fields. | ||
Syntaxcount(); | ||
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
|
| ||||||
SummaryGets form field by name. | ||||||
Syntaxfield(name)
| ||||||
DescriptionThis 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
Returned object is of | ||||||
Example // action responds to a POSTED multipart/form-data form
var mfd = request.parsedContent();
var file = mfd.field("file1");
| ||||||
See Also
|
| ||||||
SummaryGets form field by the part index. | ||||||
SyntaxfieldIdx(index);
| ||||||
DescriptionIt 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
See also | ||||||
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
|
| ||
SummaryThis object represents MIME message as defined by RFC 1521. | ||
Syntaxnew MultipartMessage(); | ||
DescriptionMultipartMessage is an interface to MIME message. There are two ways how this object appears in Charlie actions:
* it can be returned as MIME message consists of set of headers and multipart body.
Headers are manipulated by
Particular body parts are represented by
In addition, you can use
The | ||
See Also |
| ||||||
SummaryAdds a new part to the multipart object. | ||||||
SyntaxaddPart(value);
| ||||||
DescriptionUse this method to add a new part (object ofMessagePart type) to multipart message.
| ||||||
Example var mm = new MultipartMessage();
var mp = new MessagePart();
mp.write("HELLO WORLD");
....
mm.addPart(mp);
| ||||||
See Also
|
| ||||||
SummaryGet/set MIME boundary. | ||||||
Syntaxboundary([value])
| ||||||
DescriptionParticularMultipartMessage parts are detached by a boundary (see RFC 1521 for details).
Boundary is defined as part of message content type header (see
| ||||||
Example var mm = new MultipartMessage();
mm.boundary("my_superunique_boundary");
.....
or
.....
var mm = request.ParsedContent();
var bnd = mm.boundary();
| ||||||
See Also
|
| ||||||
SummaryGet/set object content type. | ||||||
SyntaxcontentType([value])
| ||||||
DescriptionUse 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
For general unstructured data use | ||||||
Example var mm = new MultipartMessage();
mm.contentType("multipart/x-special; boundary=\"" + mm.boundary() + "\"");
| ||||||
See Also
|
| ||||
SummaryNumber of message parts that constitute the multipart message. | ||||
Syntaxcount() | ||||
DescriptionFunction gets number of message parts that constitute the multipart message. To get a particular message part, useMultipartMessage.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
|
| ||||||
SummaryGets a part of multipart message. | ||||||
SyntaxgetPart(index)
| ||||||
DescriptionMessage parts are stored in an array and are accessible be their indexes that correspond to adding order. Parts indexing starts from 0. | ||||||
Examplevar mm = request.parsedContent(); var firstPart = mm.getPart(0); | ||||||
See Also
|
| |||||||||
SummaryGet/set multipart message header. | |||||||||
Syntaxheader(name, [value])
| |||||||||
DescriptionUsing this method, you can get or change a multipart message header. When a multipart message is provided as aRequest 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
By default, a new multipart message has set Header names are case-insensitive. | |||||||||
Example var mm = request.parsedContent();
var xh = mm.header("X-Super-Header");
| |||||||||
See Also
|
| ||||
SummaryGets overall size of the multipart message. | ||||
Syntaxsize(); | ||||
DescriptionThis 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 | ||||
Examplevar mm = request.parsedContent(); var s = mm.size(); | ||||
See Also
|
| ||||
SummaryGets string representation of the object. | ||||
SyntaxtoString(); | ||||
DescriptionUse this function to get string representation of the multipart message for debug purposes. This function returns the message content in the same manner asMultipartMessage.size() uses it to compute message size.
Do not use this method when feeding | ||||
Examplevar mm = request.parsedContent(); // custom method log_it stored its parameter to debug log log_it(mm.toString()); | ||||
See Also
|
| ||||||
SummaryGeneral node object. Used as an ancestor for all node types. | ||||||
SyntaxNode(handle)
| ||||||
Examplenode = new Node(handle); | ||||||
NotesNever use this contstructor directly! Use the factory methods of theDOMDocument object.
| ||||||
See Also
|
| ||||||
SummaryAppend the node to the list of children of the node. | ||||||
SyntaxappendChild(newnode)
| ||||||
Example root = doc.createElement("root");
doc.appendChild(root);
| ||||||
See Also
|
| ||||||
SummaryTest whether then node is equal to other one (represents exactly the same node). | ||||||
Syntaxequals(other)
| ||||||
Example//test whether node is the root node node.equals(doc.getFirstChild()); | ||||||
See Also
|
| ||
SummaryGet the forst child of the node. | ||
SyntaxgetFirstChild | ||
Examplechild = node.getFirstChild(); | ||
See Also
|