Forum Discussion
TCL error <http_request> - Operation not supported (line 1) invoked from within "HTTP::header remove Cache-Control"</http_request>
Hi Lior,
the error you see is most likely caused because a previous iRule/LTM Policy has already responded the ongoing HTTP request. After the HTTP request is responded an attempt to modify the HTTP headers will create that kind of TCL exemption.
You can workaround be either:
1.) Change the order of the iRule so that the manipulation takes place before the redirection
rules {
Set_Response_Private
Request_gzip
Rem_DeviceID_From_Articles
Igonre_CTRLF5
Mobile_Redirect
}
2.) Combine the individual iRules into a single one and use the
return
command after each HTTP::respond
HTTP::redirect
command, to abort further iRule processing
when HTTP_REQUEST {
if { $something eq true } then {
HTTP::redirect "http://somewhere/somefile.txt"
Stop the execution of the current iRule...
return
}
if { [HTTP::header exists "Cache-Control"] } {
HTTP::header remove Cache-Control
}
if { [HTTP::header exists "Pragma"] } {
HTTP::header remove Pragma
}
}
3.) Use the
[catch]
command to explicitly check if the HTTP request was already responded.
when HTTP_REQUEST {
if { [catch {HTTP::payload replace 0 0 {}}] } then {
The request was already responded...
return
}
if { [HTTP::header exists "Cache-Control"] } {
HTTP::header remove Cache-Control
}
if { [HTTP::header exists "Pragma"] } {
HTTP::header remove Pragma
}
}
4.) Use the
[catch]
command to overwrite the exemptions of the commands which may fail under certain conditions.
Example 1:
when HTTP_REQUEST {
if { [HTTP::header exists "Cache-Control"] } {
catch { HTTP::header remove Cache-Control }
}
if { [HTTP::header exists "Pragma"] } {
catch { HTTP::header remove Pragma }
}
}
Example 2:
when HTTP_REQUEST {
catch {
if { [HTTP::header exists "Cache-Control"] } {
HTTP::header remove Cache-Control
}
if { [HTTP::header exists "Pragma"] } {
HTTP::header remove Pragma
}
}
}
5.) Implement some signaling between your iRule to inform subsequent iRules that a HTTP request has been already responded.
iRule 1:
when HTTP_REQUEST {
if { $something eq true } then {
HTTP::redirect "http://somewhere/somefile.txt"
Imform subsequent iRule that the request has been responded.
set is_already_responded true
}
}
iRule 2:
when HTTP_REQUEST {
if { not $is_already_responded } then {
if { [HTTP::header exists "Cache-Control"] } {
HTTP::header remove Cache-Control
}
if { [HTTP::header exists "Pragma"] } {
HTTP::header remove Pragma
}
}
}
Cheers, Kai
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