<%
class xmlhttp_class

dim Proxy_,xmlurl_,referer_,Languages_,Content_Type_,cookies_,Accept_Language_,User_Agent_,Accept_,Connection_,Cache_Control_,Pragma_,Accept_Encoding_,Range_

Public Property Let Proxy(Value)	'设置代理
	Proxy_=LCase(Value)
End Property
Public Property Get Proxy		'读取代理
	Proxy=Proxy_
End Property

Public Property Let xmlurl(Value)	'设置要获取数据地址
	xmlurl_=Value
End Property
Public Property Get xmlurl		'读取要获取数据地址
	xmlurl=xmlurl_
End Property

public property Let referer(value)	'设置referer
	referer_=value
end property
public property get referer		'读取referer
	referer=referer_
end property

public property Let Languages(value)	'设置语言
	Languages_=value
end property
public property get Languages		'读取语言
	Languages=Languages_
end property

public property Let Content_Type(value)	'设置内容类型
	Content_Type_=value
end property
public property get Content_Type		'读取内容类型
	Content_Type=Content_Type_
end property

public property Let cookies(value)	'设置COOKIES
	cookies_=value
end property
public property get cookies		'读取COOKIES
	cookies=cookies_
end property

public property Let Accept_Language(value)	'设置服务器接受语言
	Accept_Language_=value
end property
public property get Accept_Language		'读取服务器接受语言
	Accept_Language=Accept_Language_
end property

public property Let User_Agent(value)	'设置发送浏览器
	User_Agent_=value
end property
public property get User_Agent		'读取发送浏览器
	User_Agent=User_Agent_
end property

public property Let Accept(value)	'设置返回文本类型
	Accept_=value
end property
public property get Accept		'读取返回文本类型
	Accept=Accept_
end property

public property Let Connection(value)	'设置连接
	Connection_=value
end property
public property get Connection		'读取连接
	Connection=Connection_
end property

public property Let Cache_Control(value)	'设置缓存
	Cache_Control_=value
end property
public property get Cache_Control	'读取缓存
	Cache_Control=Cache_Control_
end property

public property Let Pragma(value)	'设置缓存
	Pragma_=value
end property
public property get Pragma	'读取缓存
	Pragma=Pragma_
end property

public property Let Accept_Encoding(value)	'设置压缩
	Accept_Encoding_=value
end property
public property get Accept_Encoding		'读取压缩
	Accept_Encoding=Accept_Encoding_
end property

public property Let Range(value)	'设置返回字节
	Range_=value
end property
public property get Range		'读取返回字节
	Range=Range_
end property

	dim SenFe_Code
	'初始化类
	Private Sub Class_Initialize
	Proxy=""
	xmlurl=""
	referer=""
	Content_Type=""
	cookies=""
	Accept_Language=""
	User_Agent=""
	Accept=""
	Connection=""
	Cache_Control=""
	Pragma=""
	Accept_Encoding=""
	Range=""
	SenFe_Code=""
	sInfo=""
	Languages=""
	End Sub
	'释放类
	private sub class_terminate()
	on error Resume Next
			https.close
			set https=nothing
			stream.close
			set stream=nothing
	end sub

		'//　Rem 检查组件是否支持　是返回　True 否返回 False
		Public Function IsObjInstalled(strClassString)
		On Error Resume Next
		'//设置初始化值
		IsObjInstalled = False
		Err = 0
		'//测试代码
		Dim xTestObj
		Set xTestObj = Server.createObject(strClassString)
		If 0 = Err Then IsObjInstalled = True
		'//清除所申请的对象
		Set xTestObj = Nothing
		Err = 0
		End Function

	Public Sub http()
		Dim ArrProgId,arrayprogs,Prog,XmlHttpCom
		ArrProgId="MSXML2.ServerXMLHTTP.5.0|MSXML2.ServerXMLHTTP.6.0|MSXML2.ServerXMLHTTP.4.0|MSXML2.ServerXMLHTTP.3.0|MSXML2.ServerXMLHTTP|MSXML2.XMLHTTP.6.0|MSXML2.XMLHTTP.5.0|MSXML2.XMLHTTP.4.0|MSXML2.XMLHTTP.3.0|MSXML2.XMLHTTP|Microsoft.XMLHTTP"
		arrayprogs=split(ArrProgId,"|")
		For  Prog=0 to ubound(arrayprogs)-1
		If IsObjInstalled(arrayprogs(Prog)) Then
		XmlHttpCom = cstr(arrayprogs(Prog))
		Exit For
		End If
		Next
		dim https
		Set Https = Server.CreateObject(XmlHttpCom)
		With Https
		.open "GET",xmlurl,false
		.SetTimeOuts 10000,10000,10000,30000 'setTimeouts(解析响应时间,连接响应时间,发送请求数据响应时间,接受数据响应时间) 单位毫秒
		if Proxy<>"" then .SetProxy 2,Proxy '代理ip:代理端口
			.setRequestHeader "Referer",referer '验证
			.SetRequestHeader "Content-Length",Len(xmlurl) '要提交的数据长度
			.setRequestHeader "Host",mid(referer,8,instr(8,referer,"/")-8)
			if Content_Type<>"" then .SetRequestHeader "Content-Type",Content_Type 'audio/x-ms-wma;application/x-www-form-urlencoded
	        if cookies<>"" then .SetRequestHeader "Cookie",cookies 'cookie
	        if Accept_Language<>"" then .SetRequestHeader "Accept-Language",Accept_Language '语言
	        if User_Agent<>"" then .SetRequestHeader "User-Agent",User_Agent '浏览器代理
	        if Accept<>"" then .SetRequestHeader "Accept",Accept '文档类型
	        if Connection<>"" then .SetRequestHeader "Connection",Connection '连接
	        if Cache_Control<>"" then .SetRequestHeader "Cache-Control",Cache_Control '是否缓存
	        if Pragma<>"" then .SetRequestHeader "Pragma",Pragma '是否缓存
	        if Accept_Encoding<>"" then .SetRequestHeader "Accept-Encoding",Accept_Encoding 'gzip压缩(gzip, deflate)
	        if Range<>"" then .setRequestHeader "Range",Range '设置返回多少数据 //表示头500个字节：bytes=0-499 //表示第二个500字节：bytes=500-999 //表示最后500个字节：bytes=-500 //表示500字节以后的范围：bytes=500- //第一个和最后一个字节：bytes=0-0,-1 //同时指定几个范围：bytes=500-600,601-999
		.send()
		if err.number<>0 then err.Clear
		        If .ReadyState = 4 and .Status = 200 Then
		                '返回的内容
		                SenFe_Code = .ResponseBody
		                'SenFe_Code = .ResponseText
		                'SenFe_Code = .getResponseHeader("Set-Cookie")
		                'SenFe_Code = .getResponseHeader("Content-Length")
		                'SenFe_Code = .getAllResponseHeaders()

				dim objstream
				set objstream = Server.CreateObject("adodb.stream")
				objstream.Type = 1
				objstream.Mode =3
				objstream.Open
				objstream.Write SenFe_Code
				objstream.Position = 0
				objstream.Type = 2
				objstream.Charset = Languages
				sInfo = objstream.ReadText
				objstream.Close
				set objstream = nothing

		        Else
		        sInfo= "没有数据返回"
		        End If

		end With

	end Sub


end class
%>
