When using the SendBytes method to send a binary response it fails if ABytes argument is an empty array of bytes.
Steps to reproduce:
Run this program. It's inspired by hellohttpsrv.pas FPC example
program TestBrook;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes
{ you can add units after this },
BrookHTTPRequest,
BrookHTTPResponse,
BrookHTTPServer;
type
THTTPServer = class(TBrookHTTPServer)
protected
procedure DoRequest(ASender: TObject; ARequest: TBrookHTTPRequest;
AResponse: TBrookHTTPResponse); override;
end;
procedure THTTPServer.DoRequest(ASender: TObject; ARequest: TBrookHTTPRequest;
AResponse: TBrookHTTPResponse);
begin
AResponse.SendBytes([], 0, 'application/octet-stream', 200);
end;
begin
with THTTPServer.Create(nil) do
try
Port := 4000;
Open;
if not Active then
Exit;
WriteLn('Server running at http://localhost:', Port);
ReadLn;
finally
Free;
end;
end.
Raised error and/or generated log.
Invalid argument
Environment:
OS, compiler and Brook version to reproduce the problem, e.g.:
When using the
SendBytes
method to send a binary response it fails ifABytes
argument is an empty array of bytes.Steps to reproduce:
Run this program. It's inspired by
hellohttpsrv.pas
FPC exampleRaised error and/or generated log.
Invalid argument
Environment:
OS, compiler and Brook version to reproduce the problem, e.g.:
PR: https://github.com/risoflora/brookframework/pull/32