Skip to content

Does not work against httpbin digest-auth endpoint #15

Description

@HoneyryderChuck

I've tried to use this gem against httpbin's endpoints, and either the digest header hasn't been properly generated, or I'm failing to see how to set this up:

require "net/http"
require "net/http/digest_auth"

uri = URI.parse "http://httpbin.org/digest-auth/auth/user/pass"
uri.user = "user"
uri.password = "pass"

h = Net::HTTP.new uri.host, uri.port
h.set_debug_output $stderr

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

puts
puts "passed" if res.code == "200"
puts "failed" if res.code != "200"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions