procedure TfrmRtcParseDemo.RtcDataProvider1CheckRequest(Sender: TRtcConnection); begin // we want to respond to all root requests
with Sender as TRtcDataServer do begin if (Request.FileName.EndsWith('.html')) or (Request.FileName.EndsWith('.js')) or (Request.FileName.EndsWith('.css')) or (Request.FileName.EndsWith('.png')) or (Request.FileName.EndsWith('.jpeg')) or (Request.FileName.EndsWith('.gif')) then Accept; end; end;
如果用Delphi7,修改代码如下: with Sender as TRtcDataServer do begin mmo1.Lines.Add('收到请求: '+ Request.FileName); ext := ExtractFileExt(Request.FileName); if ( ( ext='.html') or (ext='.js') or (ext='.css') or (ext='.png') or (ext='.jpeg') or (ext='.gif') ) then begin Accept; mmo1.Lines.Add('接受请求'); end else mmo1.Lines.Add('拒绝未知请求');