You are not logged in.
Output a file as a file stream
2.Mormot2 BUG Fix Please fix this unit mormot.net.http.pas
Methods: the function THttpRequestContext. ContentFromFile Bug reasons, the file is empty when the output is false, can not find a file, is wrong.
Amended as follows :
ContentLength := FileSize(FileName):// Add this judgment to this sentence:
if ContentLength=0 then
begin
result := true;
Last edited by wfbhappy (2024-01-28 13:59:55)
Offline
Are you sure?
With the latest source code version,
if ContentLength=0 then the "ContentLength < 1 shl 20" branch is taken, and FileReadAll() returns true with Content=''.
As expected.
Or did I miss something?
Offline
//-- This works fine
ContentLength := FileSize(FileName);
if ContentLength=0 then
begin
result := true;
exit;
end;
result := ContentLength <> 0;
if result and
(rfWantRange in ResponseFlags) then
if not ValidateRange then
result := false; // invalid offset
if not result then
// there is no such file available, or range clearly wrong
exit;
include(ResponseFlags, rfAcceptRange);
Offline