#51 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.

#52 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!

#53 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.

#54 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.

#55 Re: mORMot 1 » HTTP Server / DWScript » 2015-04-07 13:03:00

ab, Could you include TWebRequest item in THttpServerRequest?

#56 Re: mORMot 1 » about UNICODE of DataSetToJSON in SynVirtualDataSet » 2015-04-06 15:21:41

i got it, in Delphi XE7, just as follow:

procedure TForm1.utf8ansiClick(Sender: TObject);
var
  sl:TStringlist;
  aa:tbytes;
begin
  sl:=TStringlist.Create;
  sl.LoadFromFile('c:\1.txt');
  Memo1.Lines.Add(sl.Text);
  aa := TEnCoding.UTF8.GetBytes(sl.Text);
  e1.Text := StringOf(aa);
  e2.Text := TEnCoding.utf8.GetString(aa);
  ......
end;

thanks,ab.

#57 Re: mORMot 1 » about UNICODE of DataSetToJSON in SynVirtualDataSet » 2015-04-06 14:58:57

perhaps it is the difference between delphi XE7 and delphi 7, i try to understand it.

#58 Re: mORMot 1 » HTTP Server / DWScript » 2015-04-06 14:49:55

sorry for my english,ab.
i know how to get remoteip from CallContext, but don't know how to assign it to TWebRequest. sad

#59 Re: mORMot 1 » HTTP Server / DWScript » 2015-04-06 12:47:21

   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...?

#60 Re: mORMot 1 » HTTP Server / DWScript » 2015-04-06 09:56:34

i did, i used THttpServerRequest in my mORMotHttpServer server. but FDWS.HandleDWS should handle TWebRequest/TWebResponse parameters.

#61 Re: mORMot 1 » HTTP Server / DWScript » 2015-04-06 07:47:40

i am thinking about to use DWS within mORMot Framework.
in sample "HttpSys2WebServer", procedure "FDWS.HandleDWS" used TWebRequest and TWebResponse as parameters, but how to translate THttpServerRequest to TWebRequest in my server?

thanks.

#62 Re: mORMot 1 » about UNICODE of DataSetToJSON in SynVirtualDataSet » 2015-04-05 04:00:07

everything is ok under delphi 7.
under delphi XE7,  function DataSetToJSON got the expected result also if not including chinese words.

i found that under delphi XE7 and delphi 7, function stringtoutf8 got different result with the same source string including chinese words.

#63 Re: mORMot 1 » about UNICODE of DataSetToJSON in SynVirtualDataSet » 2015-04-04 09:17:19

i just use XE7 from Delphi7, and the chinese words from database are also abnormal with  function DataSetToJSON in SynVirtualDataSet.pas.

#66 Re: mORMot 1 » about UNICODE of DataSetToJSON in SynVirtualDataSet » 2014-09-23 23:43:11

My field data type is varchar(255) with utf8-bin charset in mysql,  and i use TZReadOnlyQuery of Zeoslib to query data from mysql, then call DataSetToJSON to get JSON data, so i don't know where to define the field as ftWideString, and not ftString.

Should i define UNICODE in Synopse.inc?

Thanks.

#68 Re: mORMot 1 » about UNICODE of DataSetToJSON in SynVirtualDataSet » 2014-09-23 08:47:06

but it is meaningful for me sad.

if i changed the code above, i always got the right data including chinese words from database, or sometimes broken data.

#69 Re: mORMot 1 » about UNICODE of DataSetToJSON in SynVirtualDataSet » 2014-09-22 23:20:22

it is a ftString, ftFixedChar or ftMemo one, like this:

        ftString, ftFixedChar, ftMemo: begin
          W.Add('"');
          W.AddAnsiString({$ifdef UNICODE}AsAnsiString{$else}AsString{$endif},
            twJSONEscape);
          W.Add('"');
        end;

if define UNICODE, should use W.AddAnsiString for AsAnsiString, else W.AddString for AsString, as follow:

        ftString, ftFixedChar, ftMemo: begin
          W.Add('"');
          {$ifdef UNICODE}
            W.AddAnsiString(AsAnsiString,twJSONEscape);
          {$else}
            W.AddString(AsString);
          {$endif}
          W.Add('"');
        end;

