How to Create an Expression Using AppExpert to Compare HTTP Request Header on NetScaler

How to Create an Expression Using AppExpert to Compare HTTP Request Header on NetScaler

book

Article ID: CTX131724

calendar_today

Updated On:

Description

This article describes how to create an expression to retrieve information from one HTTP header and compare it with the value of another HTTP request header. The procedure describes comparing the URL in the Referrer header to the value of the User-Agent header. It uses the Advanced Expression Evaluator feature on AppExpert.

Requirement

Administrative access to a NetScaler GUI.

Background

Consider that you want to compare the URL in the Referrer and the User-Agent for mobile versions of a website before responding to the client request. The User-Agent in the "User-Agent" header of the request must match the URL from the Referrer. For example, a sample website www.example.com.


Instructions

To create an expression to retrieve information from one HTTP header and compare it with the value of another HTTP request header, complete the following procedure:

  1. Navigate to the AppExpert node.

  2. Select Advanced Expression Evaluator from the Tools section.

  3. Specify the following expression in the Advanced Expression Evaluator dialog box:
    HTTP.REQ.HEADER("User-Agent")==http.REQ.HEADER("Referrer").VALUE(0).REGEX_SELECT(re~(?<=http://www.example.com/).*~)

    This expression detects whether the request for the new website (http://www.example.net) has come from http://www.example.com/url and if the URL = User-Agent.

    In the Advanced Expression Evaluator dialog box, you can notice that the NetScaler returns "true" or "false" depending on the success of the match.

    If the URL matches the User-Agent value, the NetScaler returns "true" as shown in the following screen shot:

    User-added image

    If the URL does not match the User-Agent value, the NetScaler returns "false", as shown in the following screen shot:

    User-added image

Issue/Introduction

This article describes how to create an expression to retrieve information from one HTTP header and compare it with the value of another HTTP request header.