You should not use any events directly on the TRtcHttpServer component for reading or sending any data out. These events can ONLY be used for logging and monitoring purposes.
If you want to redirect traffic from your plain HTTP Server to the SSL Server, use a TRtcDataProvider component attached to the plain HTTP Server and implement the OnCheckRequest event on that TRtcDataProvider component like this:
const
// URL of your HTTPS Server, without "/"
MySecureServerLocation = 'https://www.myhostaddr.com'; var
Server: TRtcDataServer absolute Sender;
begin
// Accept the request
Server.Accept; // Set Response code
Server.Response.Status(301, 'Moved Permanently');
// Set the Server Address and Port part of the "Location" Response header by using a fixed parameter,
// instead of using the Request.Host parameter received from your Clients, but
// use the full URI received from the Client instead of forwarding all requests to the room URI "/"
Server.Response
['Location'] := MySecureServerLocation + Server.Request.URI;
// Call "Write" and not "Disconnect"
// If you do NOT call "Write", nothing will be sent to the Client (no redirect happening).
Server.
Write;
end;
Please note that by doing this, ALL requests sent from Web Browsers to the plain HTTP Server will be redirected to your HTTPS (SSL) Server, without exception. If you only want specific requests to be redirected, use the Server.Request property inside the event (above) to decide which requests you want to accept and redirect, and which requests to ignore.
Best Regards,
Danijel Tkalcec