TIdHTTP
has a public Request.Method
property, which you might be tempted to use, however that won't work, because the TIdCustomHTTP.DoRequest()
method (which does all of the actual work) overwrites that property with its own AMethod
parameter. So, you will have to call DoRequest()
directly instead:
procedure DoRequest(const AMethod: TIdHTTPMethod; AURL: string;
ASource, AResponseContent: TStream; AIgnoreReplies: array of Int16); virtual;
TIdHTTPMethod
is just a string
, so you can pass in any method name you want.
However, DoRequest()
is declared as protected
in TIdCustomHTTP
1, so you will have to use a descendant/accessor class to reach it, eg:
type
TIdHTTPAccess = class(TIdHTTP)
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
TIdHTTPAccess(IdHTTP1).DoRequest('GO', 'http://127.0.0.1:1308/...', ParamsAsNeeded...);
end;
Or, you can use a class helper
instead (Delphi 2006+ only), eg:
type
TIdHTTPHelper = class helper for TIdHTTP
procedure Go(AURL: String; ParamsAsNeeded...);
end;
procedure TIdHTTPHelper.Go(AURL: String; ParamsAsNeeded...);
begin
DoRequest('GO', AURL, ParamsAsNeeded...);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
IdHTTP1.Go('http://127.0.0.1:1308/...', ParamsAsNeeded...);
end;
1: There is an open ticket in Indy's issue tracker about this: #254 Make TIdHTTP.DoRequest() public.