Skip to content

TFPCustomHTTPClient

Base HTTP client class for making HTTP requests

Declaration

Source position: fphttpclient.pp line 115

type

  TFPCustomHTTPClient = class(TComponent)
  public
    constructor Create;
    destructor Destroy;
    property UnixSocketPath: string; {rw}
    class procedure AddHeader(HTTPHeaders: TStrings; const AHeader: string; 
                         const AValue: string);
    procedure AddHeader(const AHeader: string; const AValue: string);
    class function IndexOfHeader(HTTPHeaders: TStrings; 
                            const AHeader: string) : Integer;
    function IndexOfHeader(const AHeader: string) : Integer;
    class function GetHeader(HTTPHeaders: TStrings; const AHeader: string)
                         : string;
    function GetHeader(const AHeader: string) : string;
    procedure Terminate;
    procedure HTTPMethod;
    procedure Get(const AURL: string; Stream: TStream);
    procedure Get(const AURL: string; const LocalFileName: string);
    procedure Get(const AURL: string; Response: TStrings);
    function Get(const AURL: string) : RawByteString;
    function GetEventSource : TCustomHTTPEventSource;
    class function IsRedirect : Boolean;
    class function RedirectForcesGET : Boolean;
    class procedure SimpleGet(const AURL: string; Stream: TStream);
    class procedure SimpleGet(const AURL: string; 
                         const LocalFileName: string);
    class procedure SimpleGet(const AURL: string; Response: TStrings);
    class function SimpleGet(const AURL: string) : RawByteString;
    procedure Post(const URL: string; const Response: TStream);
    procedure Post(const URL: string; Response: TStrings);
    procedure Post(const URL: string; const LocalFileName: string);
    function Post(const URL: string) : RawByteString;
    class procedure SimplePost(const URL: string; const Response: TStream);
    class procedure SimplePost(const URL: string; Response: TStrings);
    class procedure SimplePost(const URL: string; 
                          const LocalFileName: string);
    class function SimplePost(const URL: string) : RawByteString;
    procedure Put(const URL: string; const Response: TStream);
    procedure Put(const URL: string; Response: TStrings);
    procedure Put(const URL: string; const LocalFileName: string);
    function Put(const URL: string) : RawByteString;
    class procedure SimplePut(const URL: string; const Response: TStream);
    class procedure SimplePut(const URL: string; Response: TStrings);
    class procedure SimplePut(const URL: string; 
                         const LocalFileName: string);
    class function SimplePut(const URL: string) : RawByteString;
    procedure Delete(const URL: string; const Response: TStream);
    procedure Delete(const URL: string; Response: TStrings);
    procedure Delete(const URL: string; const LocalFileName: string);
    function Delete(const URL: string) : RawByteString;
    class procedure SimpleDelete(const URL: string; const Response: TStream);
    class procedure SimpleDelete(const URL: string; Response: TStrings);
    class procedure SimpleDelete(const URL: string; 
                            const LocalFileName: string);
    class function SimpleDelete(const URL: string) : RawByteString;
    procedure Patch(const URL: string; const Response: TStream);
    procedure Patch(const URL: string; Response: TStrings);
    procedure Patch(const URL: string; const LocalFileName: string);
    function Patch(const URL: string) : RawByteString;
    class procedure SimplePatch(const URL: string; const Response: TStream);
    class procedure SimplePatch(const URL: string; Response: TStrings);
    class procedure SimplePatch(const URL: string; 
                           const LocalFileName: string);
    class function SimplePatch(const URL: string) : RawByteString;
    procedure Options(const URL: string; const Response: TStream);
    procedure Options(const URL: string; Response: TStrings);
    procedure Options(const URL: string; const LocalFileName: string);
    function Options(const URL: string) : RawByteString;
    class procedure SimpleOptions(const URL: string; 
                             const Response: TStream);
    class procedure SimpleOptions(const URL: string; Response: TStrings);
    class procedure SimpleOptions(const URL: string; 
                             const LocalFileName: string);
    class function SimpleOptions(const URL: string) : RawByteString;
    class procedure Head;
    procedure FormPost(const URL: string; FormData: RawByteString; 
                  const Response: TStream);
    procedure FormPost(const URL: string; FormData: TStrings; 
                  const Response: TStream);
    procedure FormPost(const URL: string; const FormData: string; 
                  const Response: TStrings);
    procedure FormPost(const URL: string; FormData: TStrings; 
                  const Response: TStrings);
    function FormPost(const URL: string; const FormData: RawByteString)
                  : RawByteString;
    function FormPost(const URL: string; FormData: TStrings) : RawByteString;
    class procedure SimpleFormPost(const URL: string; 
                              const FormData: RawByteString; 
                              const Response: TStream);
    class procedure SimpleFormPost(const URL: string; FormData: TStrings; 
                              const Response: TStream);
    class procedure SimpleFormPost(const URL: string; 
                              const FormData: RawByteString; 
                              const Response: TStrings);
    class procedure SimpleFormPost(const URL: string; FormData: TStrings; 
                              const Response: TStrings);
    class function SimpleFormPost(const URL: string; 
                             const FormData: RawByteString)
                              : RawByteString;
    class function SimpleFormPost(const URL: string; FormData: TStrings)
                              : RawByteString;
    procedure FileFormPost(const AURL: string; const AFieldName: string; 
                      const AFileName: string; const Response: TStream);
    procedure FileFormPost(const AURL: string; FormData: TStrings; 
                      AFieldName: string; AFileName: string; 
                      const Response: TStream);
    procedure StreamFormPost(const AURL: string; const AFieldName: string; 
                        const AFileName: string; 
                        const AStream: TStream; const Response: TStream);
    procedure StreamFormPost(const AURL: string; FormData: TStrings; 
                        const AFieldName: string; 
                        const AFileName: string; 
                        const AStream: TStream; const Response: TStream);
    class procedure SimpleFileFormPost;
    property Terminated: Boolean; {r}
  end;

