XMLHTTP 和 ServerXMLHTTP的比较区别

 

XMLHTTP

ServerXMLHTTP

1

Works on Windows 98, 95 and ME

Requires at least Windows NT 4 with IE5.01 .

2

 

Does not have a means of waiting for an async call other than using another thread to handle the response via onreadystatechange.

 

Another technique is to loop on the main thread, polling the readystate property.

For example:

 While xmlhttp.readystate <> 4

   ' async request not complete yet; still waiting

 Wend

 

But this is not as efficient as the ServerXMLHTTP's WaitForResponse method

Has a waitForResponse method with a timeout when using async calls.

3

 

Allows configuring timeouts when sending messages.

4

Is designed for single-user, desktop applications, such as running in a browser-based app.

 

XMLHTTP's assumption that it is used only in single-user environments has security implications.

Do not use XMLHTTP in multi-user scenarios such as on IIS/ASP servers.

Also, in various cases, XMLHTTP may display UI dialogs (to collect credentials).

Supports multi-user, server-based applications, such as ASP apps.

5

Because XMLHTTP is designed for single-user client applications and is based on WinInet, it enforces strict limits on the number of simultaneous connections to a given server.

The limit is either 2 or 4 (depending on HTTP version).

The ServerXMLHTTP component does not impose any limits on the number of connections to a server.

6

XMLHTTP integrates with the IE browser's cache, which may cause problems in which "stale" response data is returned.

ServerXMLHTTP does not implement a cache.

7

XMLHTTP is HTTP/1.1 compliant.

XMLHTTP does support HTTP/1.1 chunking.

ServerXMLHTTP reports itself as an HTTP/1.0 client.

The reason is that ServerXMLHTTP does not support the HTTP/1.1 response "chunking" feature, which is required for 1.1 compliance.

8

By using the IE browser's proxy settings, XMLHTTP can take advantage of IE's auto-detection of proxy servers.

If IE is configured to access sites via a proxy server, then all requests made via XMLHTTP will also go through the proxy.

However, IE (and thus XMLHTTP) can be configured to bypass the proxy server for certain sites (assuming that a direct connection to the target server can be made).

This is done in the "Tools/Internet Options/Connections/LAN Settings" dialog in IE.

The "Bypass proxy server for local addresses" option should be checked to have the proxy server bypassed for intranet sites.

ServerXMLHTTP does not support any auto-detection or discovery of proxy servers; you must explicitly specify the name of the proxy server using the proxycfg.exe utility.

Can be configured with WinHTTP proxy config to access other machines directly (no proxy server).

9

The XMLHTTP component in MSXML 3.0 supports automatic gzip decompression;

ServerXMLHTTP does not.

 

 

由此可见在服务器端用ASP来取得互联网上的任意文件使用ServerXMLHTTP或许更加合适.可以设定过期时间可以让ASP程序更具效率和可靠性

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
XMLHttpRequest对象(简称XHR)是用于在客户端和服务器之间发送数据的JavaScript API。setRequestHeader()方法是XHR对象的一个方法,用于设置HTTP请求头。HTTP请求头是指在发送HTTP请求时,包含在请求中的附加信息,包括例如用户代理、cookie、授权信息等等。通过使用setRequestHeader()方法可以设置HTTP请求头的名称和值。 setRequestHeader()方法的参数包含两个: 1. header:要设置的HTTP请求头的名称,例如"Content-Type", "Accept", "Authorization"等等。 2. value:要设置的HTTP请求头的值,例如"text/plain", "application/json", "Bearer 1234567890"等等。 例如,我们可以使用setRequestHeader()方法来设置Content-Type请求头: ``` var xhr = new XMLHttpRequest(); xhr.open('POST', '/submit', true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.send(JSON.stringify({name: 'John', age: 30})); ``` 在上面的例子中,我们使用了POST请求,将一个JSON对象发送到服务器。在发送请求之前,我们使用setRequestHeader()方法设置了Content-Type请求头,告诉服务器我们发送的是JSON数据。 需要注意的是,如果使用setRequestHeader()方法设置的HTTP请求头已经存在,那么它的值会被覆盖。而且,某些HTTP请求头可能需要特定的值,否则服务器可能会返回错误。因此,在设置HTTP请求头时,我们需要仔细查看API文档,确保设置正确的名称和值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值