#70 mORMot 1 » about UNICODE of DataSetToJSON in SynVirtualDataSet » 2014-09-22 15:42:36

profh
Replies: 17

hi,ab

i think that the following code of function DataSetToJSON in SynVirtualDataSet.pas

          W.AddAnsiString({$ifdef UNICODE}AsAnsiString{$else}AsString{$endif},
            twJSONEscape);

should be

          {$ifdef UNICODE}
            W.AddAnsiString(AsAnsiString,twJSONEscape);
          {$else}
            W.AddString(AsString);
          {$endif}

#71 Re: mORMot 1 » Best way to upload a binary file (AJAX client) » 2014-09-20 21:56:26

got it.
after a little while, without request, the memory usage of server will decrease.

thanks again.

#72 Re: mORMot 1 » Best way to upload a binary file (AJAX client) » 2014-09-20 00:37:08

you are absolutely right, after certain of requests the memory usage is not continue increasing.
and thank you so much.

#73 Re: mORMot 1 » Best way to upload a binary file (AJAX client) » 2014-09-19 16:52:25

it is strange, and it really bothers me for a little while.

#74 Re: mORMot 1 » Best way to upload a binary file (AJAX client) » 2014-09-19 14:02:15

please note that i just post data to server from client, and the server did not handle the data at all.
it seems that the server will be attacked by continuing data whatever the client postes.

#75 Re: mORMot 1 » Best way to upload a binary file (AJAX client) » 2014-09-19 13:53:18

i used the latest version, and i enabled EnableMemoryLeakReporting, but no memory leak reported.

#76 Re: mORMot 1 » Best way to upload a binary file (AJAX client) » 2014-09-19 09:52:42

i did it because i need to post data from browser, but REST methord can not be used in browser as usual .

#77 Re: mORMot 1 » Best way to upload a binary file (AJAX client) » 2014-09-19 09:32:37

i compiled "13 - StandAlone JSON SQL server" without changing any thing, and run the JSONSQLServer.exe, then used the code below to post data to the server, not post of REST, but post of URL, the memory of server kept increasing after each data was posted to the server.

procedure TForm8.Button11Click(Sender: TObject);
var
  tmpstream:TMemoryStream;
  ab:boolean;
  HTTP: THTTPSend;
  url:string;
  slist:TStringlist;
begin
  tmpstream := TMemoryStream.Create;
  HTTP := THTTPSend.Create;
  slist:=TStringlist.Create;
  try
    url := 'http://localhost:888/root';
    tmpstream.LoadFromFile('c:\rtl70.bpl');
    tmpstream.Position := 0;
    ab := HttpPostFile(url,'abc','def',tmpstream,slist);
    ... ...
  finally
    tmpstream.Free;
    HTTP.Free;
    slist.free;
  end;
end;

#78 Re: mORMot 1 » Best way to upload a binary file (AJAX client) » 2014-09-09 04:59:11

many thanks to all of you.

but i have another issue:
the memory of server kept increasing after each Binary Data was posted to the server, even if the server did not handle it at all.

#79 Re: mORMot 1 » using SynCrypto for aes/ecb/PKCS5padding » 2013-12-15 14:01:32

using sample SymmetricCrypto from http://www.torry.net/vcl/security/stron … boxvcl.zip, i got the same result "C97554911E393C5CF451FA5B0C1F3F7B", but i prefer to use syncrypto.

thanks.

#80 Re: mORMot 1 » using SynCrypto for aes/ecb/PKCS5padding » 2013-12-15 10:45:09

with SynCrypto:
plaintext:123456
key:1234567890123456
result:BBB958B46D43174355EBBCACDDE1A171

is the result above correct with PKCS#7?
Could you add a function as EncryptPKCS5?
i just want them to get the same result "C97554911E393C5CF451FA5B0C1F3F7B" to work together.

#81 Re: mORMot 1 » using SynCrypto for aes/ecb/PKCS5padding » 2013-12-15 01:53:34

i use delphi 7, but i can not get the result: C97554911E393C5CF451FA5B0C1F3F7B.

#82 mORMot 1 » using SynCrypto for aes/ecb/PKCS5padding » 2013-12-14 07:39:46

