Class: ModifiedSinceServlet

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



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/mechanize/test_case.rb', line 339

def do_GET(req, res)
  s_time = 'Fri, 04 May 2001 00:00:38 GMT'

  my_time = Time.parse(s_time)

  if req['If-Modified-Since']
    your_time = Time.parse(req['If-Modified-Since'])
    if my_time > your_time
      res.body = 'This page was updated since you requested'
    else
      res.status = 304
    end
  else
    res.body = 'You did not send an If-Modified-Since header'
  end

  res['Last-Modified'] = s_time
end