So if we manage to run DWS scripts from this event, via the THttpServerRequest class instance generated by the HTTP servers, we are good!
]]>What we may do is create a new unit, which would be able either:
- To use a mORMot server within the DWS http server;
- To use the DWS engine within a mORMot server.
I guess that the 2nd option may be preferred (e.g. to be able to use WebSockets, whereas the DWS http server do not support them).
But honestly I've no time for it now.
I would help fixing your integration, if you (or someone else) start this work.
So you could write:
aRemoteIP := FindIniNameValue(pointer(CallContext.InHead),'REMOTEIP: ');
TWebRequest = class
private
FCookies : TStrings;
FQueryFields : TStrings;
FContentFields : TStrings;
FCustom : TObject;
protected
FPathInfo : String;
FQueryString : String;
function GetHeaders : TStrings; virtual; abstract;
function GetCookies : TStrings;
function GetQueryFields : TStrings;
function GetContentFields : TStrings;
function GetUserAgent : String;
function GetAuthentication : TWebRequestAuthentication; virtual;
function GetAuthenticatedUser : String; virtual;
function PrepareCookies : TStrings; virtual;
function PrepareQueryFields : TStrings; virtual;
function PrepareContentFields : TStrings; virtual;
public
constructor Create;
destructor Destroy; override;
procedure ResetCookies; inline;
procedure ResetQueryFields; inline;
procedure ResetContentFields; inline;
procedure ResetFields; inline;
function Header(const headerName : String) : String;
function RemoteIP : String; virtual; abstract;
function RawURL : RawByteString; virtual; abstract;
function URL : String; virtual; abstract;
function Method : String; virtual; abstract;
function MethodVerb : TWebRequestMethodVerb; virtual; abstract;
function Security : String; virtual;
function ContentData : RawByteString; virtual; abstract;
function ContentType : RawByteString; virtual; abstract;
property PathInfo : String read FPathInfo write FPathInfo;
property QueryString : String read FQueryString write FQueryString;
property UserAgent : String read GetUserAgent;
property Headers : TStrings read GetHeaders;
property Cookies : TStrings read GetCookies;
property QueryFields : TStrings read GetQueryFields;
property ContentFields : TStrings read GetContentFields;
function HasQueryField(const name : String) : Boolean;
function HasContentField(const name : String) : Boolean;
function IfModifiedSince : TDateTime;
property Authentication : TWebRequestAuthentication read GetAuthentication;
property AuthenticatedUser : String read GetAuthenticatedUser;
// custom object field, freed with the request
property Custom : TObject read FCustom write FCustom;
end;
TWebRequest above is defined in dwsWebEnvironment.pas of DWS package, i can create an instanc as follow:
WebRequest := TWebRequest.create;
and how could i assign the value to WebRequest.RemoteIP...?
]]>AFAIK TWebRequest/TWebResponse are just some simple value related classes, and you would find every input and output information in THttpServerRequest.
]]>thanks.
]]>:-)
]]>Msdn speaks about winhttp api.
]]>