#1 Re: mORMot 2 » TRecordVersion doesn't work as expected » 2023-05-31 01:51:58

if dstOrm.ID > 0 then
            tmpUpdBatch.Update(dstOrm)
          else
            tmpAddBatch.Add(dstORM, true);

try it as follow:

          if dstOrm.ID > 0 then
            tmpAddBatch.Delete(dstOrm.IDValue);
          
          tmpAddBatch.Add(dstORM, true);

#2 Re: mORMot 2 » Utf8ToString does not support Chinese » 2023-05-09 01:57:27

uses LConvEncoding, and try CP936ToUTF8 or UTF8ToCP936.

#3 Re: mORMot 1 » TRestBatch from json string » 2022-07-10 14:15:32

after change the field delfinition in TOrm to NullableUtf8text, it worked.
Thanks again!

#5 mORMot 1 » TRestBatch from json string » 2022-07-06 15:01:37

profh
Replies: 3

Hi ab, i got the following code:

var
  lbatch: TRestBatch;
  lrec: TOrm;
  ...
begin
  lbatch := TRestBatch.Create(DBServer.Orm,
                  DBModel.Table[ltblname],10000,
                  [boInsertOrReplace,boExtendedJson]);
  
  lrec := DBModel.Table[ltblname].CreateAndFillPrepare(ajson); 
  lrec.FillRewind;
  while lRec.FillOne  do
  begin
    lrtn := lbatch.Add(lrec,true,true);
  ......

some field values in ajson are nulls, but after execute as follow:

lrtn := DBServer.Orm.BatchSend(lbatch);

filed values in sqlite become emtpy string or zero depends on its type.

how to keep the null values into the sqlite?

Thank you very much!

#6 Re: mORMot 1 » mORMot2 on ARM » 2022-01-30 04:21:59

thanks to ab and Alfred, i cross compiled my project with mormot1.8 using fpcupdeluxe AARch64 cross compiler under windows 11, it worked fine for months.

i also compiled it with mormot2 using fpcupdeluxe AARch64 cross compiler under windows 11, it worked also.

install fpcupdeluxe on my Raspberry Pi 4, compile it again and it also works.

the key is that i should use free pascal version 3.2.2 and lazarus 2.2.0, higher version will produce kinds of errors which are of my own codes.


thanks to you two again!

#7 Re: mORMot 1 » about TSqlDataBase.LockJson » 2021-12-17 01:37:11

Please follow the forum rules and don't post code here in the forum.

sorry about that.  smile

already got to run, thanks again!

#8 mORMot 1 » about TSqlDataBase.LockJson » 2021-12-16 08:05:59

profh
Replies: 2

hi, ab:

  is it possibly to change TSqlDataBase.LockJson in mormot.db.raw.sqlite3.pas code as follow:

from:

  fSafe.Lock; // cache access is also protected by fSafe
  try
    if IsCacheable(aSql) then
    begin
      result := fCache.Find(aSql, aResultCount); // try to get JSON result from cache
      if result <> '' then
      begin
        if fLog <> nil then
        begin
          fLog.Add.Log(sllSQL, 'from cache % %', [FileNameWithoutPath, aSql], self);
          fLog.Add.Log(sllResult, result, self, fLogResultMaximumSize);
        end;
        fSafe.UnLock; // found in cache -> leave critical section                                                        <-------- from here
      end;
    end
    else
    begin
      // UPDATE, INSERT or any non SELECT statement
      CacheFlush;
      result := '';
    end;
  except
    ...;
  end;

to

  fSafe.Lock; // cache access is also protected by fSafe
  try
    if IsCacheable(aSql) then
    begin
      result := fCache.Find(aSql, aResultCount); // try to get JSON result from cache
      if result <> '' then
      begin
        if fLog <> nil then
        begin
          fLog.Add.Log(sllSQL, 'from cache % %', [FileNameWithoutPath, aSql], self);
          fLog.Add.Log(sllResult, result, self, fLogResultMaximumSize);
        end;
      end;
    end
    else
    begin
      // UPDATE, INSERT or any non SELECT statement
      CacheFlush;
      result := '';
    end;
  except
    ...;
  end;
  fSafe.UnLock; // found in cache -> leave critical section                                               <-------         to here

