Sample code for 30+ languages & platforms
Delphi ActiveX

Setting a HTTP Max Response Size

Demonstrates the MaxResponseSize property.

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Integer;
http: TChilkatHttp;
maxSz: Cardinal;
xmlStr: WideString;

begin
success := 0;

http := TChilkatHttp.Create(Self);

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 = 0) 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.
    Memo1.Lines.Add(http.LastErrorText);
    Exit;
  end;

Memo1.Lines.Add('OK');
end;