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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
WinHTTP提供以下功能: WinHttpAddRequestHeaders 向HTTP请求句柄添加一个或多个HTTP请求标头。 WinHttpCheckPlatform 确定WinHTTP是否支持当前平台。 WinHttpCloseHandle 关闭单个 HINTERNET句柄。 WinHttpConnect 指定HTTP请求的初始目标服务器。 WinHttpCrackUrl 将URL分为其组成部分,例如主机名和路径。 WinHttpCreateProxyResolver 创建WinHttpGetProxyForUrlEx使用的句柄。 WinHttpCreateUrl 从组件部分创建URL,例如主机名和路径。 WinHttpDetectAutoProxyConfigUrl 查找代理自动配置(PAC)文件的URL。此功能报告PAC文件的URL,但不下载该文件。 WinHttpFreeProxyResult 释放从以前的调用WinHttpGetProxyResult检索的数据。 WinHttpGetDefaultProxyConfiguration 从注册表中检索默认的WinHTTP代理配置。 WinHTTPGetIEProxyConfigForCurrentUser 获取当前用户的Internet Explorer(IE)代理配置。 WinHttpGetProxyForUrl 检索指定URL的代理信息。 WinHttpGetProxyForUrlEx 检索指定URL的代理信息。 WinHttpGetProxyResult 检索到调用的结果WinHttpGetProxyForUrlEx。 WinHttpOpen 初始化应用程序对WinHTTP功能的使用。 WinHttpOpenRequest 创建HTTP请求句柄。 WinHttpQueryAuthSchemes 返回服务器支持的授权方案。 WinHttpQueryDataAvailable 返回可立即与读取数据的字节数 WinHttpReadData。 WinHttpQueryHeaders 检索与HTTP请求相关联的头信息。 WinHttpQueryOption 在指定的句柄上查询Internet选项。 WinHttpReadData 从WinHttpOpenRequest函数打开的句柄中读取数据 。 WinHttpReceiveResponse 结束由WinHttpSendRequest启动的HTTP请求 。 WinHttpResetAutoProxy 重置自动代理WinHttpSendRequest 将指定的请求发送到HTTP服务器。 WinHttpSetCredentials 将所需的授权凭证传递给服务器。 WinHttpSetDefaultProxyConfiguration 在注册表中设置默认的WinHTTP代理配置。 WinHttpSetOption 设置Internet选项。 WinHttpSetStatusCallback 设置WinHTTP可以在操作过程中进行调用的回调函数。 WinHttpSetTimeouts 设置涉及HTTP事务的各种超时。 WinHttpTimeFromSystemTime 根据HTTP版本1.0规范格式化日期和时间。 WinHttpTimeToSystemTime 获取HTTP时间/日期字符串并将其转换为 SYSTEMTIME结构。 WinHttpWriteData 将请求数据写入HTTP服务器。 WinHttpWebSocketClose 关闭WebSocket连接。 WinHttpWebSocketCompleteUpgrade 完成由WinHttpSendRequest启动的WebSocket握手。 WinHttpWebSocketQueryCloseStatus 获取服务器发送的关闭状态。 WinHttpWebSocketReceive 从WebSocket连接接收数据。 WinHttpWebSocketSend 通过WebSocket连接发送数据。 WinHttpWebSocketShutdown 向WebSocket连接发送关闭框架
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值