HttpClient and proxy PAC Files

Hi,

I having problems to connect a Win7 machine with a PAC file proxy configuration. Because on Win7 does not use auto setting for proxy httpclient i have the following code:

function TdmGlobales.GetXDataClient: TXDataClient;
var
  HttpReq : THttpRequest;
  Engine: TWinHttpEngine;
begin
  Result := TXDataClient.Create;
  //FProxyName contains url of pac file.
  if FProxyName <> '' then
    begin
      Engine := TWinHttpEngine(Result.HttpClient.Engine);
      Engine.ProxyMode := THttpProxyMode.Custom;
      Engine.ProxyName := FProxyName;
      Engine.ResetSession;
    end;
  Result.HttpClient.OnSendingRequest := procedure(Req: THttpRequest)
    begin
      Req.Timeout := (1000) * 300000;
      Req.Headers.SetValue('Authorization','Bearer ' + FvToken);
    end;
    Result.Uri := csServer;
end;
/// Client is not able to connect.


Any hints,

Thanks in advance,

Omar Zelaya
Hi,

Done it using WinHttpGetProxyForUr to get Proxy server.

There is a bug in Sparkle.WinHttp.Api I had to change thefollowing to make it work.
///added
PWINHTTP_AUTOPROXY_OPTIONS = ^WINHTTP_AUTOPROXY_OPTIONS;
//changed
  WinHttpGetProxyForUrl: function(hSession: HINTERNET; lpcwszUrl: PWideChar;
    pAutoProxyOptions: PWINHTTP_AUTOPROXY_OPTIONS; var pProxyInfo: WINHTTP_PROXY_INFO): BOOL; stdcall;

Thanks in adavnce,

Omar Zelaya

Thanks, we will add the modification to official version.