读DataSnap源代码(四)
继续篇中的
function TCustomWebDispatcher.DispatchAction(Request: TWebRequest;
Response: TWebResponse): Boolean;
var
I: Integer;
Action, Default: TWebActionItem;
Dispatch: IWebDispatch;
begin
FRequest := Request;
FResponse := Response;
I := ;
Default := nil;
if Response.Sent then
begin
Result := True;
{ Note that WebSnapSvr enabled apps have no way to mark response as sent }
Exit;
end;
Result := DoBeforeDispatch(Request, Response) or Response.Sent;
while not Result and (I < FActions.Count) do
begin
Action := FActions[I];
Result := Action.DispatchAction(Request, Response, False);
if Action.Default then Default := Action;
Inc(I);
end;
// Dispatch to self registering components
I := ;
while not Result and (I < FDispatchList.Count) do
begin
if Supports(IInterface(FDispatchList.Items[I]), IWebDispatch, Dispatch) then
begin
Result := DispatchHandler(Self, Dispatch,
Request, Response, False);
end;
Inc(I);
end; if not Result and Assigned(Default) then
Result := Default.DispatchAction(Request, Response, True);
if Result and not Response.Sent then
Result := DoAfterDispatch(Request, Response); end;
在第26行代码之前,是执行WebModule中的Action, 然后是遍例WebModule上的Component, 只要支持IWebDispatch,都有机会处理WEB请求。
当然就包括了 TDSHTTPWebDispatcher = class(TDSHTTPServerTransport, IWebDispatch)。 继续代码:
function DispatchHandler(Sender: TObject; Dispatch: IWebDispatch; Request: TWebRequest; Response: TWebResponse;
DoDefault: Boolean): Boolean;
begin
Result := False;
if (Dispatch.Enabled and ((Dispatch.MethodType = mtAny) or
(Request.MethodType = Dispatch.MethodType)) and
Dispatch.Mask.Matches(string(Request.InternalPathInfo))) then
begin
Result := Dispatch.DispatchRequest(Sender, Request, Response);
end;
end;
function TDSHTTPWebDispatcher.DispatchRequest(Sender: TObject;
Request: TWebRequest; Response: TWebResponse): Boolean;
begin
try
if Owner is TWebModule then
DataSnapWebModule := TWebModule(Owner);
try
try
RequiresServer;
TDSHTTPServerWebBroker(Self.FHttpServer).DispatchDataSnap(Request, Response);
Result := True;
except
on E: Exception do
begin
{ Default to 500, like web services. }
Response.StatusCode := 500;
Result := True;
end;
end;
except
{ Swallow any unexpected exception, it will bring down some web servers }
Result := False;
end;
finally
{ Reset current DataSnapWebModule }
DataSnapWebModule := nil;
end;
end;
至此,WEB请求转入到WebModule中的TDSHTTPWebDispatcher来处理了。
读DataSnap源代码(四)的更多相关文章
- 读DataSnap源代码(一)
Delphi的DataSnap用了一段时间了,但一直感觉有些地方还不够了解,所以花时间阅读了源代码,特作此烂笔头. Datasnap是在之前的WebBorker基础上搭建的,DataSnap向导自动生 ...
- 读DataSnap源代码(五)
function TDSHTTPWebDispatcher.DispatchRequest(Sender: TObject; Request: TWebRequest; Response: TWebR ...
- 读DataSnap源代码(六)
具体分析一下DataSanp App与Rest, WebBroker App的不同,先看TDSHTTPService. **************************************** ...
- 读DataSnap源代码(三)
function TWebRequestHandler.HandleRequest(Request: TWebRequest; Response: TWebResponse): Boolean; va ...
- 读DataSnap源代码(二)
program Project1; {$APPTYPE GUI} {$R *.dres} uses Vcl.Forms, Web.WebReq, IdHTTPWebBrokerBridge, Form ...
- 读Flask源代码学习Python--config原理
读Flask源代码学习Python--config原理 个人学习笔记,水平有限.如果理解错误的地方,请大家指出来,谢谢!第一次写文章,发现好累--!. 起因 莫名其妙在第一份工作中使用了从来没有接 ...
- session自己定义存储,怎样更好地进行session共享;读tomcat7源代码,org.apache.catalina.session.FileStore可知
session自己定义存储.怎样更好地进行session共享: 读tomcat源代码,org.apache.catalina.session.FileStore可知 一.详见: 方法1 public ...
- dotnet 读 WPF 源代码笔记 布局时 Arrange 如何影响元素渲染坐标
大家是否好奇,在 WPF 里面,对 UIElement 重写 OnRender 方法进行渲染的内容,是如何受到上层容器控件的布局而进行坐标偏移.如有两个放入到 StackPanel 的自定义 UIEl ...
- dotnet 读 WPF 源代码笔记 渲染收集是如何触发
在 WPF 里面,渲染可以从架构上划分为两层.上层是 WPF 框架的 OnRender 之类的函数,作用是收集应用程序渲染的命令.上层将收集到的应用程序绘制渲染的命令传给下层,下层是 WPF 的 GF ...
随机推荐
- 给视频加上 遮盖层, 移入隐藏, 移开 显示遮盖 ;;; mouseover ,和 mouseout
如下图所示: 主要就是 给遮盖定位 . 但是有一个问题就是 video的高度不是固定的 . 如果 video 和 遮盖 在一个 父级div里, 无法确定位置, 如果用js效果不是很好. 思路: v ...
- jetty404web界面服务器信息隐藏
jetty服务器报以上的404错误时,为了信息安全必须隐藏信息错误提示 在jetty的配置文件jetty.xml添加以下内容: 重启一下jetty服务器就OK了,在验证时是这样的:
- javascript动态加载js文件主流浏览器兼容版
一.代码示例: <html> <head> <meta http-equiv="Content-Type" content="text/ht ...
- Unknown parameter datatype UNKNOW send from server.
procedure Tmainform.Button7Click(Sender: TObject); begin kbmMWClientQuery3.Query.Text:='insert into ...
- python 一次创建多级目录
python 一次创建多级目录沙漠骆驼:qq音乐import osos.mkdirs('/home/user/app')
- 构造方法调用另一个构造方法,用this
using System; class Person { public int age; public string name; public Person(int age, string name) ...
- 在Microsoft Power BI中创建地图的10种方法
今天,我们来简单聊一聊“地图”. 在我们日常生活中,地图地位已经提升的越来越高,出门聚餐.驾驶.坐车.旅行......应运而生的就是各种Map APP. 作为数据分析师,我们今天不讲生活地图,要跟大家 ...
- reids的搭建
---恢复内容开始--- redis的安装 源码包安装 以reids3.0为例 先安装编译的软件 gcc gcc-c++ make yum -y install gcc gcc-c++ make ...
- Linux内存压力测试stressapptest
/********************************************************************** * Linux内存压力测试stressapptest * ...
- 【摄像头】Global Shutter(全局快门)与Rolling Shutter(卷帘快门)的区别与比较
由于红外补光灯的爆闪,所以一般DMS会用global shutter的sensor,而不是rolling shutter的. 参考 1. Global Shutter(全局快门)与Rolling Sh ...