Tag: asp

Handling server responses with WinHttpRequest object

Posted by – August 14, 2009

Yesterday I spent few hours trying to understand why my application was crashing after receive a big responses from server, in the end it was a question of how to use WinHttpRequest object.

WinHttpRequest is a COM object that can be used to send and receive data from server via HTTP protocol, I use it a lot in my search application because I need send user queries to search server and then process the responses in xml format.

Look this piece of code that I used to send HTTP requests to my search server:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Dim objXMLHTTP
Set objXMLHTTP = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
objXMLHTTP.Open "GET" , "/bigfile.xml" , false
objXMLHTTP.setRequestHeader "Content-Type", "text/html; charset=utf-8"
objXMLHTTP.Send
       
Dim objXML
Set objXML = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
objXML.validateOnParse = false
objXML.resolveExternals = false
objXML.preserveWhiteSpace = false
objXML.async = false
       
objXML.LoadXML( objXMLHTTP.ResponseText  )

More

Share