Class: ManyCookiesServlet

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

Instance Method Summary collapse

Instance Method Details

#do_GET(req, res) ⇒ Object



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/mechanize/test_case.rb', line 306

def do_GET(req, res)
  name_cookie = WEBrick::Cookie.new("name", "Aaron")
  name_cookie.path = "/"
  name_cookie.expires = Time.now + 86400
  res.cookies << name_cookie
  res.cookies << name_cookie
  res.cookies << name_cookie
  res.cookies << name_cookie

  expired_cookie = WEBrick::Cookie.new("expired", "doh")
  expired_cookie.path = "/"
  expired_cookie.expires = Time.now - 86400
  res.cookies << expired_cookie

  different_path_cookie = WEBrick::Cookie.new("a_path", "some_path")
  different_path_cookie.path = "/some_path"
  different_path_cookie.expires = Time.now + 86400
  res.cookies << different_path_cookie

  no_path_cookie = WEBrick::Cookie.new("no_path", "no_path")
  no_path_cookie.expires = Time.now + 86400
  res.cookies << no_path_cookie

  no_exp_path_cookie = WEBrick::Cookie.new("no_expires", "nope")
  no_exp_path_cookie.path = "/"
  res.cookies << no_exp_path_cookie

  res['Content-Type'] = "text/html"
  res.body = "<html><body>hello</body></html>"
end