天天看點

WinHTTP 自動代理支援

To ease the configuration of proxy settings, WinHTTP 5.1 implements the Web Proxy Auto-Discovery (WPAD) protocol, also known as autoproxy.

為簡化代理配置,WinHTTP 5.1實作了Web代理自動發現協定(WPAD),也叫autoproxy。

AutoProxy總覽

Applications and components that use WinHTTP to send HTTP requests should ensure that the proxy configuration is set correctly. Unless the client has a direct Internet connection, an HTTP request should normally be sent through a web proxy server that connects the client's local network to the Internet (for example, this is often the case for Web clients on a corporate LAN). For server-based applications, the proxy configuration is normally managed by the server's administrator using the WinHTTP ProxyCfg.exe utility. The server administrator knows the name of the proxy server in advance and uses ProxyCfg.exe to record this setting in the registry where WinHTTP can look it up. However, requiring client desktop end-users to manually configure WinHTTP proxy settings is problematic. The end-user may not know the name of the proxy server; requiring the end-user to run the ProxyCfg.exe utility can be a support burden for an organization. To support a good user experience, a web-enabled client application should determine the proxy configuration without user intervention.

使用WinHTTP的程式群組件發送HTTP請求要保證代理設定正确。除非客戶是直連上網,HTTP請求都會發送給連接配接客戶和Internet的web代理(這在Web使用者和公司内網很常見)。對于基于伺服器的程式來說,代理設定通常由伺服器管理者使用WinHTTP的ProxyCfg.exe管理。管理者知道代理伺服器的名稱,并使用ProxyCfg.exe把這些設定記錄到系統資料庫裡,以便WinHTTP找到它。然而要求用戶端的桌面終端使用者手動配置WinHTTP代理設定會産生很多問題。終端使用者有可能不知道代理伺服器名稱,讓使用者運作ProxyCfg.exe工具也是一個負擔很重的工作。要有好的使用者體驗,基于web的應用程式應該可以自動探測代理配置而不需要使用者幹預。

To make configuring the proxy settings for WinHTTP-based applications easier, WinHTTP now implements theWeb Proxy Auto-Discovery (WPAD) protocol, often referred to asautoproxy. This is the same protocol that web browsers implement to automatically discover the proxy configuration without requiring an end-user to specify a proxy server manually. This feature is available starting with WinHTTP version 5.1 in Windows 2000 Service Pack 3, Windows XP Service Pack 1 and Windows Server 2003. Note that although both Microsoft Internet Explorer and Microsoft WinHTTP support WPAD, the specification never progressed beyond the "Internet-Draft" stage, and expired in May 2001.

為了使基于WinHTTP的程式使用代理更簡單,WinHTTP實作了Web Proxy Auto-Discovery (WPAD) 協定,也常被稱為autoproxy。浏覽器也實作了同樣的無需使用者幹預的代理發現功能。這個功能從WinHTTP5.1開始實作,預設的在2000 SP3 、XP SP1以及Server 2003及以後作業系統都實作了上述功能。

The WPAD protocol works as follows:

WPAD協定按以下方式工作:

  1. Using the DHCP and/or DNS network protocols, the URL of a Proxy Auto-Configuration (PAC) file is discovered. The URL identifies a PAC file on the client's local network. WinHTTP supports only "http:" and "https:" PAC URLs; it does not, for example, support "file:" URLS.
  2. 使用DHCP和/或DNS網絡協定,發現一個辨別代理自動配置檔案的URL.這個URL在使用者本地網絡發現一個PAC檔案,WinHTTP隻支援形如"http:" 和"https:"的 PAC URLs。
  3. The PAC file is downloaded and optionally cached on the client's computer. The PAC file is an executable script that generates a list of one or more proxy servers given a target host name and URL. WinHTTP supports only ECMAScript-based PAC files.
  4. PAC檔案下載下傳并根據選項是否存儲在使用者計算機本地。這個PAC檔案是一個可執行的腳本,這個腳本産生一個清單,這個清單中有一個或多個以URL或主機名出現的代理伺服器。WinHTTP隻支援ECMA腳本PAC檔案。                                                                                     
  5. On each HTTP request, the PAC script code is executed, with the host name and URL of the HTTP request passed in as parameters. WinHTTP expects the PAC script code to contain a function calledFindProxyForURL, in the form:
  6. 對每個HTTP請求,PAC腳本代碼都執行,使用HTTP請求URL或主機名作為參數。WinHTTP要求PAC腳本包含一個叫FindProxyForURL函數,
  7. FindProxyForURL( url, host ); 
          
  8. This function computes a list of one or more proxy servers that can be used by the HTTP client in order to transmit the request. If the PAC script determines that the HTTP client can reach the target server directly without going through a proxy server at all, it indicates this using a special return value.
  9. 這個函數計算一個清單,這個清單中包含一個或多個代理伺服器,HTTP用戶端使用這些伺服器轉發請求。如果PAC腳本探測到HTTP用戶端可以不使用代理直接通路網絡,就會傳回一個特定的值。

AutoProxy Topics

  • WinHTTP AutoProxy Functions
  • Discovery Without an Auto-Config File
  • AutoProxy Issues in WinHTTP
  • Setting WinInet Proxy Configurations in WinHTTP
  • AutoProxy Cache
  • IPv6 Extensions to Navigator Auto-Config File Format