From Overbyte
Jump to: navigation, search

Main page -> ICS components reference -> THttpCli -> OnDocData


procedure THttpCli.OnDocData(Sender: TObject; Buffer: Pointer; Len: Integer) of object;

  • Sender : the client which fired the event
  • Buffer : a pointer to the received data buffer
  • Len : number of bytes in the buffer


This event will fire each time a buffer has been received from the server. You can use this method for example to find out how much data you received during the session. In HttpProt.pas the receive buffer size is set to 8193, which means for every chunk of 8193 bytes received from the server your event handler will be called.


see best practices

Best practices

If you update user interface elements (eg. progress bar) in this events it can create a huge overhead and slow down data transfer. If it is necesary to make UI updates in the event handler then you should do it only temporized updates. An example would be:

procedure TYourClass.HttpCliDocData(Sender: TObject; Buffer: Pointer; Len: Integer);
   FReceivedLen := FReceivedLen + Len;

   {this is only a float comparison so it don't take too much time}
   if MilliSecondsBetween(Now, FLastReceivedTime) > 50 then begin
       FLastReceivedTime := Now;
       {Update UI only here in order to avoid slow tranfer rates}

   {if you are implementing limitation on max transfer size you can also do it here}
   if (FDataLen > DataLimit) then