Lazarus Pascal
Lazarus Pascal
Demonstrate HttpRequest.RemoveAllParams
Demonstrates the effect of calling HttpRequest.RemoveAllParams.Chilkat Lazarus Pascal Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.HttpRequest;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
req: THttpRequest;
begin
req := THttpRequest.Create;
req.HttpVerb := 'POST';
req.Path := '/test123';
req.ContentType := 'application/x-www-form-urlencoded';
req.AddParam('paramA','AAA');
req.AddParam('paramB','BBB');
req.AddParam('paramC','CCC');
WriteLn(req.GenerateRequestText());
WriteLn('---------------');
// Generates:
// POST /test123 HTTP/1.1
// Content-Type: application/x-www-form-urlencoded
// Host: domain
// Content-Length: 32
//
// paramA=AAA¶mB=BBB¶mC=CCC
//
// If we call RemoveAllParams, and then add some additional params,
// then the original params are gone, and only the new params exist.
req.RemoveAllParams();
req.AddParam('paramD','DDD');
req.AddParam('paramE','EEE');
req.AddParam('paramF','FFF');
WriteLn(req.GenerateRequestText());
WriteLn('---------------');
// Generates:
// POST /test123 HTTP/1.1
// Content-Type: application/x-www-form-urlencoded
// Host: domain
// Content-Length: 32
//
// paramD=DDD¶mE=EEE¶mF=FFF
req.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.