DataScript: avi.http.get_host_tokens

DataScript

Function avi.http.get_host_tokens("MODIFIED" [,start [, end]]) or avi.http.get_host_tokens( [start [, end]] )
Description
  • avi.http.get_host_tokens("MODIFIED") or avi.http.get_host_tokens("MODIFIED", start) or avi.http.get_host_tokens("MODIFIED", start, end): Returns the updated host header tokens. For example, When the host header is overwritten by the Rewrite URL action of HTTP Policies.
  • avi.http.get_host_tokens( [start [, end]] ): Retrieves individual host sections, or tokens, from the hostname (aka strings separated by the delimiter ‘.’) when called without arguments. The command provides the flexibility to get a slice of host tokens (see examples below) when start and/or end indices are provided.
Events HTTP_REQ
HTTP_RESP
Parameter start and/or end indices, which allow parsing out section of the host header.
Returns If no start and end indices are specified, returns a table of all the host tokens. If either start index is specified or both start and end indices are specified, returns a string.
Example Example host header:http://www.avinetworks.com/a/b/index.htm?avi=true If we have HTTP Request Policies with Redirect action to www.vmware.com
avi.http.get_host_tokens("MODIFIED", 1)
Returns ‘www.vmware.com’
avi.http.get_host_tokens(1)
Returns ‘www.avinetworks.com’
avi.http.get_host_tokens("MODIFIED",2,2)
Returns ‘vmware’
avi.http.get_host_tokens(2,2)
Returns ‘avinetworks’
avi.http.get_host_tokens(6)
Returns 'nil'
avi.http.get_host_tokens("MODIFIED", 6)
Returns ‘nil’
domain = avi.http.get_host_tokens(2, 3)
if domain ~= "avinetworks.com" then
   avi.http.redirect("new.avinetworks.com")
end

Note: This API is not supported in the events SSL_PRECONNECT, SSL_CLIENTHELLO, and SSL_HANDSHAKE_DONE.