Skip to content

Instantly share code, notes, and snippets.

@gbuesing
Created April 29, 2009 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gbuesing/104007 to your computer and use it in GitHub Desktop.
Save gbuesing/104007 to your computer and use it in GitHub Desktop.
Rack::Honeypot
# Returns a blank 200 OK response for any form posts that include a value for the honeypot field
module Rack
class Honeypot
def initialize(app, field_name)
@app = app
@field_name = field_name
end
def call(env)
form_hash = env["rack.request.form_hash"]
if form_hash && form_hash[@field_name] =~ /\S/
[200, {'Content-Type' => 'text/html', "Content-Length" => "0"}, []]
else
@app.call(env)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment