For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

BaltoStar_12467's avatar
Jul 31, 2014

BIG-IP : helper functions for composing urls with query-params

f5 BIG-IP LTM VE v11.4.0 on ESXi

In my irule, I need to construct a url from multiple segments.

Each segment is run-time loaded from a data-file.

Segment form is only partially known at design-time.

EXAMPLE 1 :

segment1 : "/folder1/folder2/id1"

segment2 : "param1=n1"

EXAMPLE 2 :

segment1 : "/folder1/folder2?param1=n1"

segment2 : "param2=n2"

EXAMPLE 3 :

segment1 : "/folder1/folder2?param1=n1&param2=n2"

segment2 : "param3=n3"

Of course I could write a bit of conditional logic to properly compose the segments.

But I am wondering if perhaps F5 out-of-the-box provides any helper functions ?

For example , a function that would add query-params to the end of a url, and automatically include ? ( if necessary ) or & ( if necessary )

1 Reply

  • hi, Question mark is automatically added when you manipulate HTTP::query

    you can in 11.5 create proc to achieve you results:

    proc add_query { query } {
        if { [HTTP::query] equals "" } {
            return [HTTP::query]$query
        } else {
            return [HTTP::query]&$query
        }
    }
    
    when HTTP_REQUEST {
    log local0. "-----------------------------"
    log local0. "base uri: [HTTP::uri]"
    log local0. "base query: [HTTP::query]"
    HTTP::query [call add_query secondparam=tata]
    log local0. "uri after proc: [HTTP::uri]"
    }