【发布时间】:2016-01-30 12:47:01
【问题描述】:
使用 TIdHTTPServer (Indy 10.6),我想为关闭慢速或非活动客户端(客户端是普通浏览器)设置连接超时,并在 60 秒不活动后关闭所有僵尸连接。我在 TIdContext.Connection 中找到了 Socket.ReadTimeout。这是正确的方法吗? TIdHTTPServer 已经执行此操作(似乎有无限超时)?
WebServer := TIdHTTPServer.Create(nil);
WebServer.SessionState := false;
WebServer.KeepAlive := false;
WebServer.OnCommandGet := CustomOnCommandGet;
procedure CustomOnCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
begin
AContext.Connection.Socket.ReadTimeout := 60000;
AResponseInfo.ContentStream := TFileStream.Create('C:/file.zip', fmOpenRead or fmShareCompat);
end;
【问题讨论】: