Sample code for 30+ languages & platforms
Pascal (Lazarus/Delphi)

HTTPS GET - Download HTML or any Text Content to a String

See more HTTP Examples

The QuickGetStr method is the simplest way to retrieve a text resource from a web server using an HTTP GET request. The text resource can be HTML, XML, JSON, text, or anything other type of file composed of readable text.

Chilkat Pascal (Lazarus/Delphi) Downloads

Pascal (Lazarus/Delphi)
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
  http: THttp;
  str: string;

begin
  //  This example assumes the Chilkat API to have been previously unlocked.
  //  See Global Unlock Sample for sample code.

  http := THttp.Create;

  //  Send the HTTP GET and return the content in a string.
  str := http.QuickGetStr('https://www.chilkatsoft.com/helloWorld.json');
  if (http.LastMethodSuccess = False) then
    begin
      WriteLn(http.LastErrorText);
      Exit;
    end;

  WriteLn(str);

  str := http.QuickGetStr('https://www.chilkatsoft.com/helloWorld.txt');
  WriteLn(str);

  str := http.QuickGetStr('https://www.chilkatsoft.com/helloWorld.xml');
  WriteLn(str);


  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.