web-services - 最早放弃Web服务中的POST请求吗?

标签 web-services delphi indy indy10 delphi-10-seattle

我的网络服务中的“安全措施”之一是阻止大文件上传。
发送太大文件时,我想尽快取消文件上传请求。

由于带有文件上传的请求无论如何都会是最大的请求,因此我目前在BeforeDispatchTWebModule处理程序中具有以下代码:

procedure TWebModuleWebServices.WebModuleBeforeDispatch(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
   // Request that are too large are going to be dropped silently:
   if Request.ContentLength > cMaxContentSize then
   begin
      Handled := true;
      Exit;
   end;


是BeforeDispatch处理程序是该测试最早的阶段,还是有更好的地方?

Web服务是围绕TIdHTTPWebBrokerBridge构建的(= class(TIdCustomHTTPServer),请参见IdHTTPWebBrokerBridge.pas

最佳答案

使用Indy时,TCustomWebDispatcher.BeforeDispatch事件为时已晚,因为已经在TIdCustomHttpServer.DoExecute中检索到了发布数据流。您可以通过将TIdCustomHTTPServer.OnHeadersAvailable设置为VContinueProcessing来使用False事件(该事件较早触发)来避免该事件。

关于web-services - 最早放弃Web服务中的POST请求吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36935412/

相关文章:

c# - 从同一 Web 服务调用 Web 方法

Delphi 窗体最小化和使用计时器恢复

http - 如何使用 TIdHttp GET 请求发送内容?

delphi - 如何查看两个形状是否重叠

delphi - 如何释放通用 TList<T>?

delphi - Delphi 2009中Indy 10的逐步升级

delphi - 使用 gmail 和 Indy 发送电子邮件

json - RESTful API 设计,更新资源时区分 PUT 操作

c# - 服务器无法识别 HTTP header SOAPAction 的值

java - NoClassDefinitionFound : javax. xml.ws.Service