Recent

Author Topic: TFPHttpClient - chunk size too big (RFC 2616)  (Read 1604 times)

tudi_x

  • Hero Member
  • *****
  • Posts: 532
TFPHttpClient - chunk size too big (RFC 2616)
« on: November 07, 2017, 11:30:33 am »
hi All,
while doing a GET with TFPHttpClient I am getting a EHTTPClient.Create(SErrChunkTooBig) for a 10 M reguest (for a bandwidth check).
as per RFC2616 there is no chunk size limit.
please advise on the limitation or could it be reviewed and for persons interested the initial stream size could be used for triggering the error?

from fphttpclient.pp around line 1057, Lazarus 1.8RC5 with FPC 3.0.4:
Code: Pascal  [Select]
  1. if ChunkSize>1000000 then Raise EHTTPClient.Create(SErrChunkTooBig);

please advise.
thank you
« Last Edit: November 07, 2017, 11:55:09 am by tudi_x »
Lazarus 2.0.2 64b on Debian LXDE 10

tudi_x

  • Hero Member
  • *****
  • Posts: 532
Re: TFPHttpClient - chunk size too big (RFC 2616)
« Reply #1 on: November 07, 2017, 12:03:18 pm »
how would i get pass this error?
i commented the line, deleted lib folder, cleaned up and built.
i only see this chunk too big error in fphttpclient.pp.

Code: Pascal  [Select]
  1. unit c_get;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils,
  9.   dateutils,
  10.   fphttpclient;
  11.  
  12. type
  13.   TPassError = procedure(AError: string) of object;
  14.  
  15. type
  16.   TGETSpeed = class(TThread)
  17.   private
  18.     _URL: string;
  19.     _Error: TPassError;
  20.  
  21.     procedure TriggerError(AError: string);
  22.     procedure CheckSpeed(AURL: string; ABytes: longword);
  23.  
  24.   protected
  25.     procedure Execute; override;
  26.  
  27.   public
  28.     constructor Create(AURL: string); reintroduce;
  29.     destructor Destroy(); override;
  30.     property OnPassError: TPassError read _Error write _Error;
  31.   end;
  32.  
  33. implementation
  34.  
  35. constructor TGETSpeed.Create(AURL: string);
  36. begin
  37.   _URL := AURL;
  38.  
  39.   inherited Create(False);
  40.   self.FreeOnTerminate := True;
  41. end;
  42.  
  43. procedure TGETSpeed.Execute;
  44. begin
  45.   CheckSpeed(_URL, 10485760);
  46. end;
  47.  
  48. procedure TGETSpeed.CheckSpeed(AURL: string; ABytes: longword);
  49. var
  50.   t1, t2: TDateTime;
  51.   url: string;
  52.   params: string;
  53.   HTTPRequest: TFPHttpClient;
  54.  
  55. begin
  56.   try
  57.     params := 's=' + EncodeURLElement(IntToStr(ABytes));
  58.     url := AURL + '?' + params;
  59.  
  60.     try
  61.       HTTPRequest := TFPHttpClient.Create(nil);
  62.       t1 := now();
  63.       HTTPRequest.Get(url);
  64.       t2 := now();
  65.  
  66.       TriggerError(IntToStr(MilliSecondsBetween(t2, t1)));
  67.     except
  68.       on E: Exception do
  69.       begin
  70.         HTTPRequest.Free;
  71.         TriggerError('Error:' + E.Message);
  72.       end;
  73.     end;
  74.   finally
  75.     FreeAndNil(HTTPRequest);
  76.   end;
  77. end;
  78.  
  79. procedure TGETSpeed.TriggerError(AError: string);
  80. begin
  81.   if Assigned(_Error) then
  82.     _Error(AError);
  83. end;
  84.  
  85. destructor TGETSpeed.Destroy();
  86. begin
  87.   inherited Destroy;
  88. end;
  89.  
  90. end.
« Last Edit: November 07, 2017, 12:07:38 pm by tudi_x »
Lazarus 2.0.2 64b on Debian LXDE 10

tudi_x

  • Hero Member
  • *****
  • Posts: 532
Re: TFPHttpClient - chunk size too big (RFC 2616)
« Reply #2 on: November 07, 2017, 12:26:46 pm »
working with Synapse.
opened:  https://bugs.freepascal.org/view.php?id=32656
Lazarus 2.0.2 64b on Debian LXDE 10

Leledumbo

  • Hero Member
  • *****
  • Posts: 8139
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: TFPHttpClient - chunk size too big (RFC 2616)
« Reply #3 on: November 07, 2017, 02:46:55 pm »
how would i get pass this error?
i commented the line, deleted lib folder, cleaned up and built.
It's an fpc unit, compile the unit inside its folder (use the provided Makefile) then copy the resulting .o and .ppu to the unit path (NOT your project path).