# Irule help

**URL:** <https://community.f5.com/t/irule-help/59950>\
**Category:** Technical Forums\
**Tags:** asm-advanced-waf, irules, application-delivery\
**Created:** [October 18, 2018, 8:18am UTC](https://community.f5.com/t/irule-help/59950 "2018-10-18T08:18:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Snl](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Snl](https://community.f5.com/u/Snl)\
**Post date:** [October 18, 2018, 8:18am UTC](https://community.f5.com/t/irule-help/59950/1 "2018-10-18T08:18:23Z")

</div>

Folks

I have requirement to the request start with /abc/ directory and contains the parameter si or di the value of this parameter should not exceed more than 50 characters , if exceed should drop if less should allow. cheers snl

---

<div class="post-metadata">

**Author:** ![Snl](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Snl](https://community.f5.com/u/Snl)\
**Post date:** [October 18, 2018, 8:34am UTC](https://community.f5.com/t/irule-help/59950/2 "2018-10-18T08:34:48Z")

</div>

done some research found below , how i can call the parameters in this particular those 2 value

```tcl
when RULE_INIT {
  set DEBUG 1
  set sec_http_max_post_data_length 50
}

when HTTP_REQUEST {
  if { [string tolower [HTTP::uri]] equals "/abc/" and [HTTP::method] equals "POST" } {
    set len [HTTP::header "Content-Length"]
      if { [expr $len > $::sec_http_max_post_data_length] } {
        log local0. " SEC-ALERT: POST Length: uri=[HTTP::uri]; len=$len; max_len=$::sec_http_max_post_data_length"
        reject
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [October 18, 2018, 1:54pm UTC](https://community.f5.com/t/irule-help/59950/3 "2018-10-18T13:54:34Z")

</div>

You’ll want to create static variables in RULE\_INIT to maintain CMP.

```tcl
when RULE_INIT {
    set static::DEBUG 1
    set static::sec_http_max_post_data_length 50
}
when HTTP_REQUEST {
    if { ( [string tolower [HTTP::uri]] equals "/abc/" ) and ( [HTTP::method] equals "POST" ) } {
        set len [HTTP::header "Content-Length"]
        if { [expr {$len > $static::sec_http_max_post_data_length}] } {
            log local0. " SEC-ALERT: POST Length: uri=[HTTP::uri]; len=$len; max_len=$static::sec_http_max_post_data_length"
            reject
        }
    }
}

```
