Sample code for 30+ languages & platforms
Lazarus Pascal

Example: Http.ClearHeaders method

Demonstrates how to call the ClearHeaders method.

Also see: Chilkat Http Default and Auto-Filled Headers

Chilkat Lazarus Pascal Downloads

Lazarus Pascal
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');
  http.SetRequestHeader('X-Example','5678');

  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
  //  X-Example: 5678

  //  Remove the request headers we previously added:
  http.ClearHeaders();

  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.