#1 2017-09-21 11:16:51

Avatarx
Member
Registered: 2016-03-14
Posts: 6

SynCrtSock TWinHTTP Problem

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

Offline

#2 2017-09-21 14:27:07

Avatarx
Member
Registered: 2016-03-14
Posts: 6

Re: SynCrtSock TWinHTTP Problem

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

Last edited by Avatarx (2017-09-21 14:31:09)

Offline

#3 2017-09-21 16:56:35

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: SynCrtSock TWinHTTP Problem

I don't understand exactly what you mean, and what you expect.
Sorry.

Online

#4 2017-09-21 18:02:59

Avatarx
Member
Registered: 2016-03-14
Posts: 6

Re: SynCrtSock TWinHTTP Problem

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.

Offline

#5 2017-09-21 18:39:12

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: SynCrtSock TWinHTTP Problem

Errors are not always reported as exception,  but sometimes as status code.
This is as designed.

Online

#6 2017-09-21 18:46:49

Avatarx
Member
Registered: 2016-03-14
Posts: 6

Re: SynCrtSock TWinHTTP Problem

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

Last edited by Avatarx (2017-09-21 18:47:00)

Offline

Board footer

Powered by FluxBB