Forum Discussion
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.
when HTTP_REQUEST
{
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>: www.domain.com:443 becomes www.domain.com
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
Anthony
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] } }
KR,
Dario.
- James_ThomsonEmployee
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
KR,
Dario.
- AnthonyNimbostratus
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.
Sure! let us know if it fixes the issue.
KR,
Dario.
- AnthonyNimbostratus
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...
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com