THttpCli.Get

From Overbyte
Jump to: navigation, search

Main page -> ICS components reference -> THttpCli -> Get

Definition

function THttpCli.Get;


Description

Makes a synchronous get-request to the server.

Example

This sample makes a simple get request to the server and put the resulting page into a string.

var
 lData: TStringStream;
 lDataOut : TMemoryStream;
 lResultPage: string;
begin
 lDataOut := TMemoryStream.Create;
 lData :=  TStringStream.Create();
 //A post request would use lDataout to post data to server
 lDataOut.Seek(0, soFromBeginning);
 httpcli1.SendStream := lDataOut;
 httpcli1.RcvdStream := lData;
 httpcli1.URL        := 'http://mywebsite/test.php?field1=value1&field2=value2';
 try
   httpcli1.get;
   //lResultPage will contain the answer from the webserver as a string
   lResultPage := lData.DataString;     
 except
   lDataOut.Free;
   Exit;
 end;
 lDataOut.Free;
 lData.Free;

Best practices

Nothing yet.

How to

Nothing yet.