Class: DigestAuthServlet
- Inherits:
-
WEBrick::HTTPServlet::AbstractServlet
- Object
- WEBrick::HTTPServlet::AbstractServlet
- DigestAuthServlet
- Defined in:
- lib/mechanize/test_case.rb
Constant Summary collapse
- @@authenticator =
WEBrick::HTTPAuth::DigestAuth.new({ :UserDB => htpd, :Realm => 'Blah', :Algorithm => 'MD5', :Logger => Logger.new(nil) } )
Instance Method Summary collapse
- #do_GET(req, res) ⇒ Object (also: #do_POST)
Instance Method Details
#do_GET(req, res) ⇒ Object Also known as: do_POST
152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/mechanize/test_case.rb', line 152 def do_GET(req,res) def req.request_time; Time.now; end def req.request_uri; '/digest_auth'; end def req.request_method; "GET"; end begin @@authenticator.authenticate(req,res) res.body = 'You are authenticated' rescue WEBrick::HTTPStatus::Unauthorized res.status = 401 end FileUtils.rm('digest.htpasswd') if File.exists?('digest.htpasswd') end |