Indy 9
TIdHeaderList
Hierarchy, Properties, Methods, See Also, Unit: IdHeaderList
Implements a collection of header names and values.
TIdHeaderList = class(TStringList)
Unit
IdHeaderList
Description
TIdHeaderList is a TStringList descendant that implements a collection of header names and values, and facilitates the processing of headers used in many protocols such as Gopher+, HTTP, NNTP, POP3, and SMTP.

Features include the use of a ":" instead of a comma for separating field names from values (this can be changed with the NameValueSeparator property), and optional header folding and unfolding.


TIdHeaderList.CaseSensitive
TIdHeaderList, Example
Indicates if header name comparisons are case sensitive.
property CaseSensitive: Boolean;
Description
CaseSensitive is a Boolean property that indicates if header name comparisons are case sensitive. Name, Values, and IndexOf will consider case to be significant when CaseSensitive is True.

TIdHeaderList.FoldLength
TIdHeaderList
Indicates the Maximum length of a header line before folding occurs.
property FoldLength: Integer;
Description
FoldLength is an Integer property used to indicate the maximum length of a header line where folding occurs. When FoldLines is True, FoldLength is used to perform wrapping of text in the header line.

TIdHeaderList.FoldLines
TIdHeaderList, See Also
Indicates that header lines can be folded when the maximum length is exceeded.
property FoldLines: Boolean;
Description
FoldLines is a Boolean property that indicates the string contents of header line Values can be wrapped when the length exceeds FoldLength. Set FoldLines to True to allow line wrapping.

TIdHeaderList.Names
TIdHeaderList
Access header names by position.
property Names [Index: Integer]: string;
Parameters
Index
Header position to access.
Return Value
String - header name at the given position.
Description
Names is a read-only String property that provides indexed access to header names for the header list. Names works like Borland's TStrings.Names except that it uses the delimiter in NameValueSeparator and respects the case sensitivity flag in CaseSensitive.

TIdHeaderList.NameValueSeparator
TIdHeaderList
Delimiter(s) used to separate header names and header values.
property NameValueSeparator: String;
Description
NameValueSeparator is a String property that represents the characters used as a delimiter between the header name and the header value in the textual representation of headers.

TIdHeaderList.UnfoldLines
TIdHeaderList
Indicates that header lines should be unfolded.
property UnfoldLines: Boolean;
Description
UnfoldLines is a Boolean property that indicates if Values should be interpreted with line unfolding. Setting UnfoldLines to False will cause Values to not unfold lines. Setting UnfoldLines to True causes header lines with continuation characters to be returned with the preceding header line.

TIdHeaderList.Values
TIdHeaderList
Allows access to header values by name.
property Values [const Name: string]: string;
Parameters
Name
Header name to be retrieved.
Return Value
String - Header value for the header name.
Description
Values is an Indexed String property that works like Borland's TStrings.Values except it uses the delimiter defined in NameValueSeparator as the seperator between header name and value.

Case sensitivity is set with the CaseSensitive property, and if UnfoldLines is True, lines will be unfolded.

Thus if UnfoldLines is set to true, the value in following Example for Values['Subject'] would be "This is a line which is folded. This is on another line." If UnfoldLines is set to False, the Value['Subject'] would equal = "This is a line which is folded."

Subject:  This is a line which is folded.
 This is on another line.

TIdHeaderList.AddStdValues
TIdHeaderList, See Also
Converts text line in NAME=VALUE form to their TIdHeaderLIst representation.
procedure AddStdValues(ASrc: TStrings);
Parameters
ASrc: TStrings
Storage contains values in NAME=VALUE form.
Description
AddStdValues is a procedure used to convert text values in the TStrings container ASrc to their TIdHeaderList representation using NameValueSeparator. ASrc contains text representing header names and values in NAME=VALUE form. AddStdValues replaces the '=' character in each text line with the NameValueSeparator character(s) for their header representation.

Use ConvertToStdValues to convert header name and values to their NAME=VALUE form.


TIdHeaderList.ConvertToStdValues
TIdHeaderList, See Also
Converts headers using a specific separator to NAME=VALUE form.
procedure ConvertToStdValues(ADest: TStrings);
Parameters
ADest: TStrings
Storage for header values in NAME=VALUE form.
Description
ConvertToStdValues is a procedure used to convert text values in TIdHeaderList to a NAME=VALUE representation in the TStrings instance in ADest. ConvertToStdValues replaces the NameValueSeparator character(s) in each line in TIdHeaderList with the '=' character used by TStrings descendants.

Use AddStdValues to add text lines in NAME=VALUE form to a TIdHeaderList.


TIdHeaderList.Create
TIdHeaderList
Constructor for the object instance.
constructor Create;
Description
Create is the constructor for the object instance, and relies on the inherited Create method to initialize the object. Create also sets the default values for properties including:


TIdHeaderList.Extract
TIdHeaderList
Finds and stores all values for the given header name.
procedure Extract(const AName: string; ADest: TStrings);
Parameters
const AName: string
Header name to be located and stored.
ADest: TStrings
TStrings to store all located header values.
Description
Extract is a procedure that is used to search the header list for all occurrences of the header in AName. When the header in AName is located, the value of the header is added to ADest. ADest can, as a result, contain multiple values for the named header, with one value per line.

Note: ADest is not cleared prior to use in Extract. Any existing values in ADest are unaffected.


TIdHeaderList.IndexOfName
TIdHeaderList
Returns the index position of the header with the given name.
function IndexOfName(const Name: string): Integer; reintroduce;
Parameters
const Name: string
Header name to locate.
Return Value
Integer - Index position, or -1 when not found.
Description
IndexOfName is an Integer function that returns the index position of the header with the given name. IndexOfName work like Borland's TStrings.IndexOfName except it uses the delimiters defined in NameValueSeparator, and respects the case sensitivity flag in the CaseSensitive property.

IndexOfName can return -1 when the header in Name does not exist in the header list.


Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.