In a simple test on 9.4.6, I was able to send a 503 with content using HTTP::respond. I've also used a 503 in 9.2.4 and 9.3.1. I'm not sure if it was a bug in an older version or a configuration issue. But if you're seeing a problem with sending a 503, can you post the iRule you're testing and the results of the tests?
when HTTP_REQUEST {
set data {Some data to send to the client. If you want to use variables in here, replace the curly braces with quotes.}
Look for a URI starting with a forward slash and then 3 digits (the first digit being 1-5)
If one is found, set it as the HTTP response code. Else, send back an HTTP 200
if {[string match {/[1-5][0-9][0-9]*} [HTTP::path]]}{
Send the response with the status code from the requested path and data
HTTP::respond [string range [HTTP::path] 1 3] content $data "a_header_name" "a_header_value"
log local0. "Sending [string range [HTTP::path] 1 3] response with $data"
} else {
Send a 200 response with data
HTTP::respond 200 content $data "a_header_name" "a_header_value"
log local0. "Sending default 200 response with $data"
}
}
Example curl request:
curl -v 10.42.2.102/503
* About to connect() to 10.42.2.102 port 80
* Trying 10.42.2.102... connected
* Connected to 10.42.2.102 (10.42.2.102) port 80
> GET /503 HTTP/1.1
> User-Agent: curl/7.15.3 (i686-redhat-linux-gnu) libcurl/7.15.3 OpenSSL/0.9.7l zlib/1.1.4
> Host: 10.42.2.102
> Accept: */*
>
< HTTP/1.0 503 Service Unavailable
< a_header_name: a_header_value
* HTTP/1.0 connection set to keep alive!
< Connection: Keep-Alive
< Content-Length: 109
Connection 0 to host 10.42.2.102 left intact
* Closing connection 0
Some data to send to the client. If you want to use variables in here, replace the curly braces with quotes.
Aaron