Method: FormServlet#do_POST

Defined in:
lib/mechanize/test_case/form_servlet.rb

#do_POST(req, res) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/mechanize/test_case/form_servlet.rb', line 29

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

  query = []

  req.query.each_key { |k|
    key = WEBrick::HTTPUtils.unescape k

    req.query[k].each_data { |data|
      value = WEBrick::HTTPUtils.unescape data
      query << "<li><a href=\"#\">#{key}:#{value}</a>"
    }
  }

  res.body = "<!DOCTYPE html>\n<title>POST results</title>\n\n<ul>\n\#{query.join \"\\n\"}\n</ul>\n\n<div id=\\\"query\\\">\#{req.body}</div>\n  BODY\nend\n"