使用TIdHTTPServer
(Indy 10.6),如何跟踪每个请求(关闭连接时)发送到客户端(用户浏览器)的字节数?
procedure onCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
begin
AResponseInfo.ContentStream := TFileStream.Create('C:/HugeFile.zip', fmOpenRead or fmShareCompat);
AResponseInfo.ContentLength := AResponseInfo.ContentStream.Size;
AResponseInfo.WriteHeader;
AResponseInfo.WriteContent;
AResponseInfo.ContentStream.Free;
AResponseInfo.ContentStream := nil;
end;
例如,在日志文件中:
2014-11-06 20:32:00 - IPAddress 84.XXX.XXX.XXX 下载 1000000 字节 (100%) 2014-11-05 16:05:00 - IPAddress 72.XXX.XXX.XXX 下载 500000 字节 (50%)