#1 2017-08-16 03:34:46

cybexr
Member
Registered: 2016-09-14
Posts: 78

Default Winhttp proxy modification request

Fiddler is a wonderful debug tools which could catch every winhttp/winitnet call , and when it startsup , it could set winhttp proxy automatically.  so it is very convenient on momort c/s communication debugging.

but now in the SynCrtSock.pas , it will bypass the system proxy

procedure TWinHTTP.InternalConnect(ConnectionTimeOut,SendTimeout,ReceiveTimeout: DWORD);
begin
  if fProxyName='' then
    // add https://msdn.microsoft.com/en-us/library/windows/desktop/aa384122 ?
    OpenType := WINHTTP_ACCESS_TYPE_NO_PROXY else
    OpenType := WINHTTP_ACCESS_TYPE_NAMED_PROXY;
  fSession := WinHttpOpen(pointer(Ansi7ToUnicode(fUserAgent)), OpenType,
    pointer(Ansi7ToUnicode(fProxyName)), pointer(Ansi7ToUnicode(fProxyByPass)), 0);

and MSDN ( https://msdn.microsoft.com/en-us/librar … s.85).aspx ) told us :  WINHTTP_ACCESS_TYPE_DEFAULT_PROXY -- this option is deprecated on Windows 8.1 and newer. Use WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY instead.

so I wonder if it is possible to change the implemention here to : if client >8.1 then use WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY .  it could help coding&debuging a lot.

Online

#2 2017-08-16 06:53:33

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

Re: Default Winhttp proxy modification request

Which code patch do you propose?

Offline

#3 2017-08-16 08:43:15

cybexr
Member
Registered: 2016-09-14
Posts: 78

Re: Default Winhttp proxy modification request

just submit a pullrequest on github

Online

#4 2017-08-16 11:39:45

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

Re: Default Winhttp proxy modification request

I've modified it a little (to remove SynCommons dependency), and included it.
See https://github.com/synopse/mORMot/commi … b294bf8a0e

Thanks for sharing!

Offline

#5 2017-08-16 16:46:42

zed
Member
From: Belarus
Registered: 2015-02-26
Posts: 105

Re: Default Winhttp proxy modification request

Option WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY replases WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, but not WINHTTP_ACCESS_TYPE_NO_PROXY!

So, if you want to change behavor when fProxyName is empty, you should use WINHTTP_ACCESS_TYPE_DEFAULT_PROXY for windows version < 8.1:

if (OSVersionInfo.dwMajorVersion>=6) and (OSVersionInfo.dwMinorVersion>=3) then
  OpenType := WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY else // Windows 8.1 and newer
    OpenType := WINHTTP_ACCESS_TYPE_DEFAULT_PROXY else // Windows 8 and older
OpenType := WINHTTP_ACCESS_TYPE_NAMED_PROXY;

Offline

#6 2017-08-16 18:35:02

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

Re: Default Winhttp proxy modification request

@zed
IIRC it is not the same.
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY does not inherit browser proxy settings.

We kept the previous behavior, i.e. WINHTTP_ACCESS_TYPE_NO_PROXY and an explicit proxy credential, for Windows 8 or older.

Offline

#7 2017-08-17 00:43:15

cybexr
Member
Registered: 2016-09-14
Posts: 78

Re: Default Winhttp proxy modification request

thank you ab, for so quick response and continuous passion on mormot !

Online

Board footer

Powered by FluxBB