XMLHTTP is a set of API's that allows us to send and retrieve data to and from a remote web server using its underlying HTTP protocols and methods. In this article, Mitchell provides us with a basic introduction to the XMLHTTP library, with some examples to get you started.
The Power of the XMLHTTP Library - The XMLHTTP document headers (Page 4 of 5 )
Along with your response from the remote server, the XMLHTTP library also returns a number of HTTP headers. These headers can be accessed using the GetAllResponseHeaders method of the XMLHTTP library, as shown below:
This would cause our XMLHTTP object to send all of its headers directly to the browser. On my Windows 2000 server, the headers looked like this:
Date: Tue, 18 Dec 2001 00:06:04 GMT
These headers can come in handy if you’re trying to debug a problem with the remote servers response to your XMLHTTP request. The Content-Length variable contains the number of characters returned from the request. Keep in mind though, that even if you request a non-existent document, the Content-Length variable will still contain the length of the error message generated by the remote web server.
If we want to get the details of each individual header variable, we can use the GetResponseHeader method. To retrieve the Content-Length, we would use it like this:
Remember that you can also use the Response.AddHeader method to add your own headers to the servers’ response. These could come in handy if you’re trying to debug database connections on the remote server, for example.