TsgcHTTPServer › Events › OnUnknownProtocol
Fires when the first bytes received do not look like a valid HTTP request so the connection can be accepted or rejected.
property OnUnknownProtocol: TsgcWSUnknownProtocolEvent;
// TsgcWSUnknownProtocolEvent = procedure(Connection: TsgcWSConnection; var Accept: Boolean) of object
—
OnUnknownProtocol is raised when the server receives the first bytes from a connecting client and cannot recognize a valid HTTP request. It is typically used to accept plain TCP clients on the same listener, or to reject unsolicited/garbage connections before they consume further resources. Set Accept to True to keep the session open (OnConnect will then be fired) or to False to close it. The Connection parameter identifies the session; inspect the raw bytes already buffered on it to decide whether to allow the connection.
procedure OnUnknownProtocol(Connection: TsgcWSConnection; var Accept: Boolean);
begin
Accept := True;
end;