Skip to content

Commit

Permalink
Added buffering for chunked transfer to reduce write calls and improv…
Browse files Browse the repository at this point in the history
…e speed
  • Loading branch information
Craig Moksnes committed Mar 15, 2020
1 parent 7d74994 commit 9a68a8f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ProxyWebModuleUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ procedure TIdHTTPAppChunkedResponse.SendChunkedStream(const aStream: TStream; co
begin
FThread.Binding.UseNagle := False;

FThread.Connection.IOHandler.WriteBufferOpen;

lContinue := True;

SetLength(lBuffer, 8192);
Expand All @@ -116,6 +118,7 @@ procedure TIdHTTPAppChunkedResponse.SendChunkedStream(const aStream: TStream; co
FThread.Connection.IOHandler.WriteLn(IntToHex(lSize, 1));
FThread.Connection.IOHandler.Write(TIdBytes(lBuffer), lSize);
FThread.Connection.IOHandler.WriteLn;
FThread.Connection.IOHandler.WriteBufferFlush;

if Assigned(aPacketCallback) then
aPacketCallback(lSize, lContinue);
Expand All @@ -124,6 +127,7 @@ procedure TIdHTTPAppChunkedResponse.SendChunkedStream(const aStream: TStream; co

FThread.Connection.IOHandler.WriteLn('0');
FThread.Connection.IOHandler.WriteLn;
FThread.Connection.IOHandler.WriteBufferFlush;
end;

function TIdHTTPAppChunkedResponse.Connected: Boolean;
Expand Down

0 comments on commit 9a68a8f

Please sign in to comment.