Forum Discussion

mahnsc's avatar
mahnsc
Icon for Nimbostratus rankNimbostratus
Jan 11, 2019

Valid Events for HTTP::host

Hi everyone. When I look at the documentation for the HTTP::host command, the valid events listed are: CACHE_REQUEST, HTTP_REQUEST, HTTP_REQUEST_DATA, HTTP_REQUEST_SEND

 

When I look at the available commands for the HTTP_RESPONSE event, the HTTP::host command is listed.

 

I have an iRule that contains a switch -glob for both HTTP_REQUEST AND HTTP_RESPONSE but when trying to save it, I get an error under the HTTP_RESPONSE portion of the iRule that says: [command is not valid in current event context (HTTP_RESPONSE)][HTTP::host]

 

  • retrieving the clientside request HTTP::host is not available in a serverside response event such as HTTP_RESPONSE. Grab it in HTTP_REQUEST, save it as a variable and refer to it in HTTP_RESPONSE

    when HTTP_REQUEST {
        host = [HTTP::host]
    }
    when HTTP_RESPONSE {
        log local0. "My host: $host"
    }