Class: RobotsTxtServlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/mechanize/test_case/robots_txt_servlet.rb

Instance Method Summary collapse

Instance Method Details

#do_GET(req, res) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/mechanize/test_case/robots_txt_servlet.rb', line 3

def do_GET(req, res)
  if /301/ === req['Host'] && req.path == '/robots.txt'
    res['Location'] = 'http://301/robots_txt'
    res.code = 301
  else
    res['Content-Type'] = 'text/plain'
    res.body = <<-'EOF'
User-Agent: *
Disallow: /norobots
    EOF
  end
end