profh
Replies: 5

i used SynCrypto to encrypt plaintext with aes/ecb/PKCS7padding, but the encrypted text was different from the one encrypted using Wcrypt2 from http://delphi-jedi.org.
i need the encrypted text could be used by php, but i can not manage it.

here is my code:

function EncryptMsgData(MsgData, Key: string): string;
var
  i:integer;
  ECB:TAESECB;
  iv:TAESBlock;
begin
  Result:= '';
  for i:=0 to 15 do 
  begin
    if i > (length(Key) - 1) then
      iv[i] := 0
    else
      iv[i] := byte(Key[i + 1]);
  end;
  try
    ECB := TAESECB.Create(Key,128,iv);
    result := ECB.EncryptPKCS7(MsgData);
  finally
    ECB.Free;
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  CText.Text := strtohex(EncryptMsgData('123456','1234567890123456'));
end;

with SynCrypto:
plaintext:123456
key:1234567890123456
result:BBB958B46D43174355EBBCACDDE1A171

with wcrypt2(aes/ecb/PKCS5padding)
plaintext:123456
key:1234567890123456
result:C97554911E393C5CF451FA5B0C1F3F7B


by the way, how to create TAESECB from SynCrypto without IV, and function EncryptPKCS5 is missing.

thanks.

#83 Re: mORMot 1 » CallBackPut crashed on windows 2008 server » 2013-09-06 13:32:15

thanks, after i recompile all units, it works now.

by the way, mORMots are really great, and do run fast...

thanks again.

#84 Re: mORMot 1 » CallBackPut crashed on windows 2008 server » 2013-09-06 10:45:08

yes, i am using the latest version, and the Client instance class is TSQLRestClientURI defined as follow:

    Client:TSQLRestClientURI;

#85 Re: mORMot 1 » CallBackPut crashed on windows 2008 server » 2013-09-06 07:53:07

i just call it on windows 2003 server , it is ok.

#86 mORMot 1 » CallBackPut crashed on windows 2008 server » 2013-09-06 07:37:47

profh
Replies: 6

the following call works fine on windows xp and win7, but it crashed on windows 2008 server:

    TSQLHttpClient(Client).CallBackPut('rpcname',RUTF8,rtnutf8); 

the actually position is in  TSQLRestClientURI.URI of mORMot.pas as follow:

......
DoRetry:
    if fSessionAuthentication=nil then
      Call.Url := url else
      Call.Url := fSessionAuthentication.ClientSessionSign(self,url);
    Call.Method := method;
    if SendData<>nil then
      Call.InBody := SendData^;
{$ifndef LVCL}
    if Assigned(fOnIdle) then begin
      if fBackgroundThread=nil then
        fBackgroundThread := TSynBackgroundThreadEvent.Create(OnIdle,OnBackgroundProcess);
      if not fBackgroundThread.AsynchRun(@Call) then
        Call.OutStatus := HTML_UNAVAILABLE;
    end else
{$endif}
    begin
      InternalURI(Call);              <<------------- crashed here
      if Call.OutStatus=HTML_NOTIMPLEMENTED then begin // InternalCheckOpen failed
        InternalClose;     // force recreate connection
        InternalURI(Call); // try request again
      end;
    end;
    result.Lo := Call.OutStatus;
    result.Hi := Call.OutInternalState;
    if Head<>nil then
      Head^ := Call.OutHead;
    if Resp<>nil then
      Resp^ := Call.OutBody;
    fLastErrorCode := Call.OutStatus;
    if (Call.OutStatus=HTML_TIMEOUT) and aRetryOnceOnTimeout then begin
      aRetryOnceOnTimeout := false;
{$ifdef WITHLOG}
      SQLite3Log.Add.Log(sllError,'% % returned "408 Request Timeout" -> RETRY',
        [method,url],self);
{$endif}
      goto DoRetry;
    end;
......

#87 Re: PDF Engine » emf2pdf » 2013-05-23 14:58:58

fScaleY is always 0.75
font.LogFont.lfHeight < 0
font.spec.cell = abs(font.LogFont.lfHeight)

as follow:

