GetHeaders returns a reference to a Scripting.Dictionary object.
The Keys and Items collections will be filled with all header name, value combinations sent by the browser.
Example Usage:
<% '-------------------------------------------------------------- 'get all headers '-------------------------------------------------------------- Dim oHeaders, key Set oHeaders = GetHeaders For Each key in oHeaders.Keys Response.write key & "<BR>" Response.Write oHeaders.Item(key) & "<BR><BR>" Next Set oHeaders = Nothing '-------------------------------------------------------------- 'get the user agent of the browser. '-------------------------------------------------------------- Set oHeaders = GetHeaders key = oHeaders.Item("user-agent") Set oHeaders = Nothing %>Source Code:
<% Private Function GetHeaders() dim item, d, sKey, sItem set d = createobject("Scripting.Dictionary") d.RemoveAll for each item in request.servervariables if left(ucase(item), 5) = "HTTP_" then sKey = replace(right(UCASE(item), len(item) - 5), "_", "-") sItem = request.servervariables(item) if not d.Exists(sKey) then d.Add sKey, sItem end if next Set GetHeaders = d End Function %>The Result: