Method: HTTPClient::BasicAuth#get

Defined in:
lib/httpclient/auth.rb

#get(req) ⇒ Object

Response handler: returns credential. It sends cred only when a given uri is;

  • child page of challengeable(got *Authenticate before) uri and,

  • child page of defined credential



284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/httpclient/auth.rb', line 284

def get(req)
  target_uri = req.header.request_uri
  synchronize {
    return nil if !@force_auth and !@challenge.any? { |uri, ok|
      Util.uri_part_of(target_uri, uri) and ok
    }
    return @cred if @cred
    Util.hash_find_value(@auth) { |uri, cred|
      Util.uri_part_of(target_uri, uri)
    }
  }
end