Difference between revisions of "MimeHeader"

From Fernseher
Jump to navigationJump to search
 
Line 43: Line 43:
  string = header.toString()
  string = header.toString()
  string = header.getValue(value name)
  string = header.getValue(value name)
string = header.getAllValues()


The value has these properties:
The value has these properties:

Latest revision as of 22:12, 22 January 2009

A MimeHeader object represents a single header in a MIME or HTTP message in a easier to use format for Modjs scripts. Each header can have an array of MimeValue objects, which can have an array of MimeProperties. The true format of these are described in MIME.

To paraphrase, a true MIME header is a name:value[,value...] pair of form:

header          := header-name  ':'  header-value  CRLF
header-value    := values
values          := (value-exp  ',')*  value-exp

Each value is of form:

value-exp       := real-value  (';'  property-exp)*
real-value      := value-key ['=' value-value]

And each property then is of form:

property-exp    := property-key  ['='  property-value]

A new MimeHeader can be created using:

header = new MimeHeader(name, array of MimeValue objects)
header = new MimeHeader(name, raw value string)

If the header cannot be created (if the objects passed in aren't duckable to MimeValue, or the string isn't valid header value formatted), an exception can be thrown:

MimeHeaderException

A new MimeValue can be created using:

value = new MimeValue(raw value, array of MimeParameters)
value = new MimeValue(value name, value content, array of MimeParameters)
value = new MimeValue(raw value string)

These could throw:

MimeValueException

A new MimeProperty can be created using:

property = new MimeProperty(property name, property value)

Once a header is created, it has these properties:

  • name: The header name
  • values: array of MimeValue objects

The header has several methods:

string = header.getName()
array of MimeValues = header.getValueList()
header.addValue(MimeValue)
MimeValue = header.removeValue(index)
MimeValue = header.getValue(index)
string = header.toString()
string = header.getValue(value name)
string = header.getAllValues()

The value has these properties:

  • value: The value name, or "true" value
  • content: the value content
  • properties: array of parameter name/value pairs

And these methods:

string = value.getValueName()
string = value.getValueContent()
string = value.getValue()
value.setValueContent(string)
array of MimeParameters = value.getPropertyList()
value.addParameter(MimeParameter)
MimeParameter = value.removeParameter(index)
MimeParameter = value.getParameter(index)
string = value.toString()
string = value.getParameter(parameter name)

MimeParameters have these properties:

  • name: the parameter name
  • value: the parameter value

And these methods:

string = parm.getName()
string = parm.getValue()
parm.setValue(string)
string = parm.toString()