Difference between revisions of "MimeEntity"

From Fernseher
Jump to navigationJump to search
(New page: MimeEntity represents a standard MIME/HTTP entity, including headers and body. For Modjs, there is a MimeEntity in MailMessages, HTTPRequests, and HTTPResponses, including the req...)
 
Line 23: Line 23:
  string = entity.getBoundaryString(last?)
  string = entity.getBoundaryString(last?)
  entity.addHeader(MimeHeader | array of MimeHeader)
  entity.addHeader(MimeHeader | array of MimeHeader)
string = entity.getHeader(name)
entity.setHeader(name, value)
  entity.clearBody()
  entity.clearBody()
  entity.setBody(string)
  entity.setBody(string)

Revision as of 17:49, 22 January 2009

MimeEntity represents a standard MIME/HTTP entity, including headers and body. For Modjs, there is a MimeEntity in MailMessages, HTTPRequests, and HTTPResponses, including the request that brought about the modjs script invocation, and the response that will be sent back.

MimeEntitys can be created manually with:

entity = new MimeEntity(array of MimeHeaders, body)

If this doesn't work for some reason, it could throw

MimeEntityException

Each MimeEntity has the following properties, which may be queried, but really shouldn't be edited directly.

  • headers: the array of MimeHeaders for this entity
  • body: the raw body of this entity
  • type: the major content type of this entity
  • subtype: the subtype of this entity
  • id: the content-id of this entity, if it has one
  • boundary: the boundary string of this entity
  • children: an array of MimeEntities representing the children of this entity, in the multipart and message types
  • leader: In a multipart or message entity, the part of the body before the first boundary
  • trailer: In a multipart or message entity, the part of the body after the last boundary

The entity also has the following methods, which should be the primary method of modifying the entity if needed.

string = entity.toString()
string = entity.getContentType()
string = entity.getBoundaryString(last?)
entity.addHeader(MimeHeader | array of MimeHeader)
string = entity.getHeader(name)
entity.setHeader(name, value)
entity.clearBody()
entity.setBody(string)
entity.addToBody(string)
entity.addMessageEntity(MimeEntity)
entity.addMultipartEntity(MimeEntity | array of MimeEntitys)
MimeEntity = entity.removeChildEntity(index)
MimeEntity = entity.getChildEntity(index)
MimeEntity = entity.getChildEntityById(id)