thanks for your great job!

#9 Re: mORMot 1 » mORMot 2 in Good Shape » 2021-01-20 05:35:49

Excellent! great work ab as always!

#10 Re: mORMot 1 » about TJSONWriter... » 2020-10-28 09:40:56

i used SQLite3 version 3.33.0 without dll.

in TSQLRequest.FieldsToJSON procedure, sqlite3.column_int64(Request,i)   and  sqlite3.column_text(Request,i) can get correct values,

procedure TSQLRequest.FieldsToJSON(WR: TJSONWriter; DoNotFetchBlobs: boolean);
var i: integer;
begin
......
      SQLITE_NULL:
        WR.AddShort('null'); // returned also for ""
      SQLITE_INTEGER:
        WR.Add(sqlite3.column_int64(Request,i));                     <----perhaps Add? each sqlite3.column_int64(Request,i) is very correct
      SQLITE_FLOAT:
        WR.AddDouble(sqlite3.column_double(Request,i));
      SQLITE_TEXT: begin
        WR.Add('"');
        WR.AddJSONEscape(sqlite3.column_text(Request,i),0);     <----perhaps AddJSONEscape? each sqlite3.column_text(Request,i) is very correct
        WR.Add('"');
       end;
    end; // case ColTypes[]
    WR.Add(',');
  end;
......
end;

#11 Re: mORMot 1 » about TJSONWriter... » 2020-10-28 07:38:53

i just tried 1.18.6152, the issue remained.

#12 Re: mORMot 1 » about TJSONWriter... » 2020-10-28 07:15:25

i used 1.18.6150, and i will try 1.18.6152.

#13 mORMot 1 » about TJSONWriter... » 2020-10-28 00:47:47

profh
Replies: 6

hi,ab:

    1. i call as follow under win10 with delphi10.4, it worked correct at all .
       

rtnjson := mySQLRestServerDB.DB.ExecuteJSON(asql,true,@rc);

    2. the same call above under win10 with lazarus1.9, it worked correct when i fetch less than about 100 records.
    3. the same call above under win10 with lazarus1.9, it worked discorrect when i fetch more than about 100 or 500 records. the issue in the return json is about like that:

        ..."recommand":0null,"recommand_unit":...
    or
        ...,"sex":1,"subjection":500111,"0000","rootc":"500100",...
    or other unusual pattern
     
    4. i debugged in TSQLRequest.FieldsToJSON, everything in "Request" is correct.

thank you very much!

#14 Re: mORMot 1 » How to put TDataModule in DLL with Lazarus » 2020-04-10 15:42:02

@ab, AOG:
after recompiled sqlite3.c and ecc.c with -fPIC option, it worked.

thanks to both of you!

#16 Re: mORMot 1 » How to put TDataModule in DLL with Lazarus » 2020-04-09 09:29:34

is it possible that static/x86_64-linux/sqlite3.o and static/x86_64-linux/ecclin64O2.o should be compiled with -fPIC option?

thanks!

#17 Re: mORMot 1 » How to put TDataModule in DLL with Lazarus » 2020-04-08 13:16:49

-Cg is the same as -fPIC,
i got the same error message with -Cg- in the custom options. sad

#18 Re: mORMot 1 » How to put TDataModule in DLL with Lazarus » 2020-04-08 08:46:09

