Method: HTTPClient::ProxyAuth#filter_response

Defined in:
lib/httpclient/auth.rb

#filter_response(req, res) ⇒ Object

Filter API implementation. Traps HTTP response and parses ‘Proxy-Authenticate’ header.



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/httpclient/auth.rb', line 204

def filter_response(req, res)
  command = nil
  if res.status == HTTP::Status::PROXY_AUTHENTICATE_REQUIRED
    if challenge = parse_authentication_header(res, 'proxy-authenticate')
      uri = req.header.request_uri
      challenge.each do |scheme, param_str|
        @authenticator.each do |auth|
          next unless auth.set? # hasn't be set, don't use it
          if scheme.downcase == auth.scheme.downcase
            challengeable = auth.challenge(uri, param_str)
            command = :retry if challengeable
          end
        end
      end
      # ignore unknown authentication scheme
    end
  end
  command
end