Home|Sitemap|Contact

How can you get the response headers from a web server in your page?

You can get the response headers from any public web server using the XMLHTTP object. This example is limited to this website, but you can run this to determine what server another website is running and to inspect the response headers sent to you from that server.

Connection: close Date: Fri, 03 Jul 2009 01:33:38 GMT Server: Microsoft-IIS/6.0 MicrosoftOfficeWebServer: 5.0_Pub X-Powered-By: ASP.NET Content-Length: 7701 Content-Type: text/html Expires: Thu, 02 Jul 2009 01:33:38 GMT Set-Cookie: ASPSESSIONIDSSDQSDSS=KAPBOOJCDGPNIAOPCHOIICII; path=/ Cache-control: no-store



<%
Session.CodePage=65001
Response.Charset="UTF-8"
Response.Buffer = True
Dim objH, respHeaders

' Create an xmlhttp object:
Set objH = Server.CreateObject("Microsoft.XMLHTTP")

' Opens the connection to the remote server.
objH.Open "GET", "http://www.rodsdot.com/", False
objH.Send

respHeaders = objH.getAllResponseHeaders()
Set objH = nothing
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

<head>
<title>Response Headers</title>
</head>

<body>
<p><%=respHeaders%>
</body>

</html>