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

猜你喜欢

转载自blog.csdn.net/edger2heaven/article/details/45715805