Description

TFPCustomHTTPClient is the base class for HTTP client functionality. It provides methods for all standard HTTP operations including GET, POST, PUT, DELETE, PATCH, OPTIONS, and HEAD requests.

The class supports SSL/TLS connections, HTTP redirects, authentication, cookies, form posting with file uploads, proxy connections, and Server-Sent Events. It handles connection management, timeout control, and provides various events for monitoring request progress.

Properties

Member Visibility Description
Terminated read only public Indicates whether the HTTP operation has been terminated
UnixSocketPath public Path to Unix domain socket for local connections
See all Properties

Methods

Member Visibility Description
AddHeader public Adds an HTTP header to a headers collection
Create public Creates a new HTTP client instance
Delete public Performs an HTTP DELETE request
Destroy public Destroys the HTTP client instance
FileFormPost public Performs an HTTP POST request with file upload
FormPost public Performs an HTTP POST request with form data
Get public Performs an HTTP GET request
GetEventSource public Creates a Server-Sent Events connection
GetHeader public Gets the value of a header from a headers collection
Head public Performs an HTTP HEAD request
HTTPMethod public Executes an HTTP request with the specified method
IndexOfHeader public Returns the index of a header in a headers collection
IsRedirect public Checks if an HTTP status code indicates a redirect
Options public Performs an HTTP OPTIONS request
Patch public Performs an HTTP PATCH request
Post public Performs an HTTP POST request
Put public Performs an HTTP PUT request
RedirectForcesGET public Checks if a redirect status code forces GET method
SimpleDelete public Static method to perform a simple HTTP DELETE request
SimpleFileFormPost public Static method to perform a simple file upload form POST
SimpleFormPost public Static method to perform a simple form POST request
SimpleGet public Static method to perform a simple HTTP GET request
SimpleOptions public Static method to perform a simple HTTP OPTIONS request
SimplePatch public Static method to perform a simple HTTP PATCH request
SimplePost public Static method to perform a simple HTTP POST request
SimplePut public Static method to perform a simple HTTP PUT request
StreamFormPost public Performs an HTTP form POST with stream upload
Terminate public Terminates any ongoing HTTP operation
See all Methods

See also

Name Description
TFPHTTPClient Full-featured HTTP client with published properties
TProxyData Proxy server configuration data