Lazarus Pascal
Lazarus Pascal
Example: Http.RemoveRequestHeader method
Demonstrates how to call the RemoveRequestHeader method.Also see: Chilkat Http Default and Auto-Filled Headers
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;
responseBody: string;
begin
success := False;
http := THttp.Create;
// Add a request header.
http.SetRequestHeader('X-Something','1234');
responseBody := http.QuickGetStr('https://chilkatsoft.com/helloWorld.txt');
// Examine the request header we just sent..
WriteLn(http.LastHeader);
WriteLn('----');
// Output:
// GET /helloWorld.txt HTTP/1.1
// Host: chilkatsoft.com
// Accept: */*
// Accept-Encoding: gzip
// X-Something: 1234
// Remove the request header we previously added:
http.RemoveRequestHeader('X-Something');
responseBody := http.QuickGetStr('https://chilkatsoft.com/helloWorld.txt');
WriteLn(http.LastHeader);
// Output:
// GET /helloWorld.txt HTTP/1.1
// Host: chilkatsoft.com
// Accept: */*
// Accept-Encoding: gzip
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.