MIME Fields Always Belong to an Associated MIME HeaderΒΆ

When using Traffic Server, you cannot create a new MIME field without an associated MIME header or HTTP header; MIME fields are always seen as part of a MIME header or HTTP header.

To use a MIME field, you must specify the MIME header or HTTP header to which it belongs - this is called the field’s parent header. The TSMimeField* functions in older versions of the SDK have been deprecated, as they do not require the parent header as inputs. The current version of Traffic Server uses new functions, the ``TSMimeHdrField`` series, which require you to specify the location of the parent header along with the location of the MIME field. For every deprecated ``TSMimeField`` function, there is a new, preferred TSMimeHdrField* function. Therefore, you should use the ``TSMimeHdrField`` functions instead of the deprecated ``TSMimeField`` series. Examples are provided below.

Instead of:

TSMLoc TSMimeFieldCreate (TSMBuffer bufp)

You should use:

TSMLoc TSMimeHdrFieldCreate (TSMBuffer bufp, TSMLoc hdr)

Instead of:

void TSMimeFieldCopyValues (TSMBuffer dest_bufp, TSMLoc dest_offset,
   TSMBuffer src_bufp, TSMLoc src_offset)

You should use:

void TSMimeHdrFieldCopyValues (TSMBuffer dest_bufp, TSMLoc dest_hdr,
   TSMLoc dest_field, TSMBuffer src_bufp, TSMLoc src_hdr, TSMLoc
   src_field)

In the TSMimeHdrField* function prototypes, the TSMLoc field corresponds to the TSMLoc offset used the deprecated TSMimeField* functions (see the discussion of parent TSMLoc in the following section).