Forum Discussion

Anthony's avatar
Icon for Nimbostratus rankNimbostratus
Sep 27, 2019

TCL error on simple replace header iRule

I'm getting a TCL error from a very simple iRule and cannot understand what scenario would cause it to fail.

The iRule does a simple port removal from the host header.

   if { [HTTP::host] contains ":" }
      log local0. "[HTTP::host] becomes [substr [HTTP::host] 0 ":"]"
      HTTP::header replace Host "[substr [HTTP::host] 0 ":"]"

Sep 27 12:20:19 LTM1 info tmm3[22524]: Rule /Common/remove_port <HTTP_REQUEST>: becomes
Sep 27 12:20:19 LTM1 err tmm3[22524]: 01220001:3: TCL error: /Common/remove_port <HTTP_REQUEST> - Operation not supported (line 4)     invoked fro
m within "HTTP::header replace Host "[substr [HTTP::host] 0 ":"]""

Any ideas on what scenario would cause this to happen? It works on most, just seems there is something particular that causes the error to be thrown.

Many thanks


  • Dario_Garrido's avatar
    Oct 04, 2019

    Try this.

    when HTTP_REQUEST {
       if { [HTTP::host] contains ":" } {
          log local0. "[HTTP::host] becomes [getfield [HTTP::host] {:} 1]"
          HTTP::header replace Host [getfield [HTTP::host] {:} 1]



8 Replies

  • What version are you running? Also, how were you testing? I just loaded that irule on a 14.1 box and I sent traffic through without a problem.

    However, I couldn't get it to log an HTTP::host with the colon in it. I created a line to only log HTTP::host and it only puts the domain name, not the colon.

    So, just curious which client you're using to test.

  • Hello Anthony.

    That's a common issue with HTTP::header command when you use it with quotes. Just do this to avoid the error

    set new_header "[substr [HTTP::host] 0 ":"]"
    HTTP::header replace Host $new_header



  • We're running v12.1.4. It only happens every so often so I don't actually know what is causing it. I did wonder if it was something to do with the string replacement. I prefersetting a varaible before the replacement so I'll do that and see if it stops it.


    Thanks for your answers.

      • Anthony's avatar
        Icon for Nimbostratus rankNimbostratus

        Quick answer is that its generated the same error.

        TCL error: /Common/remove_port <HTTP_REQUEST> - Operation not supported (line 4)     invoked from within "HTTP::header replace Host $new_host"

        Back to the drawing board...