Forum Discussion
Deepak_Kumar2
Jan 13, 2022Nimbostratus
Getting HTML Page Title for iRule
Hi All, I am working on creating a new VIP with 2 servers(each server has its separate pool). One of the server have some issues and at times it directly through a Logout Page while accessing ...
Jan 14, 2022
The title of the HTML page isn't part of any HTTP header. It's part of the document that's being returned by the webserver. So you'll need to enable the STREAM profile and use it to parse the response. The iRule below shows how to extract the title.
when HTTP_REQUEST {
# Disable the stream filter by default
STREAM::disable
# LTM does not uncompress response content, so if the server has compression enabled
# and it cannot be disabled on the server, we can prevent the server from
# sending a compressed response by removing the compression offerings from the client
HTTP::header remove "Accept-Encoding"
}
when HTTP_RESPONSE {
# Check if response type is text
if {[HTTP::header value Content-Type] starts_with "text"} {
# match <title>...</title>
STREAM::expression {=<title>[A-Za-z0-9\.\-]+==}
# Enable the stream filter for this response only
STREAM::enable
}
}
when STREAM_MATCHED {
# extract the title
set title [string range [STREAM::match] 7 end]
log local0.info "Title: $title"
}
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