Forum Discussion
stucky101_88485
Nimbostratus
Aug 08, 2012cannot add \r\n to string
iApp gurus
I'm working on customizing the basic http iapp to send a user agent in the http header. It looks like the
f5.app_utils:create_monitor proc doesn't let me pass such an option so I'm t...
Mitra_Kelly_625
Aug 08, 2012Historic F5 Account
On further review, I see that there is definitely a but in the create_monitor procedure. It works for many cases, but not this one. I am including a new version of this proc that you can add to your template and call instead. You won't have to sent the version string to this one for this usage.
proc create_monitor_2 { name_prefix
monitor_type
monitor_interval
monitor_send
monitor_recv
http_version
dns_name
} {
set monitor_name "${name_prefix}_${monitor_type}_monitor"
set http10_header "HTTP/1.0"
set http11_header "HTTP/1.1"
set monitor_ending "\\r\\n"
make sure that the send string is formatted correctly,
even if we have to edit it
convert converted \r and \n back to two char \r\n
set temp_string ""
regsub -all {\r} $monitor_send "\\r" temp_string
set monitor_send $temp_string
regsub -all {\n} $monitor_send "\\n" temp_string
set monitor_send $temp_string
set monitor_timeout [ expr { [ expr {$monitor_interval * 3} ] + 1 } ]
set monitor_ending_length [string length $monitor_ending]
set send_length [string length $monitor_send]
set send_length_minus_end [ expr {$send_length - $monitor_ending_length} ]
clear off real \r\n
while { [string last $monitor_ending $monitor_send] == $send_length_minus_end } {
set send_length_minus_end [expr { $send_length_minus_end - 1 }]
set monitor_send [string range $monitor_send 0 $send_length_minus_end]
set send_length [string length $monitor_send]
set send_length_minus_end [ expr {$send_length - $monitor_ending_length} ]
}
if { [string first $http11_header $monitor_send] == -1 } {
if { $http_version == "Version 1.1" || $http_version == "version_1_1" } {
append monitor_send " HTTP/1.1\\r\\nHost: "
append monitor_send $dns_name
append monitor_send "\\r\\nConnection: Close"
}
}
append monitor_send $monitor_ending
append monitor_send $monitor_ending
do_tmsh_create "/ ltm monitor $monitor_type" "$monitor_name \
defaults-from $monitor_type \
interval $monitor_interval \
timeout $monitor_timeout \
send \"$monitor_send\" \
recv \"$monitor_recv\" \
destination *:*"
return $monitor_name
}
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects