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...)
 
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
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.
MimeEntity represents a standard [[MIME]]/HTTP entity, including headers and body.  For [[Modjs]], there is a MimeEntity in [[MailMessage]]s, [[HTTPRequest]]s, and [[HTTPResponse]]s, including the request that brought about the modjs script invocation, and the response that will be sent back.


MimeEntitys can be created manually with:
MimeEntitys can be created manually with:
  entity = new MimeEntity(array of MimeHeaders, body)
  entity = new MimeEntity(array of [[MimeHeader]]s, body)


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


Each MimeEntity has the following properties, which may be queried, but really shouldn't be edited directly.
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
*headers: the array of [[MimeHeader]]s for this entity
*body: the raw body of this entity
*body: the raw body of this entity
*type: the major content type of this entity
*type: the major content type of this entity
Line 22: Line 22:
  string = entity.getContentType()
  string = entity.getContentType()
  string = entity.getBoundaryString(last?)
  string = entity.getBoundaryString(last?)
  entity.addHeader(MimeHeader | array of MimeHeader)
  entity.addHeader([[MimeHeader]] | array of [[MimeHeader]]s)
*adds the given headers, even if they already exist
array of [[MimeHeader]]s = entity.getHeader(name)
*gets all headers of the given name
string = entity.getHeaderValue(name)
*gets the value string (raw) of the first header with the given name
entity.setHeader(name, value)
*changes the raw value string of the first header with the given name
  entity.clearBody()
  entity.clearBody()
  entity.setBody(string)
  entity.setBody(string)

Latest revision as of 22:11, 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 MimeHeaders)
  • adds the given headers, even if they already exist
array of MimeHeaders = entity.getHeader(name)
  • gets all headers of the given name
string = entity.getHeaderValue(name)
  • gets the value string (raw) of the first header with the given name
entity.setHeader(name, value)
  • changes the raw value string of the first header with the given name
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)