Skip to content

Commit

Permalink
Merge pull request #147 from continuum/always-send-auth-credentials-f…
Browse files Browse the repository at this point in the history
…or-basic-auth

Avoid waiting for a WWW-Authenticate under HTTP Basic auth
  • Loading branch information
maxdemarzi committed Feb 13, 2014
2 parents f6b64c0 + d5df0c4 commit 715ef13
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/neography/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,18 @@ def log(path, body)
end

def authenticate(path = nil)
@client.set_auth(path,
@authentication[@authentication.keys.first][:username],
@authentication[@authentication.keys.first][:password]) unless @authentication.empty?
unless @authentication.empty?
auth_type = @authentication.keys.first
@client.set_auth(
path,
@authentication[auth_type][:username],
@authentication[auth_type][:password]
)
# Force http client to always send auth credentials without
# waiting for WWW-Authenticate headers, thus saving one request
# roundtrip for each URI. Only works for HTTP basic auth.
@client.www_auth.basic_auth.challenge(configuration) if auth_type == 'basic_auth'
end
end

private
Expand Down

0 comments on commit 715ef13

Please sign in to comment.