thttpfield.md 2.2 KB


id: thttpfield title: THttpField

sidebar_label: THttpField

An HTTP Field/Header

Represents a single HTTP field/header, which can be identified either by its name (string) or by an enumeration value (EHttpHeader).

Constructors

Method New(header:EHttpHeader, value:String)

Initializes a new THttpField instance with the specified header and value.


Method New(name:String, value:String)

Initializes a new THttpField instance with the specified name and value.

The name can be a standard HTTP header name or a custom name.


Methods

Method Is:Int(name:String)

Checks if the header matches the specified name.

Headers with custom names can be added, so this method checks by string name.


Method GetName:String()

Returns the name of the HTTP field/header.


Method GetValue:String()

Returns the value of the HTTP field/header.


Method GetHeader:EHttpHeader()

Returns the enumeration value of the HTTP header.

Throws an exception if the header was created with a custom name and does not correspond to a standard header. Use TryGetHeader to safely attempt retrieval.


Method TryGetName:Int(name:String Var)

Attempts to retrieve the name of the HTTP field/header.

This method is safe to use even if the header was created with a custom name.

Returns

True if the name was retrieved; False otherwise.


Method TryGetHeader:Int(header:EHttpHeader Var)

Attempts to retrieve the enumeration value of the HTTP header.

This method is safe to use even if the header was created with a custom name, and in such cases it will return False.

Returns

True if the header corresponds to a standard header and the value was retrieved; False otherwise.


Method ToString:String()

Returns a string representation of the HTTP field/header in the format "Name: Value".