ACCESS::respond

Description

This command generates new respond and automatically overrides the default respond. This command only can be used only once per HTTP request, and subsequent calls to this command will return an error. Notes:

Additional capabilities:

  • ACCESS::respond will ignores empty header name, but not header value. e.g. ACCESS::respond 200 content $body $header_name $header_value. If $header_name is empty, ACCESS::respond will also ignore $header_value.
  • By default keeping connection alive is determined by HTTP hudfilter via http_keepalive(). The admin can override Keep-Alive state to force connection close via specifying header Connection Close. Currrently we don’t support forcing connection to be keep-alive.
  • For 401, This command will automatically insert this header WWW-Authenticate: Basic realm=””. This can be overriden by specifying WWW-Authenticate header value.

Changed behavior on ACCESS

  • As above, this command will override the default respond. If there is no respond, such as forwarding the request to the backend server, this command will cancel that forwarding.
  • ACCESS default response is actually closing the connection. When this command is used, ACCESS will no longer close the connection unless admin force to close it via Connection header.

Syntax

ACCESS::respond <status code> [content <content>] [noserver] [<header name> <header value>]+

Examples

when ACCESS_POLICY_COMPLETED {
    set policy_result [ACCESS::policy result]
    switch $policy_result {
    "allow" {
    # Do nothing
    }
    "deny" {
        ACCESS::respond 401 content "<html><body>Error: Failure in Authentication</body></html>" Connection Close
    }
    }
}