Skip to content

ServerVariable - cBaseWebComponent

Allows retrieval of IIS Server Variable values

Type: Function
Return Data Type: String

Parameters

Parameter Type Description
sVariableName String Name of the server variable to retrieve

Syntax

Function ServerVariable String sVariableName Returns String

Call Example

Get ServerVariable sVariableName to StringVariable

Description

Allows retrieval of IIS Server Variable values. See Microsoft's MSDN for documentation of IIS Server Variables.

Sample

This sample shows how to obtain the value of the IIS server variable HTTP_X_FORWARDED_FOR during OnAttachProcess.

Procedure OnAttachProcess
    String sIP

    Get ServerVariable  "HTTP_X_FORWARDED_FOR" to sIP
    If (sIP = "" or Lowercase(sIP) = "unknown") Begin
        Get ServerVariable  "REMOTE_ADDR" to sIP
    End

    Send LogEvent 3000 sIP

    Forward Send OnAttachProcess
End_Procedure

Sample

Client side uses AddHeader to add HTTP header:

Procedure OnPreSendSOAPRequest Handle hoSOAPXml Handle hoHttp String ByRef sHost String ByRef sFilePath
    Get AddHeader of hoHttp 'TestHeader' 'Test' to StrLen
    Forward Send OnPreSendSOAPRequest hoSOAPXml hoHttp sHost sFilePath
End_Procedure

Within cWebService objects you can query HTTP headers via the ServerVariable API. Each incoming header is added as a variable with the HTTP_ prefix. So the following code should do it:

Get ServerVariable "HTTP_TestHeader" to sHeader

For a list of IIS Server Variables, see Microsoft's IIS Server Variables page.