Class: SendCookiesServlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/mechanize/test_case/send_cookies_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
15
16
17
18
# File 'lib/mechanize/test_case/send_cookies_servlet.rb', line 3

def do_GET(req, res)
  res.content_type = 'text/html'

  cookies = req.cookies.map do |c|
    "<li><a href=\"#\">#{c.name}:#{c.value}</a>"
  end.join "\n"

  res.body = <<-BODY
<!DOCTYPE html>
<title>Your cookies</title>

<ul>
#{cookies}
</ul>
  BODY
end