diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d69fc1..bda2ad6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ * Fix: [#88](https://github.com/savonrb/httpi/issues/88) timeout and proxy options are now properly passed to the EM-HTTP-Request client. +* Fix: [#90](https://github.com/savonrb/httpi/issues/90) we now raise an error if + you try to use Net::HTTP with HTTP digest authentication, because Net::HTTP does + not support digest authentication. + ### 2.0.2 (2013-01-26) * Feature: Changed `HTTPI::Request#set_cookies` to accept an Array of `HTTPI::Cookie` diff --git a/lib/httpi/adapter/net_http.rb b/lib/httpi/adapter/net_http.rb index 050dbc5..851d37b 100644 --- a/lib/httpi/adapter/net_http.rb +++ b/lib/httpi/adapter/net_http.rb @@ -127,6 +127,10 @@ def request_client(type) request_client = request_class.new @request.url.request_uri, @request.headers request_client.basic_auth *@request.auth.credentials if @request.auth.basic? + if @request.auth.digest? + raise NotSupportedError, "Net::HTTP does not support HTTP digest authentication" + end + request_client end diff --git a/spec/httpi/adapter/net_http_spec.rb b/spec/httpi/adapter/net_http_spec.rb index 1c2a3f6..bad776e 100644 --- a/spec/httpi/adapter/net_http_spec.rb +++ b/spec/httpi/adapter/net_http_spec.rb @@ -60,6 +60,14 @@ response.body.should eq("basic-auth") end + it "does not support digest authentication" do + request = HTTPI::Request.new(@server.url + "digest-auth") + request.auth.digest("admin", "secret") + + expect { HTTPI.get(request, adapter) }. + to raise_error(HTTPI::NotSupportedError, /does not support HTTP digest authentication/) + end + it "supports ntlm authentication" do request = HTTPI::Request.new(@server.url + "ntlm-auth") request.auth.ntlm("tester", "vReqSoafRe5O")