Forum Discussion
stucky101_88485
Aug 08, 2012Nimbostratus
cannot 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 trying to pass the entire thing inside $monitor_send and set $monitor_dns_name and $http_version to an empty string. I'm running into 2 issues with that.
1. I removed the http_version and dns_name section and set them to empty. When I paste the following http header
GET / HTTP/1.1\r\nHost: localhost\r\nUser-Agent: F5LTM/11\r\nConnection: Close\r\n\r\n
it creates the app just fine. However the resulting http monitor is actually truncated like this :GET / HTTP/1.1\r\nHost: localhost\r\nUser-Agent: F5LTM/11\r\nConnection: Close\r\n
in other words it appears to chomp the last 2 \r\n so the pool is marked down.
2. I'd like to have this string as a default rather than GET / but it appears the string element does not accept the \r\n.
string monitor_send default "GET / HTTP/1.1\r\nHost: localhost\r\nUser-Agent: F5LTM/11\r\nConnection: Close\r\n\r\n" required display "xlarge"
causes
01070734:3: Configuration error:
/Common/f5.http_clientssl: line 117,61: error 4: Unexpected character at 'r'
/Common/f5.http_clientssl: line 117,68: Invalid character (:)
/Common/f5.http_clientssl: line 117,79: Invalid character (\)
/Common/f5.http_clientssl: line 117,81: Invalid character (\)
/Common/f5.http_clientssl: line 117,87: Invalid character (-)
/Common/f5.http_clientssl: line 117,93: Invalid character (:)
/Common/f5.http_clientssl: line 117,100: Invalid character (/)
/Common/f5.http_clientssl: line 117,101: Invalid character (1)
/Common/f5.http_clientssl: line 117,102: Invalid character (1)
/Common/f5.http_clientssl: line 117,103: Invalid character (\)
/Common/f5.http_clientssl: line 117,105: Invalid character (\)
/Common/f5.http_clientssl: line 117,117: Invalid character (:)
/Common/f5.http_clientssl: line 117,124: Invalid character (\)
/Common/f5.http_clientssl: line 117,126: Invalid character (\)
/Common/f5.http_clientssl: line 117,128: Invalid character (\)
I tried single quoting but it causes an error :
string monitor_send default 'GET / HTTP/1.1\r\nHost: localhost\r\nUser-Agent: F5LTM/11\r\nConnection: Close\r\n\r\n' required display "xlarge"
01070734:3: Configuration error:
/Common/f5.http_clientssl: line 117,45: Invalid character (')
/Common/f5.http_clientssl: line 117,50: Invalid character (/)
/Common/f5.http_clientssl: line 117,56: Invalid character (/)
/Common/f5.http_clientssl: line 117,57: Invalid character (1)
/Common/f5.http_clientssl: line 117,59: Invalid character (1)
/Common/f5.http_clientssl: line 117,60: Invalid character (\)
/Common/f5.http_clientssl: line 117,62: Invalid character (\)
/Common/f5.http_clientssl: line 117,68: Invalid character (:)
/Common/f5.http_clientssl: line 117,79: Invalid character (\)
/Common/f5.http_clientssl: line 117,81: Invalid character (\)
/Common/f5.http_clientssl: line 117,87: Invalid character (-)
/Common/f5.http_clientssl: line 117,93: Invalid character (:)
/Common/f5.http_clientssl: line 117,100: Invalid character (/)
/Common/f5.http_clientssl: line 117,101: Invalid character (1)
/Common/f5.http_clientssl: line 117,102: Invalid character (1)
I CAN quote the \ and it does let me save it this way :
string monitor_send default "GET / HTTP/1.1\\r\\nHost: localhost\\r\\nUser-Agent: F5LTM/11\\r\\nConnection: Close\\r\\n\\r\\n" required display "xlarge"
However, now the presentation layer shows this string with \\ included although it does remove them when it actually creates the monitor but it truncates the last 2 chars again.
I suppose I'm hitting a string lenght limitation ? Then again I can manually create this http header in the gui just fine.
Any insight would be appreciated.
btw if anyone cares how I'm doing this I just removed the dns_name and http_version sections from the presentation and changed the implementation a bit since I seem to be forced to pass these 2 options empty or not.
set monitor_recv \"$::server_pools__monitor_recv\"
set monitor_send \"$::server_pools__monitor_send\"
set http_version $::EMPTY_STRING
set monitor_dns_name $::EMPTY_STRING
set monitor_type http
7 Replies
Sort By
- just wanted to mention I know I could create the monitor first and then point to it during the presentation but I'm trying to build a fully self-sufficient template.
- There is a drop-down labeled with "What HTTP version do your HTTP servers expect clients to use?" which has two options "Version 1.0" and "Version 1.1". It defaults to version 1.0. For what you are trying to do, you need to switch it to "Version 1.1" The reason why is the HTTP version 1.0 requests have just a single \r\n and version 1.1 requests have two of them. You are sending an HTTP version 1.1 send string, but the HTTP version is still set to version 1.0. This is causing you problems. If you switch it to version 1.1, it should solve the truncation problem. You can change the default on that control to version 1.1, or even remove that control and hard-code version 1.1.
- There appears to be a bug in the create_monitor proc within f5.app_utils where when using HTTP/1.0, one of the CRLFs is stripped incorrectly. It seems that when you removed the inputs for the http version and call that procedure with a blank value for the version (but still had HTTP/1.1 in the send string) that you're hitting this bug even though you're not explicitly specifying HTTP/1.0.
- Guys
- 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.
- Let us know if Mitra's suggestion didn't get you up and running. It might be that you would be best-served by bypassing the convenience proc and just issuing the tmsh::create call for the monitor directly.
I had the exact same problem and I found this nice little workaround:
string monquery default tcl { set results {GET / HTTP/1.1\r\nHost: localhost\r\nUser-Agent: F5LTM/11\r\nConnection: Close\r\n\r\n} return $results } required display “xlarge"
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