#1 2017-03-15 01:16:33

Ericshen
Member
Registered: 2017-02-25
Posts: 10

replace TIdHTTPRequestInfo to the mORMot

hell everyone , In my  demo I used the indy, now I want replace  TIdHTTPRequestInfo  to the mORMot .
how to it ? thanks!

code like this :

function CheckSignature(ARequestInfo: TIdHTTPRequestInfo): boolean;
var
  signature, timestamp, nonce, echostr: String;
  tmpstr: TStringList;
  temp: String;
begin
  tmpstr := TStringList.Create;
  try
    signature := ARequestInfo.Params.Values['signature'];
    timestamp := ARequestInfo.Params.Values['timestamp'];
    nonce := ARequestInfo.Params.Values['nonce'];

    echostr := ARequestInfo.Params.Values['echostr'];
    tmpstr.Add(Token);
    tmpstr.Add(timestamp);
    tmpstr.Add(nonce);
    tmpstr.Sort;
    temp := StringReplace(tmpstr.text, #13#10, '', [rfReplaceAll]);
    Result := SHA1(temp) = signature;
  finally
    tmpstr.Free;
  end;
end;


delphi berlin update 2, win 10

thanks!

Offline

#2 2017-03-15 03:49:30

igors233
Member
Registered: 2012-09-10
Posts: 234

Re: replace TIdHTTPRequestInfo to the mORMot

Can you be more specific about what you need?
If you want want to connect your Delphi client to mORMot server use specific mORMot classes like shown in sample 4.
If you want to retrieve some resource (page) from net, use HttpGet or appropriate classes from SynCrtSock.
If you want to send some data then use HttpPost.

Offline

#3 2017-03-15 05:18:42

Ericshen
Member
Registered: 2017-02-25
Posts: 10

Re: replace TIdHTTPRequestInfo to the mORMot

thanks igors233!
I Visited http://127.0.0.1/wxapi?wid=1  and then I want get the values Wid=1 ,and other Return values  like  this: signature := ARequestInfo.Params.Values['signature'];
    timestamp := ARequestInfo.Params.Values['timestamp']; nonce := ARequestInfo.Params.Values['nonce'];

Offline

#4 2017-03-15 05:46:12

igors233
Member
Registered: 2012-09-10
Posts: 234

Re: replace TIdHTTPRequestInfo to the mORMot

You're writing a client right (not the server)?

Do you want to parse retrieved content from some site? AFAIK if returned values are in ini style formt (key=value with each pair in new line) then you would have to do that manually, load it into some TStringList and then access it similar as you did in Indy.

Offline

#5 2017-03-15 07:56:55

Ericshen
Member
Registered: 2017-02-25
Posts: 10

Re: replace TIdHTTPRequestInfo to the mORMot

igors233,Thank you for your reply!

Sorry, I may not have a clear description, the establishment of a mormot service, and then send a get request to fill in the external URL, and with four parameters: Signature, Timestamp, Nonce, Echostr; according to the value of these parameters, the need to check the mormot service request is not legitimate.
If checksum is returned by true.

Offline

#6 2017-03-15 13:51:09

igors233
Member
Registered: 2012-09-10
Posts: 234

Re: replace TIdHTTPRequestInfo to the mORMot

Sorry I still don't follow what you really need, try to answer these questions:
1) Are you writing mORMot Client (communicating with some external web site) or Server (respoding to client requests)?
2) Do you need to send some data or receive some data (or both)?

Offline

#7 2017-03-15 15:04:50

Ericshen
Member
Registered: 2017-02-25
Posts: 10

Re: replace TIdHTTPRequestInfo to the mORMot

igors233, Thank you very much for your reply!

The url:http://127.0.0.1/wxapi? Wid=1 access Web services, then the server receives the request, access to such data: /wxapi=1? &signature=aaaaa&echostr=bbbbb&timestmp=cccc, now I want to break out of the data, such as: wxapi=1; signnature = aaaaa; timestmp=cccc;
how to deal with mormot?

Offline

#8 2017-03-16 04:03:06

igors233
Member
Registered: 2012-09-10
Posts: 234

Re: replace TIdHTTPRequestInfo to the mORMot

Sorry but I'm still not sure what you want to do, are you writing a server side code that should handle requests such as:
http://127.0.0.1/wxapi=1?&signature=aaa … estmp=cccc?

If so then you can define method service and parse input params with ease using features available in TSQLRestServerURIContext, take a look at docs, it's explained well: https://synopse.info/files/html/Synopse … ml#TITL_49

Offline

Board footer

Powered by FluxBB