The Header class models an RFC 2822 or MIME header.
Essentially, it's a container for HeaderField objects which can check whether its contents make sense and are legal (see RFC 2822 page 19), and will give them to callers on demand.
Fields are available by calling field() with the right type. This works well for some fields, but fields which can occur several times have a problem. Will have to solve that eventually.
Some fields are also available as values, e.g. date().
Constructs an empty Header in m mode. If m is Rfc2822, the header's validity will follow RFC 2822 rules, while if m is Mime, RFC 2045-2049 rules are used.
Appends the HeaderField hf to this Header.
If the HeaderField::position() is -1, add() sets it one higher than that of the last HeaderField. This tends to make it unique and larger than all others, but it may not be unique. Unfortunately guaranteeing uniqueness is O(n).
Creates a header field with the supplied name and value, and appends it to this Header, adjusting validity as necessary.
Returns a pointer to the address field of type t at index n in this header, or a null pointer if no such field exists.
Returns a pointer to the addresses in the t header field, which must be an address field such as From or Bcc. If not, or if the field is empty, addresses() returns a null pointer.
Appends the string representation of the field hf to r. Does nothing if hf is 0.
This function doesn't wrap. That's probably a bug. How to fix it?
(The details of the function are liable to change.)
Returns the canonical text representation of this Header.
Returns the value of the Content-Description field, or an empty string if there isn't one. RFC 2047 encoding is not considered - should it be?
Returns a pointer to the Content-Disposition header field, or a null pointer if there isn't one.
Returns a pointer to the Content-Language header field, or a null pointer if there isn't one.
Returns the value of the Content-Location field, or an empty string if there isn't one. The URI is not validated in any way.
Returns a pointer to the Content-Transfer-Encoding header field, or a null pointer if there isn't one.
Returns a pointer to the Content-Type header field, or a null pointer if there isn't one.
Returns the header's data t, which is the normal date by default, but can also be orig-date or resent-date. If there is no such field or t is meaningless, date() returns a null pointer.
Returns whatever was set using setDefaultType(), or TextPlain if setDefaultType() hasn't been called.
Returns a one-line error message describing the first error detected in this Header, or an empty string if there is no error.
Returns a pointer to the header field with type t and index n, or a null pointer if there is no such field in this header.
if n is 0, as it is by default, the first field with type t is returned. 1 refers to the second.
Returns a pointer to the header field with type Other, name h and index n, or a null pointer if there is no such field in this header.
If n is 0, as it is by default, the first field with the desired name is returned, 1 refers to the second, and so on.
Returns a pointer to a list containing all the HeaderField objects in this Header. Neither the list nor the HeaderField objects it in may be modified or freed by the caller - Header keeps other pointers to these objects.
The return value may point to an empty list, but can not be a null pointer.
Scans for fields containing unlabelled 8-bit content and encodes them using c.
At the moment, this covers most unstructured fields. The exact scope of the function may change.
Returns the header's in-reply-to value. This comes straight from the RFC 2822 representation.
Returns the header's message-id t, which is the normal message-id by default but can also be the first resent-message-id or the content-id. The returned string is in the cleanest possible form. If there is no such message-id, messageId() returns an empty string.
Returns the header's mode, either Mime or Rfc2822, which is set using the constructor and decides whether a particular header is valid. For example, in Rfc2822 mode a Date field is mandatory, while in Mime mode it's not allowed.
Removes all fields with type t from the header.
Removes all fields named n from this header.
Works only if n is header-cased (ie. this function is case-sensitive).
Repairs a few harmless and common problems, such as inserting two Date fields with the same value. Assumes that p is its companion body (whose text is in body), and may look at it to decide what/how to repair.
Repairs problems that can be repaired without knowing the associated bodypart.
Notifies this Header that if no ContentType is set, its default type is t. The initial value is TextPlain.
Removes any redundant header fields from this header, and simplifies the value of some.
For example, if 'sender' or 'reply-to' points to the same address as 'from', that field can be removed, and if 'from' contains the same address twice, one can be removed.
Returns the header's subject. For the moment, this is a simple string. It'll have to morph soon, to handle RFC 2047 at least.
Returns true if this Header fills all the conditions laid out in RFC 2821 for validity, and false if not.
This private function verifies that the entire header is consistent and legal, and that each contained HeaderField is legal.
This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.