#1 Re: mORMot 1 » SynCrtSock TWinHTTP Problem » 2017-09-21 18:46:49

I see!
But if server doesn't exist (winhttp error code 12007) than I become error 12019. If it must be so and you mean that this is correct, than I will change my code only - I still need correct error code at end sad
Why must it be so designed!?

#2 Re: mORMot 1 » SynCrtSock TWinHTTP Problem » 2017-09-21 18:02:59

What I mean is that there are very serious bugs in SynCrtSock.
Actually errors are just ignored and for sure no one need such code. What I've expected was to work with WinHTTP and to receive needed information correctly.

OK. I've made some little changes in your code. Must I send them to git or you can fix errors alone?
Problem is very clear described: in procedure TWinHTTP.InternalSendRequest, if HTTPS is True mostly error codes received from WinHTTP are just ignored.

#3 Re: mORMot 1 » SynCrtSock TWinHTTP Problem » 2017-09-21 14:27:07

And it is clear bug - after short research I found it.
Actually I do not understand this piece of logic there sad  Also,  in SynCrtSock , procedure TWinHTTP.InternalSendRequest if Request is HTTPS, than errors are just ignored. Why?! I just didn't get it!

In my situation I have real errors 12007 or 12002 and they MUST be reported. All others sure must be reported too...

#4 mORMot 1 » SynCrtSock TWinHTTP Problem » 2017-09-21 11:16:51

Avatarx
Replies: 5

I need some Help with TWinHTTP from SynCrtSock.

I have procedure :

procedure TServiceRequest.GetService(const FullURL: string;
  var ResponseCode: Integer; var ResponseHeader, ResponseData: SockString);
var
  aURI: TURI;
  CESHTTPClient: TWinHTTP;
begin
//  Event fired on some Service
  CESHTTPClient := nil;
  try
    try
      aURI.From(FullURL);
      CESHTTPClient := TWinHTTP.Create(aURI.Server, aURI.Port, aURI.Https );
      CESHTTPClient.IgnoreSSLCertificateErrors := true;

      ResponseCode := CESHTTPClient.Request( aURI.Address,'GET', 0, '', '', '', ResponseHeader, ResponseData);
    except
      on E: Exception do
      begin
        Log('Request not successful! Exception: ' + E.Message);
      end;
    end;
  finally
    aURI.Clear;
    if Assigned(CESHTTPClient) then
      CESHTTPClient.Free;
  end;
end;

...and everything works just fine , until I have some error like wrong server name for example.
In that fall I will get error 12019 from winhttp.dll

The same error 12019 I have when ReciveTime is bigger than those defined in Request for example...

Question is, how to become real Error Message (fore example Server doesnot response or something like that)?

#5 Re: Other components » Delphi SynMustache » 2016-03-15 07:41:37

ok! Now it works with stringtoUTF8 and UTF8tostring. Just fine! Thank you!

Why don't you mention it in documentation for SynMustache?  smile

#6 Other components » Delphi SynMustache » 2016-03-14 18:50:10

Avatarx
Replies: 2

I am new to Delphi SynMustache and I want to use it in some very important projects. So I've tryed to play a little bit more with templates and it seems that there is a problem with parsing from templates with non englisch texts. I mean special symbols from german language for example, like "ä", "ß", "ö" ...
To be more specific:

procedure TForm2.RenderTemplate;
var
  mustache: TSynMustache;
  jsonUFT16: string;
  templateUTF16: string;
  jsonUTF8: RawUTF8;
  templateUTF8: RawUTF8;
  jsonRBS: RawByteString;
  templateRBS: RawByteString;
  htmlOutput: string;
begin
  memOutput.Lines.Clear;

  // don't work for us
  memOutput.Lines.Add('Output using RawUTF8');
  templateUTF8 := memTemplate.Text;
  mustache := TSynMustache.Parse(templateUTF8);
  jsonUTF8 := memJSON.Text;
  htmlOutput := mustache.RenderJSON(jsonUTF8);
  memOutput.Lines.Add(htmlOutput);

  memOutput.Lines.Add('');

  // work for us
  memOutput.Lines.Add('Output using RawByteString');
  templateRBS := memTemplate.Text;
  mustache := TSynMustache.Parse(templateRBS);
  jsonRBS := memJSON.Text;
  htmlOutput := mustache.RenderJSON(jsonRBS);
  memOutput.Lines.Add(htmlOutput);
end;

So if I use RawByteString everything seems to be ok, but I'm not sure if that is the right way to go. Property "Template" is ok after parsing, but Tags doesn't recognise code page correctly and at end the result is not as awaited to be.

Is this possible bug or I'm doing something wrong?  sad

Board footer

Powered by FluxBB