正如我在您链接到的线程中所述,MaxConnectionReply
由 实现TIdCmdTCPServer
,它TIdHTTPServer
不是派生自。由于您正在覆盖DoMaxConnectionsExceeded()
,您必须手动将自己的回复发送给客户端,并确保它是正确的 HTTP 格式,例如:
procedure TMyHttpServer.DoMaxConnectionsExceeded(AIOHandler: TIdIOHandler);
var
Html: TIdBytes;
begin
Html := ToBytes('<html><body>500 - Too many connections</body></html>');
AIOHandler.WriteLn('HTTP/1.0 500 Too many connections');
AIOHandler.WriteLn('Content-Type: text/html');
AIOHandler.WriteLn('Content-Length: ' + IntToStr(Html));
AIOHandler.WriteLn('Connection: close');
AIOHandler.WriteLn;
AIOHandler.Write(Html);
end;