Contribute Open Script

[BRCD_OS_118] Change URL case

by Yasir_Liaqatullah on ‎01-20-2012 03:19 PM (448 Views)

Area

Content inspection

Traffic

HTTP

Description

            This script analyzes the incoming request and looks for the URL and changes the alphabet in URL into lower case or upper case as defined in the “BEGIN” section of the script. The client request is forwarded to a server based on the hash of the new URL. 

Performance Estimate

           

            Contact us for our detailed reporting

               or

            Report your own performance estimate

Required Backend configuration

            No special configuration is required

Events and API Used

Events

API

HTTP_REQUEST

OS_HTTP_REQUEST::url

OS_SLB:Smiley Tongueersist

Script source code

# Purpose: Convert the URL from lower case to upper case (and vise versa)

use OS_SLB;

use OS_HTTP_REQUEST;

sub BEGIN {

    

       # Change below variable to UPPER or LOWER to convert url to upper or lower case respectively

       $to_which_case = "LOWER";

}

#############################################

#

# HTTP REQUEST EVENTS

#

#############################################

sub HTTP_REQUEST {

    

       # Get the URL from the request

       my $client_url = OS_HTTP_REQUEST::url;

       #print "Client Request has this URL - $client_url\n";

       if ($to_which_case =~ m/^LOWER$/) {

              #print "Converting URL to LOWER case\n";

              $new_url = lc $client_url;

       } elsif ($to_which_case =~ m/^UPPER$/) {

              #print "Converting URL to UPPER case\n";

              $new_url = uc $client_url;

       } else {

              #print "Undefined case so URL is not modified. Use either UPPER or LOWER keywords in the script\n";

              $new_url = $client_url;

       }

       # Insert modified URL

       OS_HTTP_REQUEST::url("$new_url");

    

       # Choose real server based on hash of URL

       OS_SLB:Smiley Tongueersist("hash-to-bucket", "$new_url");

}