Fun with iRules: Haiku Error Responses

One of our stellar sales engineers, Rob Eberhardt, whipped up a fun iRule after one of his customers showed him some HTTP 404 errors returning haiku in BeOS.  The class, and iRule, followed by the result.  Enjoy!

The Class

Stored as an external class in /var/class/haiku_int.class (integer type).

1 := "The web site you seek
Lies beyond our perception
But others await."
,
2 := "Sites you are seeking
From your path they are fleeing
Their winter has come."
,
3 := "A truth found, be told
You are far from the fold, Go
Come back yet again."
,
4 := "Wind catches lily
Scatt'ring petals to the wind:
Your site is not found."
,
5 := "These three are certain:
Death, taxes, and site not found.
You, victim of one."
,
6 := "Ephemeral site.
I am the Blue Screen of Death.
No one hears your screams."
,

This continues on through 38, but the remaining ones removed for brevity.  Now the class reference:

class haiku_class {
   type value
   filename "/var/class/haiku_int.class"
   separator ":="
   }

The iRule

when RULE_INIT {
  set static::error_404 {
        
        
        
        
"#E7E7E7">
        
class=Section1>
        
        

class=MsoNormal align=center>

        
        
        table width=500 height=258>
        
        
'background:#0078AD'>
        

        'font-family:"Arial","sans-serif"; color: white; font-size: large'>
        Error 404:
File Not Found
        
        
'background:white'>
        

'font-family:"Arial","sans-serif"'>

    }  
}
when HTTP_RESPONSE {
  if { [HTTP::status] == 404 } {
    set randomnumber [expr { int (38 * rand()) }]
    set haiku [class match -value $randomnumber equals haiku_class]
    set response [concat $static::error_404 $haiku]
    HTTP::respond 200 content [subst $response]
  }
} 

The Result

Here’s a couple snapshots of the browser (I commented out the if clause to generate the error every request)

Related Articles

Published Apr 27, 2011
Version 1.0
No CommentsBe the first to comment