i got the linking error as follow when built the shared library, and it worked correct if i bulit the executive program directly.

  Verbose: linker: /usr/bin/ld: mORMot/static/x86_64-linux/sqlite3.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
  Verbose: linker: /usr/bin/ld: mORMot/static/x86_64-linux/ecclin64O2.o: relocation R_X86_64_32S against `.data' can not be used when making a shared object; recompile with -fPIC

thanks!

#19 Re: mORMot 1 » How to put TDataModule in DLL with Lazarus » 2020-04-06 08:46:05

@ab, AOG:

yes, mORMot is source-first, so i gave up TDataModule and with fpcunit.TTestCase instead, it works.

many thanks!

#20 Re: mORMot 1 » How to put TDataModule in DLL with Lazarus » 2020-03-30 11:47:54

@AOG, thanks, it seems to be ok. and i will practice it in my project and reply the message later.

#21 Re: mORMot 1 » How to put TDataModule in DLL with Lazarus » 2020-03-28 22:05:38

Yes, it is a tiresome question about Lazarus/FPC, and i manage to avoid using TDataModule.

Is there any alternative? I have some components and predefined functions/procedures in it.
thanks.

#22 mORMot 1 » How to put TDataModule in DLL with Lazarus » 2020-03-28 15:27:07

profh
Replies: 13

sorry for the topic not related to mORMot.
   
i have a server with mORMot using Delphi 10.3.3 under Windwos Server for years , thanks for ab and the great team.
i create another server also with mORMot using Lazaris 1.9.0. under CentOS 7, i put TDataModule in DLL, it raised exception,
"Failed to initialize component class "TDataModule1": No streaming method available."

here is the code:

library mydll;
{$mode objfpc}{$H+}

Uses
  fastMM4,
{$IFDEF UNIX}
  cthreads,
{$ENDIF}
   classes, Sysutils, lcl;

type
  TDataModule1 = class(TDataModule)
  private
  public
  end;

var
  sl:TStringlist;
  DataModule1: TDataModule1;

begin
  sl:=TStringlist.Create;
  try
    DataModule1:= TDataModule1.create(nil);       <--error 
  except on e:exception do begin
    sl.Add('2:' + e.Message);
    sl.SaveToFile('c:\sl.txt');
  end;
  end;
  DataModule1.free;
  sl.free;
end.
    

thanks for help.

#23 Re: mORMot 1 » Delphi 64bit sqlite compilation » 2019-09-22 23:20:14

@ab, thanks, and you are my hero.

#25 Re: mORMot 1 » TSQLHttpServer.Create raised "access violation" under CentOS7(64) » 2018-08-27 11:08:59

@ab and mpv,

i used Paralles Virtual Machine, and just changed the network adapter configure,it works now.

thanks a lot for your time.

#26 Re: mORMot 1 » TSQLHttpServer.Create raised "access violation" under CentOS7(64) » 2018-08-27 10:28:11

i am not good at Linux.
i compiled and executed "04 - HTTP Client-Server" successful on CentOS 7(64) about six month ago, but this time it does not work.
so i think the error is not about mORMOt or pascal, or it is about CentOS permissions, and i missed something.

#27 Re: mORMot 1 » TSQLHttpServer.Create raised "access violation" under CentOS7(64) » 2018-08-27 10:09:19

thanks, mpv

i changed the port to 1234, and run:
firewall-cmd --permanent --add-port=1234/tcp
firewall-cmd --reload

it did not work.

#28 Re: mORMot 1 » TSQLHttpServer.Create raised "access violation" under CentOS7(64) » 2018-08-27 09:23:21

i debugged "04 - HTTP Client-Server" and got the messages as follow:

Exception class "ECrtSocket" at $00000000009E4F03 with message "OpenBind(0.0.0.0:8080,bind): CallServer=-1 99  [Cannot assign requested address]"

06fdf1b2069b9007.png

05ef744018f7f123.png

#29 Re: mORMot 1 » TSQLHttpServer.Create raised "access violation" under CentOS7(64) » 2018-08-27 02:17:10

thanks for your quick reply,ab.

i used  newpascal and Lazarus trunk.
i also used the latest mORMot and SQLite3fpc files, and compiled with no error.

i think the error is not about mORMOt or pascal,perhaps it is about CentOS permissions,I have no idea.
i will reinstall CentOS and try it again.
thanks again.

#30 mORMot 1 » TSQLHttpServer.Create raised "access violation" under CentOS7(64) » 2018-08-26 01:54:19

profh
Replies: 7

i have a server with mORMot running on Windows Server 2008, and it is stable and fast, many thanks to ab for the great work.

recently i would like to create a server running on CentOS7, i complied "04 - HTTP Client-Server" and changed Project04Server
permissions to "read and write", when i executed it,it raised "access violation" error.

i debugged it and found the breakpoint at "TSQLHttpServer.Create", maybe i missed something?

thanks!

#31 Re: mORMot 1 » WinHTTP, http.sys and WebSockets » 2017-11-14 13:26:26

Great work @mpv and ab, many thanks !!!
i am waiting for a THttpWebSocketServer of poll/epoll version under Unix/Linux... wink

#32 Re: mORMot 1 » using TSQLHttpServer under Windows server 2008 » 2017-06-23 03:15:32

every thing is ok whern i change TSQLHttpServer to THttpApiServer.

#33 Re: mORMot 1 » using TSQLHttpServer under Windows server 2008 » 2017-06-23 03:08:41

thanks,

i have a fast and stable RestServer using THttpApiServer for years, many thanks for you for the great mORMot framework.

i am thinking about to use one server and one port(perhaps,80) to provide RestServer and Websocket functions, for Websocket is a good choice for realtime chat,but THttpApiServer can not upgrade with WebSockets, so i think about to use TSQLHttpServer.

start a server using TSQLHttpServer with RestServer and Websocket is ok, but when client access the server:
1. running c:\ab32.exe -n 2 -c 1   http://127.0.0.1/echo.htm, Time per request is 5002.999 [ms] (mean), very solw.
2. i used TSQLRestClientURI to call CallBackPut, when posted data more than 8k, then the call.inbody at the server side will be different from the data sent by the client,when posted data is just one short line,everything is ok.

Best Regards.

#34 mORMot 1 » using TSQLHttpServer under Windows server 2008 » 2017-06-20 13:13:01

profh
Replies: 3

@ab,
    i used TSQLHttpServer to server as RestServer and WebSocket Server with the same port at the same time:
    1. when three or four clients connected the server, the server responsed very slow.
    2. if client posted data more than 8k, then the call.inbody at the server side will be different from the data sent by the client.
    3. when i used THttpApiServer, everything is ok.

Best Regards.

#37 Re: mORMot 1 » are there any table limitations? » 2016-10-16 02:39:24

it stoped at TSQLModelRecordProperties.Create of mORMot.pas.

 

  constructor TSQLModelRecordProperties.Create(aModel: TSQLModel;
  aTable: TSQLRecordClass; aKind: TSQLRecordVirtualKind);
  var f: integer;
  ...
  fProps := aTable.RecordProps;          <------------------stoped here.
  ...
  

#38 mORMot 1 » are there any table limitations? » 2016-10-16 02:35:22

profh
Replies: 3

i have a TSQLRecord defined as follow:

  Ttjxx = class(TSQLRecord)
  private
    fpid:integer;
    fKSH:RawUTF8;
    fTJXH: RawUTF8;
    fJWBSBZ:RawUTF8;
    fJWBS: RawUTF8;
    fYK_LYSLY:currency;
    fYK_LYSLZ: currency;
    fYK_JZSLY:currency;
    fYK_JZSLZ: currency;
    fYK_JZDSY:currency;
    fYK_JZDSZ: currency;
    fYK_SJJC:RawUTF8;
    fYK_SJJCT: RawUTF8;
    fYK_SJDS1:RawUTF8;
    fYK_SJDS2: RawUTF8;
    fYK_SJDS3:RawUTF8;
    fYK_SJDS4: RawUTF8;
    fYK_SJDS5:RawUTF8;
    fYK_YSYJ: RawUTF8;
    fYK_YB: RawUTF8;
    fNK_XYSSY: currency;
    fNK_XYSZY:currency;
    fNK_FYQK: RawUTF8;
    fNK_XZJXG:RawUTF8;
    fNK_HXXT: RawUTF8;
    fNK_SJXT: RawUTF8;
    fNK_G: currency;
    fNK_GXZ: RawUTF8;
    fNK_P: currency;
    fNK_PXZ:RawUTF8;
    fNK_YSYJ: RawUTF8;
    fNK_QT: RawUTF8;
    fWK_SG: currency;
    fWK_TZ: currency;
    fWK_PF: RawUTF8;
    fWK_MB:RawUTF8;
    fWK_JB: RawUTF8;
    fWK_JZ: RawUTF8;
    fWK_SZ: RawUTF8;
    fWK_GJ:RawUTF8;
    fWK_YSYJ: RawUTF8;
    fWK_QT: RawUTF8;
    fEB_ZETL: currency;
    fEB_YETL: currency;
    fEB_XJ: RawUTF8;
    fEB_YSYJ:RawUTF8;
    fEB_EBYH: RawUTF8;
    fKQ_CE: RawUTF8;
    fKQ_SFKC: RawUTF8;
    fKQ_YC:RawUTF8;
    fKQ_YSYJ: RawUTF8;
    fKQ_QT: RawUTF8;
    fXT: RawUTF8;
    fXT_YSYJ:RawUTF8;
    fXT_QT: RawUTF8;
    fGG_ZAM: RawUTF8;
    fGG_YGKY: RawUTF8;
    fGG_YSYJ:RawUTF8;
    fGG_QT: RawUTF8;
    fZYSXDM1: RawUTF8;
    fZYSXDM2: RawUTF8;
    fZYSXDM3:RawUTF8;
    fZYSXDM4: RawUTF8;
    fZYSXDM5: RawUTF8;
    fZYSXDM6: RawUTF8;
    fTJJLDM:RawUTF8;
    fBZ: RawUTF8;
  published
    property pid: integer read fpid write fpid;
    property KSH: RawUTF8 read fKSH write fKSH;
    property TJXH: RawUTF8 read fTJXH write fTJXH;
    property JWBSBZ: RawUTF8 read fJWBSBZ write fJWBSBZ;
    property JWBS: RawUTF8 read fJWBS write fJWBS;
    property YK_LYSLY: currency read fYK_LYSLY write fYK_LYSLY;
    property YK_LYSLZ: currency read fYK_LYSLZ write fYK_LYSLZ;
    property YK_JZSLY: currency read fYK_JZSLY write fYK_JZSLY;
    property YK_JZSLZ: currency read fYK_JZSLZ write fYK_JZSLZ;
    property YK_JZDSY: currency read fYK_JZDSY write fYK_JZDSY;
    property YK_JZDSZ: currency read fYK_JZDSZ write fYK_JZDSZ;
    property YK_SJJC: RawUTF8 read fYK_SJJC write fYK_SJJC;
    property YK_SJJCT: RawUTF8 read fYK_SJJCT write fYK_SJJCT;
    property YK_SJDS1: RawUTF8 read fYK_SJDS1 write fYK_SJDS1;
    property YK_SJDS2: RawUTF8 read fYK_SJDS2 write fYK_SJDS2;
    property YK_SJDS3: RawUTF8 read fYK_SJDS3 write fYK_SJDS3;
    property YK_SJDS4: RawUTF8 read fYK_SJDS4 write fYK_SJDS4;
    property YK_SJDS5: RawUTF8 read fYK_SJDS5 write fYK_SJDS5;
    property YK_YSYJ: RawUTF8 read fYK_YSYJ write fYK_YSYJ;
    property YK_YB: RawUTF8 read fYK_YB write fYK_YB;
    property NK_XYSSY: currency read fNK_XYSSY write fNK_XYSSY;
    property NK_XYSZY: currency read fNK_XYSZY write fNK_XYSZY;
    property NK_FYQK: RawUTF8 read fNK_FYQK write fNK_FYQK;
    property NK_XZJXG: RawUTF8 read fNK_XZJXG write fNK_XZJXG;
    property NK_HXXT: RawUTF8 read fNK_HXXT write fNK_HXXT;
    property NK_SJXT: RawUTF8 read fNK_SJXT write fNK_SJXT;
    property NK_G: currency read fNK_G write fNK_G;
    property NK_GXZ: RawUTF8 read fNK_GXZ write fNK_GXZ;
    property NK_P: currency read fNK_P write fNK_P;
    property NK_PXZ: RawUTF8 read fNK_PXZ write fNK_PXZ;
    property NK_YSYJ: RawUTF8 read fNK_YSYJ write fNK_YSYJ;
    property NK_QT: RawUTF8 read fNK_QT write fNK_QT;
    property WK_SG: currency read fWK_SG write fWK_SG;
    property WK_TZ: currency read fWK_TZ write fWK_TZ;
    property WK_PF: RawUTF8 read fWK_PF write fWK_PF;
    property WK_MB: RawUTF8 read fWK_MB write fWK_MB;
    property WK_JB: RawUTF8 read fWK_JB write fWK_JB;
    property WK_JZ: RawUTF8 read fWK_JZ write fWK_JZ;
    property WK_SZ: RawUTF8 read fWK_SZ write fWK_SZ;
    property WK_GJ: RawUTF8 read fWK_GJ write fWK_GJ;
    property WK_YSYJ: RawUTF8 read fWK_YSYJ write fWK_YSYJ;
    property WK_QT: RawUTF8 read fWK_QT write fWK_QT;
    property EB_ZETL: currency read fEB_ZETL write fEB_ZETL;
    property EB_YETL: currency read fEB_YETL write fEB_YETL;
    property EB_XJ: RawUTF8 read fEB_XJ write fEB_XJ;
    property EB_YSYJ: RawUTF8 read fEB_YSYJ write fEB_YSYJ;
    property EB_EBYH: RawUTF8 read fEB_EBYH write fEB_EBYH;
    property KQ_CE: RawUTF8 read fKQ_CE write fKQ_CE;
    property KQ_SFKC: RawUTF8 read fKQ_SFKC write fKQ_SFKC;
    property KQ_YC: RawUTF8 read fKQ_YC write fKQ_YC;
    property KQ_YSYJ: RawUTF8 read fKQ_YSYJ write fKQ_YSYJ;
    property KQ_QT: RawUTF8 read fKQ_QT write fKQ_QT;
    property XT: RawUTF8 read fXT write fXT;
    property XT_YSYJ: RawUTF8 read fXT_YSYJ write fXT_YSYJ;
    property XT_QT: RawUTF8 read fXT_QT write fXT_QT;
    property GG_ZAM: RawUTF8 read fGG_ZAM write fGG_ZAM;
    property GG_YGKY: RawUTF8 read fGG_YGKY write fGG_YGKY;
    property GG_YSYJ: RawUTF8 read fGG_YSYJ write fGG_YSYJ;
    property GG_QT: RawUTF8 read fGG_QT write fGG_QT;
    property ZYSXDM1: RawUTF8 read fZYSXDM1 write fZYSXDM1;
    property ZYSXDM2: RawUTF8 read fZYSXDM2 write fZYSXDM2;
    property ZYSXDM3: RawUTF8 read fZYSXDM3 write fZYSXDM3;
    property ZYSXDM4: RawUTF8 read fZYSXDM4 write fZYSXDM4;
    property ZYSXDM5: RawUTF8 read fZYSXDM5 write fZYSXDM5;
    property ZYSXDM6: RawUTF8 read fZYSXDM6 write fZYSXDM6;
    property TJJLDM: RawUTF8 read fTJJLDM write fTJJLDM;
    property BZ: RawUTF8 read fBZ write fBZ;
  end;

  when i create TSQLModel as follow, it failed with message "Access violation ad address 007CC7F4 in module 'project.exe', Read of address 00000004".
 

 myModel := TSQLModel.Create([Ttjxx],'');

  but many simple TSQLRecord s work fine.

  thanks.

#41 Re: mORMot 1 » Http Error 406 » 2015-10-26 06:43:51

it works after i modify the code of THttpApiServer.Execute in SynCrtSock.pas:

from:

              Err := Http.ReceiveRequestEntityBody(fReqQueue,Req^.RequestId,flags,
                BufRead,InContentLength-InContentLengthRead,BytesRead);

to:

              Err := Http.ReceiveRequestEntityBody(fReqQueue,Req^.RequestId,flags,
                BufRead,2048,BytesRead);

and i can upload file more than 1024M now.

#42 Re: mORMot 1 » Http Error 406 » 2015-10-25 07:28:14

i found that Http.ReceiveRequestEntityBody got 1450 result.

#43 mORMot 1 » Http Error 406 » 2015-10-25 05:41:53

profh
Replies: 5

ab,

i post a 350M file separately to two servers, server with windows 10 works fine, but client got Http Error 406 message from server with windows server 2003.
is it about default file size limitation?

thanks.

#44 Re: mORMot 1 » about mutiply cookies » 2015-05-13 10:01:36

function TMyW3Server.process(Ctxt: THttpServerRequest): cardinal;
var
  dwsfat:TFileAccessType;
  pathFileName : String;
  params : String;
  infoCache : TFileAccessInfoCache;
  request : THttpSysWebRequest;
  response : THttpSysWebResponse;
  fileAttribs : Cardinal;
...
begin
...
      if Pos('\.', pathFileName)>0 then
        // Directories or files beginning with a '.' are invisible
        fileAttribs:=INVALID_FILE_ATTRIBUTES
      else if not StrBeginsWith(pathFileName, FPath) then
      begin
        // request is outside base path
        Ctxt.OutContent:='<h1>Not authorized</h1>';
        Ctxt.OutContentType:=cHTMTL_UTF8_CONTENT_TYPE;
        Result:=401;
        Exit;
      end
      else
      begin
        {$WARN SYMBOL_PLATFORM OFF}
        fileAttribs:=GetFileAttributes(Pointer(pathFileName));
        if fileAttribs<>INVALID_FILE_ATTRIBUTES then begin
           if (fileAttribs and faHidden)<>0 then
              fileAttribs:=INVALID_FILE_ATTRIBUTES;
        end;
        {$WARN SYMBOL_PLATFORM ON}

      end;

      if fileAttribs=INVALID_FILE_ATTRIBUTES then
      begin
        Ctxt.OutContent:='<h1>Not found</h1>';
        Ctxt.OutContentType:=cHTMTL_UTF8_CONTENT_TYPE;
        Result:=404;
        Exit;
      end else if StrEndsWith(pathFileName, '.dws') then
      begin
        request := THttpSysWebRequest.Create;
        response := THttpSysWebResponse.Create;
        try
          request.ResetCookies;
          request.ResetQueryFields;
          request.ResetContentFields;
          request.ResetFields;
          request.PathInfo := rtntext;
          request.InURL := Ctxt.URL;
          request.InHeaders := Ctxt.InHeaders;
          request.InMethord := Ctxt.Method;
          request.QueryString := query;
          request.InContent := Ctxt.InContent;
          request.InContentType := Ctxt.InContentType;
          request.InRemoteIP := remoteip;
          request.InUserAgent := agent;
          request.InSecurity := 'No Security';
//           case Ctxt.AuthenticationStatus of
//              hrsSSL : request.Security:=Format('SSL, %d bits', [Ctxt.SecurityBytes*8]);
//           else
//              request.Security:='';
//           end;

           response.StatusCode:=200;
           response.ContentType:=cHTMTL_UTF8_CONTENT_TYPE;
             infoCache:=TFileAccessInfoCache(request.Custom);
          if infoCache=nil then begin
            infoCache:=TFileAccessInfoCache.Create(FileAccessInfoCacheSize);
            request.Custom:=infoCache;
            infoCache.CacheCounter:=FCacheCounter;
          end else if infoCache.CacheCounter<>FCacheCounter then begin
            infoCache.Flush;
            infoCache.CacheCounter:=FCacheCounter;
          end;

           FDWS.HandleDWS(pathFileName,dwsfat, request, response,[]);

           Ctxt.OutContent:=response.ContentData;
           Ctxt.OutContentType:=response.ContentType;
           Ctxt.OutCustomHeaders := Ctxt.OutCustomHeaders + #13#10 + nocacheheaderstr;

           if response.HasHeaders then
              Ctxt.OutCustomHeaders:=Ctxt.OutCustomHeaders + #13#10+
                                                       response.CompiledHeaders;
           Result:=response.StatusCode;
        finally
           request.Free;
           request := nil;
           response.Free;
           response := nil;
        end;
      end;
...
end;

#45 Re: mORMot 1 » about mutiply cookies » 2015-05-12 23:53:12

i got it, and i will use "Set-Cookie: myCookie=1111111,22222222" instead.

BTW, i have accomplished dws within mORMot, see http://synopse.info/forum/viewtopic.php?id=947.
thanks ab and Eric, you are really so great!

#46 Re: mORMot 1 » about mutiply cookies » 2015-05-12 14:46:23

just get one cookie at the same time, the first one or the second one,  using each of the following code:

Ctxt.OutCustomHeaders := Ctxt.OutCustomHeaders + #13#10+ 'Set-Cookie: a=1111111111; b=22222222';
Ctxt.OutCustomHeaders := Ctxt.OutCustomHeaders + #13#10+ 'Set-Cookie: a=1111111111, b=22222222';
Ctxt.OutCustomHeaders := Ctxt.OutCustomHeaders + #13#10+ 'Set-Cookie: a=1111111111; b=22222222;';
Ctxt.OutCustomHeaders := Ctxt.OutCustomHeaders + #13#10+ 'Set-Cookie: a=1111111111;, b=22222222;';

#47 Re: mORMot 1 » about mutiply cookies » 2015-05-12 11:52:57

ab wrote:

Ctxt.OutCustomHeaders := Ctxt.OutCustomHeaders + #13#10+ 'Set-Cookie: a=1111111111; b=22222222';

with this code, just get the first one, 'b=22222222' is still missing.

#48 mORMot 1 » about mutiply cookies » 2015-05-12 04:47:16

profh
Replies: 8

hi,ab

  i need to set more than one cookie key/value, but just the last one will be sent to the client. the code is as follow:

Ctxt.OutCustomHeaders := Ctxt.OutCustomHeaders + #13#10+ 
              'Set-Cookie: a=1111111111' + #13#10 + 'Set-Cookie: b=22222222';

  in the client response header, just get 'Set-Cookie: b=22222222'' string, and 'Set-Cookie: a=1111111111' is missing.

thanks!

#49 Re: mORMot 1 » HTTP Server / DWScript » 2015-04-07 22:36:53

That is what I did.
DWS has a sample "HttpSys2WebServer", it used TWebRequest/TWebResponse parameters for FDWS.HandleDWS procedure, that is why I asked you how to prepare TWebRequest from THttpServerRequest.
It will be great if THttpServerRequest provides the TWebRequest information.

#50 Re: mORMot 1 » HTTP Server / DWScript » 2015-04-07 15:59:50

The 2nd option would be preferred, and I would like to get started with it.
I planned to script it in the onrequest procedure of mORMot server, or should I use the WebSocket?
Many thanks.

Board footer

Powered by FluxBB