Tutorials » The Power of the XMLHTTP Library

The XMLHTTP document headers

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:

Response.Write ObjXMLHTTP.GetAllResponseHeaders

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:

Server: Microsoft-IIS/5.0
Date: Tue, 18 Dec 2001 00:06:04 GMT
Connection: keep-alive
Content-Length: 8
Content-Type: text/html
Cache-control: private

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:

Response.Write objXMLHTTP.GetResponseHeader("Content-Length")

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.


Previous Start Next
  1 2 3 4 5