test/test_servlets.rb in mechanize-0.6.4 vs test/test_servlets.rb in mechanize-0.6.5
- old
+ new
@@ -14,9 +14,30 @@
res['Content-Type'] = "text/html"
res.body = req['Referer'] || ''
end
end
+class ModifiedSinceServlet < WEBrick::HTTPServlet::AbstractServlet
+ 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
+end
+
class GzipServlet < WEBrick::HTTPServlet::AbstractServlet
def do_GET(req, res)
if req['Accept-Encoding'] =~ /gzip/
File.open("#{BASE_DIR}/htdocs/#{req.query['file']}", 'r') do |file|
string = ""