Browse files

Add example to documentation

  • Loading branch information...
1 parent ae03253 commit aafed0bb8e2422af71303cb7aca7539d99c56dc6 @drbrain committed Sep 10, 2010
Showing with 24 additions and 0 deletions.
  1. +24 −0 lib/net/http/digest_auth.rb
View
24 lib/net/http/digest_auth.rb
@@ -6,6 +6,30 @@
# An implementation of RFC 2617 Digest Access Authentication.
#
# http://www.rfc-editor.org/rfc/rfc2617.txt
+#
+# Here is a sample usage of DigestAuth on Net::HTTP:
+#
+# require 'uri'
+# require 'net/http'
+# require 'net/http/digest_auth'
+#
+# uri = URI.parse 'http://localhost:8000/'
+# uri.user = 'username'
+# uri.password = 'password'
+#
+# h = Net::HTTP.new uri.host, uri.port
+#
+# req = Net::HTTP::Get.new uri.request_uri
+#
+# res = h.request req
+#
+# digest_auth = Net::HTTP::DigestAuth.new
+# auth = digest_auth.auth_header uri, res['www-authenticate'], 'GET'
+#
+# req = Net::HTTP::Get.new uri.request_uri
+# req.add_field 'Authorization', auth
+#
+# res = h.request req
class Net::HTTP::DigestAuth

0 comments on commit aafed0b

Please sign in to comment.