Lazarus Pascal
Lazarus Pascal
Example: Http.GetRequestHeader method
Demonstrates theGetRequestHeader method.
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.Http;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
http: THttp;
hdr1: string;
hdr2: string;
begin
success := False;
http := THttp.Create;
hdr1 := 'X-CSRF-Token';
hdr2 := 'X-Example';
http.SetRequestHeader(hdr1,'Fetch');
http.SetRequestHeader(hdr2,'123ABC');
WriteLn(hdr1 + ': ' + http.GetRequestHeader(hdr1));
WriteLn(hdr2 + ': ' + http.GetRequestHeader(hdr2));
// Output:
// X-CSRF-Token: Fetch
// X-Example: 123ABC
http.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.