简体   繁体   English

解决代理身份验证所需的问题

[英]Resolving a Proxy Authentication Required Issue

I've written a Delphi application which requires communication with a remote web server. 我已经编写了一个Delphi应用程序,该应用程序需要与远程Web服务器进行通信。 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. 我将INTERNET_OPEN_TYPE_PRECONFIG标志传递到InternetOpen函数中以初始化我的应用程序对WinINet函数的使用,并通过这样做使我的应用程序从注册表中检索用户的Internet配置。

  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. 也许由于我的无知,我相信这可以使用用户特定的Internet设置(无论是直接连接还是通过代理)与远程Web服务器进行通信。 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. 他看到的是“需要代理身份验证”(HTTP状态代码407)。

Is this something that my app should be handling (eg provide a form to enter proxy authentication details and pass them with my HTTP requests)? 这是我的应用程序应该处理的事情吗(例如,提供一个表单来输入代理身份验证详细信息,并将其与我的HTTP请求一起传递)? 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? 还是这仅仅是客户IT部门可以轻松解决的配置问题?

Any pointers would be much appreciated. 任何指针将不胜感激。

You may need to handle authentication, depending on what auth methods the proxy supports (it will tell you in the 407 response). 您可能需要处理身份验证,具体取决于代理支持的身份验证方法(它将在407响应中告诉您)。 See http://msdn.microsoft.com/en-us/library/aa384220(VS.85).aspx 参见http://msdn.microsoft.com/zh-cn/library/aa384220(VS.85).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM