Get Headers Function

GetHeaders returns all headers sent to the current web page by a given user's browser.

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.

Syntax: Set object = GetHeaders()

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:

ACCEPT
*/*

HOST
psacake.com

USER-AGENT
claudebot

X-REWRITE-URL
/web/ic.asp



asp function headers


Back To Top
© 1998 - 2024 psacake.com
Version 7.21 | Advertise on this site