ASize  font.LogFont.lfHeight font.spec.cell
------------------------------------------
87.75,-117,117
87.75,-117,117
87.75,-117,117
87.75,-117,117
75,-100,100
75,-100,100
75,-100,100
75,-100,100
87.75,-117,117
87.75,-117,117
87.75,-117,117
87.75,-117,117
87.75,-117,117
87.75,-117,117
87.75,-117,117
87.75,-117,117
87.75,-117,117
87.75,-117,117
87.75,-117,117
75,-100,100
75,-100,100
75,-100,100
75,-100,100
87.75,-117,117
87.75,-117,117
87.75,-117,117
......


but i am not sure which one is not correct.

#88 Re: PDF Engine » emf2pdf » 2013-05-23 13:13:58

in procedure TPdfEnum.TextOut(var R: TEMRExtTextOut) of SynPdf.pas, the following code:

    if font.LogFont.lfHeight<0 then
      ASize := Abs(font.LogFont.lfHeight)*fscaleY else
      ASize := Abs(font.spec.cell)*fscaleY;

the value of ASize ,sometimes is 66, sometimes is 4.27450962518871E-39, i guess ASize is not correct sometimes.

#89 Re: PDF Engine » emf2pdf » 2013-05-20 12:12:40

the font name is "宋体" in chinese.

#90 Re: PDF Engine » emf2pdf » 2013-05-20 11:52:34

i use delphi7 and the latest great mORMot.

thanks.

#91 Re: PDF Engine » emf2pdf » 2013-05-19 15:42:05

i change line 5827 of synpdf.pas

from:

RawUnicodeToUtf8(ALogFont.lfFaceName,StrLenW(ALogFont.lfFaceName));

to:

AName := ALogFont.lfFaceName;


then the following code can render emf file including all chinese words into pdf file:

procedure TForm1.Button6Click(Sender: TObject);
var
  emf : TMetafile;
  Pdf: TPdfDocument;
begin
  emf := TMetafile.Create;
  Pdf := TPdfDocument.Create;

  try
    emf.LoadFromFile('c:\emf\21.emf');
    Pdf.EmbeddedTTF := True;
    pdf.StandardFontsReplace := true;
    pdf.PDFA1 := true;
    Pdf.UseFontFallBack := true;
    Pdf.FontFallBackName := 'Arial Unicode MS';
    Pdf.DefaultPageWidth := MulDiv(emf.Width,72,Pdf.ScreenLogPixels);
    Pdf.DefaultPageHeight := MulDiv(emf.Height,72,Pdf.ScreenLogPixels);
    Pdf.AddPage;
    Pdf.Canvas.RenderMetaFile(emf);
    pdf.SaveToFile('c:\emf\test.pdf');
  finally
    FreeAndNil(emf);
    FreeAndNil(pdf);
  end;
end;

but the position and size of some words are unusual.

i sent an email with "pdf from emf.jpg" and "emf21.emf" to webcontact01 at synopse.info, please check it.

#92 Re: PDF Engine » emf2pdf » 2013-04-09 03:18:54

i use htm2pdf in the latest package from http://synopse.info/fossil/wiki/Synopse+OpenSource, and open a html file with chinese words, then save html file to pdf file, the chinese words are still missing in the output pdf file, but the metafile produced by htmlview contains all things in the html file.

could you give me a sample, many thanks.

#93 Re: PDF Engine » emf2pdf » 2013-04-08 09:58:20

DrawAntiAliased in SynGdiPlus.pas is like this:

procedure TGDIPlus.DrawAntiAliased(Source: TMetafile; Dest: HDC; R: TRect;
  aSmoothing: TSmoothingMode; aTextRendering: TTextRenderingHint);
begin
  dec(R.Right);
  dec(R.Bottom); // Metafile rect includes right and bottom coords
  PlayEnhMetaFile(Dest,Source.Handle,R); // use GDI drawing by default
end;

but PlayEnhMetaFile is a windows function, i can not step in it.

#94 Re: PDF Engine » emf2pdf » 2013-04-08 09:34:16

i download ARIALUNI.TTF from http://anonym.to/?http://sourceforge.ne … nts/files/, and then set FontFallBackName like this:

PdfDoc.FontFallBackName := 'Arial Unicode MS';

the chinese words are still missing.

i also download synpdfunicode_test.rar  from https://cdn.anonfiles.com/1363978013590.rar , and it works as expected.

BTW,i am using the latest code.

#95 Re: PDF Engine » emf2pdf » 2013-04-08 08:19:26

procedure TForm1.Button3Click(Sender: TObject);
var
  Gdip:TGDIPlusFull;
  emf:TMetaFile;
begin
  Gdip := TGDIPlusFull.Create;
  emf := TMetaFile.Create;
  try
    emf.LoadFromFile('c:\emf\1.emf');
    gdip.DrawAntiAliased(emf,PaintBox1.Canvas.Handle,Rect(0,0,300,500));
  finally
    emf.Free;
    Gdip.Free;
  end;
end;

PaintBox1 can display all of the emf file including chinese words and bitmap.

if i change above code as the following, the produced pdf file just contains bitmap,but no chinese words at all.

procedure TForm1.Button2Click(Sender: TObject);
const
  OutputFileName = 'c:\emf\1.pdf';
  InputFileName = 'c:\emf\1.emf';
var
  PdfDoc: TPDFDocumentGDI;
  PdfPage: TPdfpage;
  Emf: TMetafile;
begin
  Emf := TMetafile.Create();
  Emf.LoadFromFile(InputFileName);

  PdfDoc := TPdfDocumentGDI.Create;
  PdfDoc.UseFontFallBack := true;
  PdfDoc.CompressionMethod := cmFlateDecode;
  PdfDoc.DefaultPaperSize := psUserDefined;
  PdfPage := PdfDoc.AddPage();
  PdfPage.PageWidth := Round(72 * Emf.MMWidth / 2540);
  PdfPage.PageHeight := Round(72 * Emf.MMHeight / 2540);
  gdip.DrawAntiAliased(emf,PdfDoc.VCLCanvas.Handle,Rect(0, 0,
//gdip.DrawAntiAliased(emf,PaintBox1.Canvas.Handle,Rect(0, 0,
      Round(Screen.PixelsPerInch * Emf.MMWidth / 2540),
      Round(Screen.PixelsPerInch * Emf.MMHeight / 2540)));

  PdfDoc.SaveToFile(OutputFileName);
  PdfDoc.Free();

  FreeAndNil(Emf);
end;

#96 Re: mORMot 1 » export the SAD document as pdf (for Office 2007+), » 2013-02-18 07:56:58

absolutely, i tried the latest versions, no error message popuped, but no chinese words displayed in pdf file.

now, i use adobe virtual printer and ghostscript to produce pdf files from doc files, but it is so complicated, and ghostscript file is too big to install.

#97 Re: mORMot 1 » export the SAD document as pdf (for Office 2007+), » 2013-02-18 06:45:41

thanks, and i is a bad news for me.

see http://synopse.info/forum/viewtopic.php?id=42, i can generate correct emf files from doc file using adobe virtual printer, but i still can not translate the emf files into pdf file using synpdf, because the chinese fonts are unusual.

#98 mORMot 1 » export the SAD document as pdf (for Office 2007+), » 2013-02-18 04:18:39

profh
Replies: 5

i noticed http://synopse.info/fossil/info/4f99e33ea0 just before, and i compiled SynProject, and it worked fine.

i use win7 + office2007 + 2007 Microsoft Office Add-in: Microsoft Save as PDF or XPS in my computer, but i copied SynProject.exe to another computer with win7 + office2007 only, it did not work, error mesage was "Error during the document creation. Did'nt you miss a \ or a } in your text?".

is it necessary to install 2007 Microsoft Office Add-in to export the SAD document as pdf? indeed, i need save ms document file as emf, pdf or swf file directly without Add-in.

thanks.

#99 Re: mORMot 1 » how to parse post data which includes "&" as content? » 2012-09-26 07:09:50

sorry,i made a mistake.

i should parse the post data before call urldecode.

thanks, ab.

#100 Re: mORMot 1 » how to parse post data which includes "&" as content? » 2012-09-26 06:55:58

i parsed it using "&" as Delimiter,so i got the result as follow:

var1 = value1
var2 = a.php?varphp1=valuephp1
varphp2 = valuephp2
var3 = value3

but it is not what i need.

Board footer

Powered by FluxBB