Module: HTTPX::Plugins::NTLMAuth::InstanceMethods
- Defined in:
- lib/httpx/plugins/ntlm_authentication.rb
Instance Method Summary collapse
- #ntlm_authentication(user, password, domain = nil) ⇒ Object (also: #ntlm_auth)
- #send_requests(*requests) ⇒ Object
Instance Method Details
#ntlm_authentication(user, password, domain = nil) ⇒ Object Also known as: ntlm_auth
28 29 30 |
# File 'lib/httpx/plugins/ntlm_authentication.rb', line 28 def ntlm_authentication(user, password, domain = nil) with(ntlm: Authentication::Ntlm.new(user, password, domain: domain)) end |
#send_requests(*requests) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/httpx/plugins/ntlm_authentication.rb', line 34 def send_requests(*requests) requests.flat_map do |request| ntlm = request..ntlm if ntlm request.headers["authorization"] = ntlm.negotiate probe_response = wrap { super(request).first } return probe_response unless probe_response.is_a?(Response) if probe_response.status == 401 && ntlm.can_authenticate?(probe_response.headers["www-authenticate"]) request.transition(:idle) request.headers["authorization"] = ntlm.authenticate(request, probe_response.headers["www-authenticate"]) super(request) else probe_response end else super(request) end end end |