Lazarus Pascal
Lazarus Pascal
Setting a HTTP Max Response Size
Demonstrates theMaxResponseSize property.
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;
maxSz: LongWord;
xmlStr: string;
begin
success := False;
http := THttp.Create;
maxSz := 16384;
http.MaxResponseSize := maxSz;
// Try to get something larger, such as hamlet.xml which is 279658 bytes
xmlStr := http.QuickGetStr('https://chilkatsoft.com/hamlet.xml');
if (http.LastMethodSuccess = False) then
begin
// If the LastErrorText contains the string "MaxResponseSize",
// then the HTTP request failed because the response body would've been larger than the max allowed response size.
WriteLn(http.LastErrorText);
Exit;
end;
WriteLn('OK');
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.