Pregunta

I've written a Delphi application which requires communication with a remote web server. I pass INTERNET_OPEN_TYPE_PRECONFIG flag into the InternetOpen function to initialise my app's use of the WinINet functions and by doing so my app to retrieve the user's Internet configuration from the registry.

  NetHandle := InternetOpen('WebTool', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
  if Assigned(NetHandle) then
  begin
    try
      hConnect := InternetConnect(NetHandle, PChar(ServerName), ServerPort,
                      nil, nil, INTERNET_SERVICE_HTTP, 0, 1);
      if Assigned(hConnect) then
      begin
        try
          // Open the request
          hRequest := HttpOpenRequest(hConnect, PChar('POST'),
                          PChar(ServerScript), nil, nil, nil,
                          HTTPOpenRequestFlags, 0);
          if Assigned(hRequest) then
          begin

Perhaps due to my ignorance, I believed this enabled communication with the remote web server using the user's particular Internet settings whether direct connection or via a proxy. It certainly works via my company's proxy server.

However, I've now encountered one customer for whom the above does not allow him access. He sees a "Proxy Authentication Required" (HTTP status code 407) instead.

Is this something that my app should be handling (e.g. provide a form to enter proxy authentication details and pass them with my HTTP requests)? Is there a way of picking up this information automatically?

Or is this simply down to a configuration issue that the customer's IT department can easily resolve?

Any pointers would be much appreciated.

¿Fue útil?

Solución

You may need to handle authentication, depending on what auth methods the proxy supports (it will tell you in the 407 response). See http://msdn.microsoft.com/en-us/library/aa384220(VS.85).aspx

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top