We check the Server Address TextEdit control so we make a few validations on it. We could use regular expressions to do this job, but this is out of the scope of this demo.

Configure our TRtcDataRequest. We are not making validations on the FileName, those are done whe the Request is started at the OnBeginRequest event.

No Beep.

Start the connection. We already set our ServerAddr property for our RtcHttpClient control, so now, we start our connection to that server.

20. Connect to the internet, then Compile and Run the project.

If every thing is ok, you should see your form ready to process your requests.

Project Running

In this example, content is received piece-by-piece and filled into the Memo field (mmResult) by adding the text Read to Memo’s text and special care had to be taken to avoid clearing the memo in the middle of receiving.
You can access response header information in different ways:

Even though Response.ContentLength could be undefined (zero) if Server only supports HTTP/1.0 (server will end the response with a disconnect), you can always use the Response.ContentIn property to check how much of the response content has already arrived. This will increment for each package received, even if you do not call Read.

Other interesting events when receiving data are the OnResponseDone and OnConnectLost events. OnResponseDone event will be triggered after the last OnDataReceived event (after all data has been received), while the OnConnectLost event gets called in case your connection drops after executing the OnBeginRequest event, but before you received the complete response in the OnDataReceived event.

To store received data in a stream, you can open the stream from the OnDataReceived event when Response.Started, append (to the stream) everything you Read from the OnDataReceived event and close the stream from OnResponseDone and OnConnectLost events.