Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #16 from lmeijvogel/9d91c041f5fb2ca3b969e1e8b5c3a8…
Browse files Browse the repository at this point in the history
…172a2700bf

Always authenticate if server requires it
  • Loading branch information
Dev Random committed Aug 27, 2011
2 parents 11c0136 + 9d91c04 commit de04a29
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/net/dav.rb
Expand Up @@ -135,7 +135,7 @@ def request(verb, path, body, headers)
Net::HTTP::Copy.new(path)
when :proppatch
Net::HTTP::Proppatch.new(path)
when :lock
when :lock
Net::HTTP::Lock.new(path)
when :unlock
Net::HTTP::Unlock.new(path)
Expand All @@ -153,6 +153,13 @@ def handle_request(req, headers, limit = MAX_REDIRECTS, &block)
# You should choose better exception.
raise ArgumentError, 'HTTP redirect too deep' if limit == 0

case @authorization
when :basic
req.basic_auth @user, @pass
when :digest
digest_auth(req, @user, @pass, response)
end

response = nil
if block
@http.request(req) {|res|
Expand All @@ -176,11 +183,11 @@ def handle_request(req, headers, limit = MAX_REDIRECTS, &block)
if disable_basic_auth
raise "server requested basic auth, but that is disabled"
end
new_req.basic_auth @user, @pass
@authorization = :basic
else
digest_auth(new_req, @user, @pass, response)
@authorization = :digest
end
return handle_request(new_req, headers, limit - 1, &block)
return handle_request(req, headers, limit - 1, &block)
when Net::HTTPRedirection then
location = URI.parse(response['location'])
if (@uri.scheme != location.scheme ||
Expand Down

0 comments on commit de04a29

Please sign in to comment.