ResolveContentType
function ResolveContentType(AContentType: string): string;
Example
procedure EffectiveType(const Part: TIdMessagePart; var Value: Variant);
begin
Value := Part.ResolveContentType(Part.ContentType);
end;
Usage
ResolveContentType returns nonempty input unchanged or supplies context-sensitive MIME defaults for empty input, including multipart/digest children.
Additional Technical Info
ResolveContentType supplies Indy's default media type only when AContentType is empty.
| Condition | Result |
|---|---|
| Input nonempty | The exact input, including parameters and whitespace, unchanged |
Empty; item belongs to a MIME-encoded owner message; parent is multipart/digest | message/rfc822 |
| Empty; item belongs to any other MIME context | text/plain |
| Empty; detached, wrong collection, no owner message or non-MIME message | Empty String |
Despite a source comment saying the routine extracts text/plain from a parameterized value, the implementation does not parse nonempty input at all. Callers needing a bare media type must parse it separately; do not assume parameters are removed.
The MIME default path depends on the item being in TIdMessageParts whose owner is TIdMessage with Encoding=meMIME. For a nonnegative hidden ParentPart, it indexes the same collection and inspects that parent's first Content-Type header for multipart/digest.
There is no ParentPart bounds check here. A stale index can raise an indexed collection exception. Parent linkage is not exposed by this generated page set, but decoded/native message structures can contain it.
The method does not write ContentType, repair headers or validate the returned token. Complexity is constant except header lookup. Collection/owner mutation during the call is unsupported.
The source-reviewed example passes the stored header and accepts that an already nonempty parameterized value remains parameterized. It was not executed.
External references
- Indy upstream:
TIdMessagePart.ResolveContentType- exact context/default branches. - RFC 2045 section 5.2 - default
text/plainMIME content type. - RFC 2046 section 5.1.5 -
multipart/digestchild default.